@visuallyjs/browser-ui-angular 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/esm2022/index.mjs +3 -0
  2. package/esm2022/lib/charts/area.chart.component.mjs +8 -36
  3. package/esm2022/lib/charts/bar.chart.component.mjs +8 -36
  4. package/esm2022/lib/charts/bubble.chart.component.mjs +8 -36
  5. package/esm2022/lib/charts/column.chart.component.mjs +8 -36
  6. package/esm2022/lib/charts/line.chart.component.mjs +8 -36
  7. package/esm2022/lib/charts/pie.chart.component.mjs +8 -36
  8. package/esm2022/lib/charts/sankey.chart.component.mjs +12 -8
  9. package/esm2022/lib/charts/scatter.chart.component.mjs +8 -36
  10. package/esm2022/lib/charts/series.based.chart.component.mjs +54 -0
  11. package/esm2022/lib/charts/xy.chart.component.mjs +10 -22
  12. package/esm2022/lib/color.tag.component.mjs +33 -27
  13. package/esm2022/lib/controls-component.mjs +48 -44
  14. package/esm2022/lib/diagram-palette-component.mjs +37 -32
  15. package/esm2022/lib/edge.type.picker.component.mjs +23 -18
  16. package/esm2022/lib/export-controls-component.mjs +7 -9
  17. package/esm2022/lib/hooks/use-visuallyjs-update.mjs +21 -0
  18. package/esm2022/lib/hooks/use-zoom.mjs +24 -0
  19. package/esm2022/lib/inspector.component.mjs +29 -27
  20. package/esm2022/lib/miniview-component.mjs +33 -25
  21. package/esm2022/lib/palette.component.mjs +42 -37
  22. package/esm2022/lib/shape.component.mjs +20 -18
  23. package/esm2022/lib/shape.palette.component.mjs +25 -21
  24. package/esm2022/lib/surface-component.mjs +7 -5
  25. package/esm2022/lib/vjs-service.mjs +35 -1
  26. package/fesm2022/visuallyjs-browser-ui-angular.mjs +466 -503
  27. package/fesm2022/visuallyjs-browser-ui-angular.mjs.map +1 -1
  28. package/index.d.ts +3 -0
  29. package/lib/charts/area.chart.component.d.ts +10 -15
  30. package/lib/charts/bar.chart.component.d.ts +9 -15
  31. package/lib/charts/bubble.chart.component.d.ts +12 -15
  32. package/lib/charts/column.chart.component.d.ts +12 -15
  33. package/lib/charts/line.chart.component.d.ts +16 -17
  34. package/lib/charts/pie.chart.component.d.ts +9 -15
  35. package/lib/charts/sankey.chart.component.d.ts +5 -0
  36. package/lib/charts/scatter.chart.component.d.ts +9 -15
  37. package/lib/charts/series.based.chart.component.d.ts +44 -0
  38. package/lib/charts/xy.chart.component.d.ts +13 -11
  39. package/lib/color.tag.component.d.ts +5 -5
  40. package/lib/controls-component.d.ts +6 -4
  41. package/lib/diagram-palette-component.d.ts +8 -2
  42. package/lib/edge.type.picker.component.d.ts +5 -5
  43. package/lib/export-controls-component.d.ts +6 -6
  44. package/lib/hooks/use-visuallyjs-update.d.ts +21 -0
  45. package/lib/hooks/use-zoom.d.ts +6 -0
  46. package/lib/inspector.component.d.ts +6 -7
  47. package/lib/miniview-component.d.ts +17 -9
  48. package/lib/palette.component.d.ts +5 -6
  49. package/lib/shape.component.d.ts +5 -5
  50. package/lib/shape.palette.component.d.ts +5 -3
  51. package/lib/surface-component.d.ts +5 -1
  52. package/lib/vjs-service.d.ts +41 -0
  53. package/package.json +2 -2
  54. package/visuallyjs-browser-ui-angular.tgz +0 -0
package/esm2022/index.mjs CHANGED
@@ -23,6 +23,7 @@ export * from './lib/edge.type.picker.component';
23
23
  export * from './lib/inspector.component';
24
24
  export * from './lib/color.tag.component';
25
25
  export * from './lib/diagram-component';
26
+ export * from './lib/charts/series.based.chart.component';
26
27
  export * from './lib/charts/column.chart.component';
27
28
  export * from './lib/charts/bar.chart.component';
28
29
  export * from './lib/charts/line.chart.component';
@@ -32,3 +33,5 @@ export * from './lib/charts/pie.chart.component';
32
33
  export * from './lib/charts/scatter.chart.component';
33
34
  export * from './lib/charts/bubble.chart.component';
34
35
  export * from './lib/charts/sankey.chart.component';
36
+ export * from './lib/hooks/use-zoom';
37
+ export * from './lib/hooks/use-visuallyjs-update';
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, Input, NgZone, inject } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { AreaChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class AreaChartComponent {
6
- constructor() {
7
- this.$vjs = inject(VisuallyJsService);
8
- this.$el = inject(ElementRef);
9
- this.$ngZone = inject(NgZone);
5
+
6
+ export class AreaChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new AreaChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new AreaChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: AreaChartComponent, selector: "vjs-area-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AreaChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: AreaChartComponent, selector: "vjs-area-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AreaChartComponent, decorators: [{
42
14
  type: Component,
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, Input, NgZone, inject } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { BarChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class BarChartComponent {
6
- constructor() {
7
- this.$vjs = inject(VisuallyJsService);
8
- this.$el = inject(ElementRef);
9
- this.$ngZone = inject(NgZone);
5
+
6
+ export class BarChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new BarChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new BarChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BarChartComponent, selector: "vjs-bar-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BarChartComponent, selector: "vjs-bar-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BarChartComponent, decorators: [{
42
14
  type: Component,
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, inject, Input, NgZone } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { BubbleChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class BubbleChartComponent {
6
- constructor() {
7
- this.$el = inject(ElementRef);
8
- this.$ngZone = inject(NgZone);
9
- this.$vjs = inject(VisuallyJsService);
5
+
6
+ export class BubbleChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new BubbleChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new BubbleChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BubbleChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BubbleChartComponent, selector: "vjs-bubble-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BubbleChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: BubbleChartComponent, selector: "vjs-bubble-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BubbleChartComponent, decorators: [{
42
14
  type: Component,
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, inject, Input, NgZone } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { ColumnChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class ColumnChartComponent {
6
- constructor() {
7
- this.$el = inject(ElementRef);
8
- this.$ngZone = inject(NgZone);
9
- this.$vjs = inject(VisuallyJsService);
5
+
6
+ export class ColumnChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new ColumnChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new ColumnChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnChartComponent, selector: "vjs-column-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnChartComponent, selector: "vjs-column-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnChartComponent, decorators: [{
42
14
  type: Component,
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, Input, NgZone, inject } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { LineChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class LineChartComponent {
6
- constructor() {
7
- this.$el = inject(ElementRef);
8
- this.$ngZone = inject(NgZone);
9
- this.$vjs = inject(VisuallyJsService);
5
+
6
+ export class LineChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new LineChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new LineChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: LineChartComponent, selector: "vjs-line-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: LineChartComponent, selector: "vjs-line-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineChartComponent, decorators: [{
42
14
  type: Component,
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, Input, NgZone, inject } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { PieChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class PieChartComponent {
6
- constructor() {
7
- this.$el = inject(ElementRef);
8
- this.$ngZone = inject(NgZone);
9
- this.$vjs = inject(VisuallyJsService);
5
+
6
+ export class PieChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new PieChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new PieChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PieChartComponent, selector: "vjs-pie-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PieChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PieChartComponent, selector: "vjs-pie-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PieChartComponent, decorators: [{
42
14
  type: Component,
@@ -1,12 +1,21 @@
1
- import { Component, inject, ElementRef, Input, NgZone } from "@angular/core";
1
+ import { Component, inject, ElementRef, Input, NgZone, effect } from "@angular/core";
2
2
  import { SankeyChart } from "@visuallyjs/browser-ui";
3
3
  import { VisuallyJsService } from "../vjs-service";
4
4
  import * as i0 from "@angular/core";
5
+
5
6
  export class SankeyChartComponent {
6
7
  constructor() {
7
8
  this.$el = inject(ElementRef);
8
9
  this.$ngZone = inject(NgZone);
9
10
  this.$vjs = inject(VisuallyJsService);
11
+ effect(() => {
12
+ if (this.useModel && this.chart == null) {
13
+ const m = this.$vjs.model();
14
+ if (m != null) {
15
+ this._init(m, null, null, null);
16
+ }
17
+ }
18
+ });
10
19
  }
11
20
 
12
21
  _init(dataSource, csvData, jsonData, url) {
@@ -29,12 +38,7 @@ export class SankeyChartComponent {
29
38
  }
30
39
 
31
40
  ngAfterViewInit() {
32
- if (this.useModel) {
33
- this.$vjs.getModel((p) => {
34
- this._init(p, null, null, null);
35
- });
36
- }
37
- else {
41
+ if (!this.useModel) {
38
42
  this._init(null, this.csvData, this.jsonData, this.url);
39
43
  }
40
44
  }
@@ -57,7 +61,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
57
61
  selector: "vjs-sankey-chart",
58
62
  template: `<div></div>`
59
63
  }]
60
- }], propDecorators: { csvData: [{
64
+ }], ctorParameters: function () { return []; }, propDecorators: { csvData: [{
61
65
  type: Input
62
66
  }], jsonData: [{
63
67
  type: Input
@@ -1,42 +1,14 @@
1
- import { Component, ElementRef, inject, Input, NgZone } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { ScatterChart } from "@visuallyjs/browser-ui";
3
- import { VisuallyJsService } from "../vjs-service";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
4
4
  import * as i0 from "@angular/core";
5
- export class ScatterChartComponent {
6
- constructor() {
7
- this.$el = inject(ElementRef);
8
- this.$ngZone = inject(NgZone);
9
- this.$vjs = inject(VisuallyJsService);
5
+
6
+ export class ScatterChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new ScatterChart(el, options);
10
9
  }
11
- _init(dataSource, data, url) {
12
- this.$ngZone.runOutsideAngular(() => {
13
- const o = Object.assign({}, this.options);
14
- Object.assign(o, { dataSource });
15
- this.chart = new ScatterChart(this.$el.nativeElement, o);
16
- if (data) {
17
- this.chart.load({ data });
18
- }
19
- else if (url) {
20
- this.chart.load({ url });
21
- }
22
- });
23
- }
24
-
25
- ngAfterViewInit() {
26
- if (this.useModel) {
27
- this.$vjs.getModel((p) => {
28
- this._init(p, null, null);
29
- });
30
- }
31
- else {
32
- this._init(null, this.data, this.url);
33
- }
34
- }
35
- ngOnDestroy() {
36
- this.chart?.destroy();
37
- }
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScatterChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
39
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ScatterChartComponent, selector: "vjs-scatter-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScatterChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ScatterChartComponent, selector: "vjs-scatter-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
40
12
  }
41
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScatterChartComponent, decorators: [{
42
14
  type: Component,
@@ -0,0 +1,54 @@
1
+ import { effect, ElementRef, inject, Injectable, Input, NgZone } from "@angular/core";
2
+ import { VisuallyJsService } from "../vjs-service";
3
+ import * as i0 from "@angular/core";
4
+
5
+ export class SeriesBasedChartComponent {
6
+ _init(dataSource, data, url) {
7
+ this.$ngZone.runOutsideAngular(() => {
8
+ const o = Object.assign({}, this.options);
9
+ Object.assign(o, { dataSource });
10
+ this.chart = this.createChart(this.$el.nativeElement, o);
11
+ if (data) {
12
+ this.chart.load({ data });
13
+ }
14
+ else if (url) {
15
+ this.chart.load({ url });
16
+ }
17
+ });
18
+ }
19
+ constructor() {
20
+ this.$el = inject(ElementRef);
21
+ this.$ngZone = inject(NgZone);
22
+ this.$vjs = inject(VisuallyJsService);
23
+ effect(() => {
24
+ if (this.useModel && this.chart == null) {
25
+ const m = this.$vjs.model();
26
+ if (m != null) {
27
+ this._init(m, null, null);
28
+ }
29
+ }
30
+ });
31
+ }
32
+
33
+ ngAfterViewInit() {
34
+ if (!this.useModel) {
35
+ this._init(null, this.data, this.url);
36
+ }
37
+ }
38
+ ngOnDestroy() {
39
+ this.chart?.destroy();
40
+ }
41
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SeriesBasedChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
42
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SeriesBasedChartComponent }); }
43
+ }
44
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SeriesBasedChartComponent, decorators: [{
45
+ type: Injectable
46
+ }], ctorParameters: function () { return []; }, propDecorators: { data: [{
47
+ type: Input
48
+ }], url: [{
49
+ type: Input
50
+ }], options: [{
51
+ type: Input
52
+ }], useModel: [{
53
+ type: Input
54
+ }] } });
@@ -1,28 +1,14 @@
1
- import { Component, ElementRef, Input, NgZone, inject } from "@angular/core";
1
+ import { Component, Input } from "@angular/core";
2
2
  import { CategoryValueChart } from "@visuallyjs/browser-ui";
3
+ import { SeriesBasedChartComponent } from "./series.based.chart.component";
3
4
  import * as i0 from "@angular/core";
4
- export class XYChartComponent {
5
- constructor() {
6
- this.$el = inject(ElementRef);
7
- this.$ngZone = inject(NgZone);
5
+
6
+ export class XYChartComponent extends SeriesBasedChartComponent {
7
+ createChart(el, options) {
8
+ return new CategoryValueChart(el, options);
8
9
  }
9
-
10
- ngAfterViewInit() {
11
- this.$ngZone.runOutsideAngular(() => {
12
- this.chart = new CategoryValueChart(this.$el.nativeElement, this.options);
13
- if (this.data) {
14
- this.chart.load({ data: this.data });
15
- }
16
- else if (this.url) {
17
- this.chart.load({ url: this.url });
18
- }
19
- });
20
- }
21
- ngOnDestroy() {
22
- this.chart?.destroy();
23
- }
24
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: XYChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
25
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: XYChartComponent, selector: "vjs-xy-chart", inputs: { data: "data", url: "url", options: "options" }, ngImport: i0, template: `<div></div>`, isInline: true }); }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: XYChartComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
11
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: XYChartComponent, selector: "vjs-xy-chart", inputs: { data: "data", url: "url", options: "options", useModel: "useModel" }, usesInheritance: true, ngImport: i0, template: `<div></div>`, isInline: true }); }
26
12
  }
27
13
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: XYChartComponent, decorators: [{
28
14
  type: Component,
@@ -36,4 +22,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
36
22
  type: Input
37
23
  }], options: [{
38
24
  type: Input
25
+ }], useModel: [{
26
+ type: Input
39
27
  }] } });
@@ -1,4 +1,4 @@
1
- import { Component, ElementRef, Input, Output, EventEmitter, signal, ChangeDetectorRef, inject } from "@angular/core";
1
+ import { Component, ElementRef, Input, Output, EventEmitter, signal, ChangeDetectorRef, inject, effect } from "@angular/core";
2
2
  import { CLASS_COLOR_PICKER, CLASS_COLOR_PICKER_SWATCH, CLASS_COLOR_PICKER_SWATCHES, EVENT_CONTEXT_UPDATE, INSPECTOR_CONTEXT_RECENT_COLORS } from "@visuallyjs/browser-ui";
3
3
  import { VisuallyJsService } from "./vjs-service";
4
4
  import * as i0 from "@angular/core";
@@ -14,9 +14,39 @@ export class ColorPickerComponent {
14
14
  this.$vjs = inject(VisuallyJsService);
15
15
  this.$el = inject(ElementRef);
16
16
  this.$cdr = inject(ChangeDetectorRef);
17
+ this.initialized = false;
18
+ effect(() => {
19
+ const i = this.$vjs.inspector();
20
+ if (!this.initialized) {
21
+ this.initialized = true;
22
+ this.swatches.set(i.ensureContext(INSPECTOR_CONTEXT_RECENT_COLORS, () => []));
23
+ i.bind(EVENT_CONTEXT_UPDATE, (p) => {
24
+ if (p.key === INSPECTOR_CONTEXT_RECENT_COLORS) {
25
+ this.swatches.set(p.value);
26
+ this.$cdr.detectChanges();
27
+ }
28
+ });
29
+ const colorInput = this.$el.nativeElement.querySelector("[type='color']");
30
+ colorInput.onchange = () => {
31
+ const color = colorInput.value;
32
+ this.pushColor(color);
33
+ i.setValue(this.propertyName, color, true);
34
+ };
35
+ setTimeout(() => {
36
+ // if there is a color, maybe push to context
37
+ const v = i.getValue(this.propertyName);
38
+ if (v != null) {
39
+ this.pushColor(v);
40
+ }
41
+ });
42
+ }
43
+ });
17
44
  }
18
45
  $getInspector(cb) {
19
- this.$vjs.getInspector(cb);
46
+ const i = this.$vjs.inspector();
47
+ if (i != null) {
48
+ cb(i);
49
+ }
20
50
  }
21
51
  selectColor(color) {
22
52
  this.$getInspector(inspector => {
@@ -39,30 +69,6 @@ export class ColorPickerComponent {
39
69
  }
40
70
  });
41
71
  }
42
- ngAfterViewInit() {
43
- this.$getInspector(inspector => {
44
- this.swatches.set(inspector.ensureContext(INSPECTOR_CONTEXT_RECENT_COLORS, () => []));
45
- inspector.bind(EVENT_CONTEXT_UPDATE, (p) => {
46
- if (p.key === INSPECTOR_CONTEXT_RECENT_COLORS) {
47
- this.swatches.set(p.value);
48
- this.$cdr.detectChanges();
49
- }
50
- });
51
- const colorInput = this.$el.nativeElement.querySelector("[type='color']");
52
- colorInput.onchange = () => {
53
- const color = colorInput.value;
54
- this.pushColor(color);
55
- inspector.setValue(this.propertyName, color, true);
56
- };
57
- setTimeout(() => {
58
- // if there is a color, maybe push to context
59
- const v = inspector.getValue(this.propertyName);
60
- if (v != null) {
61
- this.pushColor(v);
62
- }
63
- });
64
- });
65
- }
66
72
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
67
73
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColorPickerComponent, selector: "vjs-color", inputs: { propertyName: "propertyName", maxColors: "maxColors" }, outputs: { changeEvent: "changeEvent" }, ngImport: i0, template: "<div class=\"vjs-color-picker\">\n <input type=\"color\" [attr.vjs-att]=\"propertyName\"/>\n <div class=\"vjs-color-picker-swatches\">\n <div *ngFor=\"let swatch of swatches()\" class=\"vjs-color-picker-swatch\" attr.data-color=\"{{swatch}}\" style=\"background-color:{{swatch}}\" (click)=\"selectColor(swatch)\"></div>\n </div>\n </div>", isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); }
68
74
  }
@@ -77,7 +83,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
77
83
  </div>
78
84
  </div>`
79
85
  }]
80
- }], propDecorators: { propertyName: [{
86
+ }], ctorParameters: function () { return []; }, propDecorators: { propertyName: [{
81
87
  type: Input
82
88
  }], maxColors: [{
83
89
  type: Input