@hpcc-js/chart 3.7.4 → 3.7.6

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 (80) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +93 -93
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +1 -1
  6. package/dist/index.umd.cjs.map +1 -1
  7. package/package.json +9 -7
  8. package/src/Area.md +176 -176
  9. package/src/Area.ts +12 -12
  10. package/src/Axis.css +35 -35
  11. package/src/Axis.ts +781 -781
  12. package/src/Bar.md +90 -90
  13. package/src/Bar.ts +9 -9
  14. package/src/Bubble.css +16 -16
  15. package/src/Bubble.md +69 -69
  16. package/src/Bubble.ts +196 -196
  17. package/src/BubbleXY.ts +14 -14
  18. package/src/Bullet.css +59 -59
  19. package/src/Bullet.md +104 -104
  20. package/src/Bullet.ts +176 -176
  21. package/src/Column.css +44 -44
  22. package/src/Column.md +90 -90
  23. package/src/Column.ts +684 -684
  24. package/src/Contour.md +88 -88
  25. package/src/Contour.ts +97 -97
  26. package/src/D3Cloud.ts +403 -403
  27. package/src/Gantt.md +119 -119
  28. package/src/Gantt.ts +14 -14
  29. package/src/Gauge.md +148 -148
  30. package/src/Gauge.ts +368 -368
  31. package/src/HalfPie.md +62 -62
  32. package/src/HalfPie.ts +26 -26
  33. package/src/Heat.md +42 -42
  34. package/src/Heat.ts +283 -283
  35. package/src/HexBin.css +8 -8
  36. package/src/HexBin.md +88 -88
  37. package/src/HexBin.ts +144 -144
  38. package/src/Line.css +4 -4
  39. package/src/Line.md +170 -170
  40. package/src/Line.ts +14 -14
  41. package/src/Pie.css +50 -50
  42. package/src/Pie.md +88 -88
  43. package/src/Pie.ts +546 -546
  44. package/src/QuarterPie.md +61 -61
  45. package/src/QuarterPie.ts +35 -35
  46. package/src/QuartileCandlestick.md +129 -129
  47. package/src/QuartileCandlestick.ts +349 -349
  48. package/src/Radar.css +14 -14
  49. package/src/Radar.md +104 -104
  50. package/src/Radar.ts +336 -336
  51. package/src/RadialBar.css +25 -25
  52. package/src/RadialBar.md +91 -91
  53. package/src/RadialBar.ts +217 -217
  54. package/src/Scatter.css +42 -42
  55. package/src/Scatter.md +163 -163
  56. package/src/Scatter.ts +412 -412
  57. package/src/StatChart.md +117 -117
  58. package/src/StatChart.ts +261 -261
  59. package/src/Step.md +163 -163
  60. package/src/Step.ts +12 -12
  61. package/src/Summary.css +55 -55
  62. package/src/Summary.md +219 -219
  63. package/src/Summary.ts +322 -322
  64. package/src/SummaryC.md +154 -154
  65. package/src/SummaryC.ts +240 -240
  66. package/src/WordCloud.css +2 -2
  67. package/src/WordCloud.md +144 -144
  68. package/src/WordCloud.ts +268 -268
  69. package/src/XYAxis.css +40 -40
  70. package/src/XYAxis.md +149 -149
  71. package/src/XYAxis.ts +809 -809
  72. package/src/__package__.ts +3 -3
  73. package/src/__tests__/heat.ts +71 -71
  74. package/src/__tests__/index.ts +3 -3
  75. package/src/__tests__/pie.ts +20 -20
  76. package/src/__tests__/stat.ts +16 -16
  77. package/src/__tests__/test3.ts +68 -68
  78. package/src/index.ts +28 -28
  79. package/src/test.ts +70 -70
  80. package/src/timeFormats.ts +26 -26
package/src/Bubble.ts CHANGED
@@ -1,196 +1,196 @@
1
- import { I2DChart, ITooltip } from "@hpcc-js/api";
2
- import { FAChar, InputField, ISize, SVGWidget, Text, Utility } from "@hpcc-js/common";
3
- import { hierarchy as d3Hierarchy, pack as d3Pack } from "d3-hierarchy";
4
- import { select as d3Select } from "d3-selection";
5
-
6
- import "../src/Bubble.css";
7
-
8
- export class Bubble extends SVGWidget {
9
- static __inputs: InputField[] = [{
10
- id: "label",
11
- type: "string"
12
- }, {
13
- id: "value",
14
- type: "number"
15
- }];
16
-
17
- labelWidgets;
18
- d3Pack;
19
-
20
- constructor() {
21
- super();
22
- I2DChart.call(this);
23
- ITooltip.call(this);
24
- Utility.SimpleSelectionMixin.call(this);
25
-
26
- this._drawStartPos = "origin";
27
-
28
- this.labelWidgets = {};
29
-
30
- this.d3Pack = d3Pack()
31
- .size([this.width(), this.height()])
32
- .padding(1.5)
33
- ;
34
- }
35
-
36
- size(): ISize;
37
- size(_): this;
38
- size(_?): ISize | this {
39
- const retVal = super.size.apply(this, arguments);
40
- if (arguments.length) {
41
- this.d3Pack
42
- .size([this.width(), this.height()])
43
- ;
44
- }
45
- return retVal;
46
- }
47
-
48
- enter(domNode, element) {
49
- super.enter(domNode, element);
50
- this._selection.widgetElement(element);
51
- const context = this;
52
- this
53
- .tooltipHTML(function (d) {
54
- switch (context.tooltipStyle()) {
55
- case "series-table":
56
- return context.tooltipFormat({
57
- label: d[0],
58
- arr: context.columns().slice(1).map(function (column, i) {
59
- return {
60
- label: column,
61
- color: context._palette(d[0]),
62
- value: d[1]
63
- };
64
- })
65
- });
66
- default:
67
- return context.tooltipFormat({ label: d.data[0], value: d.data[1] });
68
- }
69
- })
70
- ;
71
- }
72
-
73
- update(domNode, element) {
74
- super.update(domNode, element);
75
- const context = this;
76
-
77
- this._palette = this._palette.switch(this.paletteID());
78
- if (this.useClonedPalette()) {
79
- this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
80
- }
81
-
82
- const root = d3Hierarchy({ children: this.cloneData() })
83
- .sum(function (d) { return d[1]; })
84
- .sort(function (b, a) {
85
- return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0;
86
- })
87
- ;
88
- this.d3Pack(root);
89
-
90
- const node = element.selectAll(".node").data(root.children || [], d => d.data[0]);
91
-
92
- // Enter ---
93
- node.enter().append("g")
94
- .attr("class", (d, i) => "node series series-" + this.cssTag(d.data[0]))
95
- .attr("opacity", 0)
96
- .call(this._selection.enter.bind(this._selection))
97
- .on("click", function (d) {
98
- context.click(context.rowToObj(d.data), context.columns()[1], context._selection.selected(this));
99
- })
100
- .on("dblclick", function (d) {
101
- context.dblclick(context.rowToObj(d.data), context.columns()[1], context._selection.selected(this));
102
- })
103
- .each(function (d) {
104
- const element2 = d3Select(this);
105
- const pos = { x: d.x, y: d.y };
106
- element2.append("circle")
107
- .attr("transform", "translate(" + pos.x + "," + pos.y + ")")
108
- .attr("r", 0)
109
- .on("mouseout.tooltip", context.tooltip.hide)
110
- .on("mousemove.tooltip", context.tooltip.show)
111
- ;
112
- if (d.__viz_faChar) {
113
- context.labelWidgets[d.data[0]] = new FAChar()
114
- .char(d.__viz_faChar)
115
- .target(this)
116
- .render()
117
- ;
118
- } else {
119
- context.labelWidgets[d.data[0]] = new Text()
120
- .text(d.data[0])
121
- .target(this)
122
- .render()
123
- ;
124
- }
125
- })
126
- .merge(node).transition()
127
- .attr("opacity", 1)
128
- .each(function (d) {
129
- const element2 = d3Select(this);
130
- const pos = { x: d.x, y: d.y };
131
- element2.select("circle").transition()
132
- .attr("transform", "translate(" + pos.x + "," + pos.y + ")")
133
- .style("fill", context.fillColor(d.data, context.columns()[1], d.data[1]))
134
- .attr("r", d.r)
135
- .select("title")
136
- .text(d.data[0] + " (" + d.data[1] + ")")
137
- ;
138
- if (d.__viz_faChar) {
139
- context.labelWidgets[d.data[0]]
140
- .pos(pos)
141
- .render()
142
- ;
143
- } else {
144
- context.labelWidgets[d.data[0]]
145
- .pos(pos)
146
- .colorFill_default(context.textColor(d.data, context.columns()[1], d.data[1]))
147
- .width(d.r * 2)
148
- .text(d.data[0])
149
- .render()
150
- ;
151
- }
152
- })
153
- ;
154
-
155
- // Exit ---
156
- node.exit().transition()
157
- .style("opacity", 0)
158
- .remove()
159
- ;
160
- }
161
-
162
- exit(domNode, element) {
163
- super.exit(domNode, element);
164
- }
165
-
166
- }
167
- Bubble.prototype._class += " chart_Bubble";
168
- Bubble.prototype.implements(I2DChart.prototype);
169
- Bubble.prototype.implements(ITooltip.prototype);
170
- Bubble.prototype.mixin(Utility.SimpleSelectionMixin);
171
-
172
- export interface Bubble {
173
- paletteID(): string;
174
- paletteID(_: string): this;
175
- useClonedPalette(): boolean;
176
- useClonedPalette(_: boolean): this;
177
-
178
- // I2DChart
179
- _palette;
180
- fillColor(row: any[], column: string, value: number): string;
181
- textColor(row: any[], column: string, value: number): string;
182
- click(row, column, selected): void;
183
- dblclick(row, column, selected): void;
184
-
185
- // ITooltip
186
- tooltip;
187
- tooltipHTML(_): string;
188
- tooltipFormat(_): string;
189
- tooltipStyle(): "default" | "none" | "series-table";
190
-
191
- // SimpleSelectionMixin
192
- _selection;
193
- }
194
-
195
- Bubble.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Bubble.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
196
- Bubble.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
1
+ import { I2DChart, ITooltip } from "@hpcc-js/api";
2
+ import { FAChar, InputField, ISize, SVGWidget, Text, Utility } from "@hpcc-js/common";
3
+ import { hierarchy as d3Hierarchy, pack as d3Pack } from "d3-hierarchy";
4
+ import { select as d3Select } from "d3-selection";
5
+
6
+ import "../src/Bubble.css";
7
+
8
+ export class Bubble extends SVGWidget {
9
+ static __inputs: InputField[] = [{
10
+ id: "label",
11
+ type: "string"
12
+ }, {
13
+ id: "value",
14
+ type: "number"
15
+ }];
16
+
17
+ labelWidgets;
18
+ d3Pack;
19
+
20
+ constructor() {
21
+ super();
22
+ I2DChart.call(this);
23
+ ITooltip.call(this);
24
+ Utility.SimpleSelectionMixin.call(this);
25
+
26
+ this._drawStartPos = "origin";
27
+
28
+ this.labelWidgets = {};
29
+
30
+ this.d3Pack = d3Pack()
31
+ .size([this.width(), this.height()])
32
+ .padding(1.5)
33
+ ;
34
+ }
35
+
36
+ size(): ISize;
37
+ size(_): this;
38
+ size(_?): ISize | this {
39
+ const retVal = super.size.apply(this, arguments);
40
+ if (arguments.length) {
41
+ this.d3Pack
42
+ .size([this.width(), this.height()])
43
+ ;
44
+ }
45
+ return retVal;
46
+ }
47
+
48
+ enter(domNode, element) {
49
+ super.enter(domNode, element);
50
+ this._selection.widgetElement(element);
51
+ const context = this;
52
+ this
53
+ .tooltipHTML(function (d) {
54
+ switch (context.tooltipStyle()) {
55
+ case "series-table":
56
+ return context.tooltipFormat({
57
+ label: d[0],
58
+ arr: context.columns().slice(1).map(function (column, i) {
59
+ return {
60
+ label: column,
61
+ color: context._palette(d[0]),
62
+ value: d[1]
63
+ };
64
+ })
65
+ });
66
+ default:
67
+ return context.tooltipFormat({ label: d.data[0], value: d.data[1] });
68
+ }
69
+ })
70
+ ;
71
+ }
72
+
73
+ update(domNode, element) {
74
+ super.update(domNode, element);
75
+ const context = this;
76
+
77
+ this._palette = this._palette.switch(this.paletteID());
78
+ if (this.useClonedPalette()) {
79
+ this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
80
+ }
81
+
82
+ const root = d3Hierarchy({ children: this.cloneData() })
83
+ .sum(function (d) { return d[1]; })
84
+ .sort(function (b, a) {
85
+ return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0;
86
+ })
87
+ ;
88
+ this.d3Pack(root);
89
+
90
+ const node = element.selectAll(".node").data(root.children || [], d => d.data[0]);
91
+
92
+ // Enter ---
93
+ node.enter().append("g")
94
+ .attr("class", (d, i) => "node series series-" + this.cssTag(d.data[0]))
95
+ .attr("opacity", 0)
96
+ .call(this._selection.enter.bind(this._selection))
97
+ .on("click", function (d) {
98
+ context.click(context.rowToObj(d.data), context.columns()[1], context._selection.selected(this));
99
+ })
100
+ .on("dblclick", function (d) {
101
+ context.dblclick(context.rowToObj(d.data), context.columns()[1], context._selection.selected(this));
102
+ })
103
+ .each(function (d) {
104
+ const element2 = d3Select(this);
105
+ const pos = { x: d.x, y: d.y };
106
+ element2.append("circle")
107
+ .attr("transform", "translate(" + pos.x + "," + pos.y + ")")
108
+ .attr("r", 0)
109
+ .on("mouseout.tooltip", context.tooltip.hide)
110
+ .on("mousemove.tooltip", context.tooltip.show)
111
+ ;
112
+ if (d.__viz_faChar) {
113
+ context.labelWidgets[d.data[0]] = new FAChar()
114
+ .char(d.__viz_faChar)
115
+ .target(this)
116
+ .render()
117
+ ;
118
+ } else {
119
+ context.labelWidgets[d.data[0]] = new Text()
120
+ .text(d.data[0])
121
+ .target(this)
122
+ .render()
123
+ ;
124
+ }
125
+ })
126
+ .merge(node).transition()
127
+ .attr("opacity", 1)
128
+ .each(function (d) {
129
+ const element2 = d3Select(this);
130
+ const pos = { x: d.x, y: d.y };
131
+ element2.select("circle").transition()
132
+ .attr("transform", "translate(" + pos.x + "," + pos.y + ")")
133
+ .style("fill", context.fillColor(d.data, context.columns()[1], d.data[1]))
134
+ .attr("r", d.r)
135
+ .select("title")
136
+ .text(d.data[0] + " (" + d.data[1] + ")")
137
+ ;
138
+ if (d.__viz_faChar) {
139
+ context.labelWidgets[d.data[0]]
140
+ .pos(pos)
141
+ .render()
142
+ ;
143
+ } else {
144
+ context.labelWidgets[d.data[0]]
145
+ .pos(pos)
146
+ .colorFill_default(context.textColor(d.data, context.columns()[1], d.data[1]))
147
+ .width(d.r * 2)
148
+ .text(d.data[0])
149
+ .render()
150
+ ;
151
+ }
152
+ })
153
+ ;
154
+
155
+ // Exit ---
156
+ node.exit().transition()
157
+ .style("opacity", 0)
158
+ .remove()
159
+ ;
160
+ }
161
+
162
+ exit(domNode, element) {
163
+ super.exit(domNode, element);
164
+ }
165
+
166
+ }
167
+ Bubble.prototype._class += " chart_Bubble";
168
+ Bubble.prototype.implements(I2DChart.prototype);
169
+ Bubble.prototype.implements(ITooltip.prototype);
170
+ Bubble.prototype.mixin(Utility.SimpleSelectionMixin);
171
+
172
+ export interface Bubble {
173
+ paletteID(): string;
174
+ paletteID(_: string): this;
175
+ useClonedPalette(): boolean;
176
+ useClonedPalette(_: boolean): this;
177
+
178
+ // I2DChart
179
+ _palette;
180
+ fillColor(row: any[], column: string, value: number): string;
181
+ textColor(row: any[], column: string, value: number): string;
182
+ click(row, column, selected): void;
183
+ dblclick(row, column, selected): void;
184
+
185
+ // ITooltip
186
+ tooltip;
187
+ tooltipHTML(_): string;
188
+ tooltipFormat(_): string;
189
+ tooltipStyle(): "default" | "none" | "series-table";
190
+
191
+ // SimpleSelectionMixin
192
+ _selection;
193
+ }
194
+
195
+ Bubble.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Bubble.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
196
+ Bubble.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
package/src/BubbleXY.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { Scatter } from "./Scatter.ts";
2
-
3
- export class BubbleXY extends Scatter {
4
- constructor() {
5
- super();
6
- }
7
- enter(domNode, element) {
8
- if (!this.pointSizeColumn_exists()) {
9
- this.pointSizeColumn(this.columns()[this.columns().length - 1]);
10
- }
11
- super.enter(domNode, element);
12
- }
13
- }
14
- BubbleXY.prototype._class += " chart_BubbleXY";
1
+ import { Scatter } from "./Scatter.ts";
2
+
3
+ export class BubbleXY extends Scatter {
4
+ constructor() {
5
+ super();
6
+ }
7
+ enter(domNode, element) {
8
+ if (!this.pointSizeColumn_exists()) {
9
+ this.pointSizeColumn(this.columns()[this.columns().length - 1]);
10
+ }
11
+ super.enter(domNode, element);
12
+ }
13
+ }
14
+ BubbleXY.prototype._class += " chart_BubbleXY";
package/src/Bullet.css CHANGED
@@ -1,60 +1,60 @@
1
- .chart_Bullet .domain {
2
- opacity: 0;
3
- }
4
-
5
- .chart_Bullet .bullet {
6
- border: solid 1px;
7
- border-color: transparent;
8
- font: 10px sans-serif;
9
- }
10
-
11
- .chart_Bullet .bullet.selected {
12
- border-color: red;
13
- }
14
-
15
- .chart_Bullet .bullet.over {
16
- border-color: orange;
17
- }
18
-
19
- .chart_Bullet .bullet.selected.over {
20
- border-color: red;
21
- }
22
-
23
- .chart_Bullet .bullet .marker {
24
- stroke: #000;
25
- stroke-width: 2px;
26
- }
27
-
28
- .chart_Bullet .bullet .tick line {
29
- stroke: #666;
30
- stroke-width: .5px;
31
- }
32
-
33
- .chart_Bullet .bullet .range.s0 {
34
- fill: #eee;
35
- }
36
-
37
- .chart_Bullet .bullet .range.s1 {
38
- fill: #ddd;
39
- }
40
-
41
- .chart_Bullet .bullet .range.s2 {
42
- fill: #ccc;
43
- }
44
-
45
- .chart_Bullet .bullet .measure.s0 {
46
- fill: lightsteelblue;
47
- }
48
-
49
- .chart_Bullet .bullet .measure.s1 {
50
- fill: steelblue;
51
- }
52
-
53
- .chart_Bullet .bullet .title {
54
- font-size: 14px;
55
- font-weight: bold;
56
- }
57
-
58
- .chart_Bullet .bullet .subtitle {
59
- fill: #999;
1
+ .chart_Bullet .domain {
2
+ opacity: 0;
3
+ }
4
+
5
+ .chart_Bullet .bullet {
6
+ border: solid 1px;
7
+ border-color: transparent;
8
+ font: 10px sans-serif;
9
+ }
10
+
11
+ .chart_Bullet .bullet.selected {
12
+ border-color: red;
13
+ }
14
+
15
+ .chart_Bullet .bullet.over {
16
+ border-color: orange;
17
+ }
18
+
19
+ .chart_Bullet .bullet.selected.over {
20
+ border-color: red;
21
+ }
22
+
23
+ .chart_Bullet .bullet .marker {
24
+ stroke: #000;
25
+ stroke-width: 2px;
26
+ }
27
+
28
+ .chart_Bullet .bullet .tick line {
29
+ stroke: #666;
30
+ stroke-width: .5px;
31
+ }
32
+
33
+ .chart_Bullet .bullet .range.s0 {
34
+ fill: #eee;
35
+ }
36
+
37
+ .chart_Bullet .bullet .range.s1 {
38
+ fill: #ddd;
39
+ }
40
+
41
+ .chart_Bullet .bullet .range.s2 {
42
+ fill: #ccc;
43
+ }
44
+
45
+ .chart_Bullet .bullet .measure.s0 {
46
+ fill: lightsteelblue;
47
+ }
48
+
49
+ .chart_Bullet .bullet .measure.s1 {
50
+ fill: steelblue;
51
+ }
52
+
53
+ .chart_Bullet .bullet .title {
54
+ font-size: 14px;
55
+ font-weight: bold;
56
+ }
57
+
58
+ .chart_Bullet .bullet .subtitle {
59
+ fill: #999;
60
60
  }