@hpcc-js/chart 2.86.2 → 2.86.3

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 (78) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +93 -93
  3. package/dist/index.es6.js.map +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/package.json +6 -6
  7. package/src/Area.md +176 -176
  8. package/src/Area.ts +12 -12
  9. package/src/Axis.css +34 -34
  10. package/src/Axis.ts +733 -733
  11. package/src/Bar.md +90 -90
  12. package/src/Bar.ts +9 -9
  13. package/src/Bubble.css +16 -16
  14. package/src/Bubble.md +69 -69
  15. package/src/Bubble.ts +191 -191
  16. package/src/BubbleXY.ts +14 -14
  17. package/src/Bullet.css +60 -60
  18. package/src/Bullet.md +104 -104
  19. package/src/Bullet.ts +167 -167
  20. package/src/Column.css +17 -17
  21. package/src/Column.md +90 -90
  22. package/src/Column.ts +659 -659
  23. package/src/Contour.md +88 -88
  24. package/src/Contour.ts +97 -97
  25. package/src/D3Cloud.ts +400 -400
  26. package/src/Gantt.md +119 -119
  27. package/src/Gantt.ts +14 -14
  28. package/src/Gauge.md +148 -148
  29. package/src/Gauge.ts +358 -358
  30. package/src/HalfPie.md +62 -62
  31. package/src/HalfPie.ts +26 -26
  32. package/src/Heat.md +42 -42
  33. package/src/Heat.ts +283 -283
  34. package/src/HexBin.css +9 -9
  35. package/src/HexBin.md +88 -88
  36. package/src/HexBin.ts +139 -139
  37. package/src/Line.css +6 -6
  38. package/src/Line.md +170 -170
  39. package/src/Line.ts +14 -14
  40. package/src/Pie.css +23 -23
  41. package/src/Pie.md +88 -88
  42. package/src/Pie.ts +503 -503
  43. package/src/QuarterPie.md +61 -61
  44. package/src/QuarterPie.ts +35 -35
  45. package/src/QuartileCandlestick.md +129 -129
  46. package/src/QuartileCandlestick.ts +349 -349
  47. package/src/Radar.css +15 -15
  48. package/src/Radar.md +104 -104
  49. package/src/Radar.ts +336 -336
  50. package/src/RadialBar.css +25 -25
  51. package/src/RadialBar.md +91 -91
  52. package/src/RadialBar.ts +212 -212
  53. package/src/Scatter.css +16 -16
  54. package/src/Scatter.md +163 -163
  55. package/src/Scatter.ts +376 -376
  56. package/src/StatChart.md +117 -117
  57. package/src/StatChart.ts +253 -253
  58. package/src/Step.md +163 -163
  59. package/src/Step.ts +12 -12
  60. package/src/Summary.css +56 -56
  61. package/src/Summary.md +219 -219
  62. package/src/Summary.ts +322 -322
  63. package/src/SummaryC.md +154 -154
  64. package/src/SummaryC.ts +240 -240
  65. package/src/WordCloud.css +3 -3
  66. package/src/WordCloud.md +144 -144
  67. package/src/WordCloud.ts +263 -263
  68. package/src/XYAxis.css +41 -41
  69. package/src/XYAxis.md +149 -149
  70. package/src/XYAxis.ts +803 -803
  71. package/src/__package__.ts +3 -3
  72. package/src/__tests__/heat.ts +71 -71
  73. package/src/__tests__/index.ts +3 -3
  74. package/src/__tests__/pie.ts +20 -20
  75. package/src/__tests__/stat.ts +16 -16
  76. package/src/__tests__/test3.ts +69 -69
  77. package/src/index.ts +27 -27
  78. package/src/test.ts +71 -71
package/src/HexBin.md CHANGED
@@ -1,88 +1,88 @@
1
- # HexBin
2
-
3
- <!--meta
4
-
5
- -->
6
-
7
- HexBin and [Contour](./Contour.md) serve a similar purpose. They summarize high density data across two continuous axes.
8
-
9
-
10
- <ClientOnly>
11
- <hpcc-vitepress style="width:100%;height:600px">
12
- <div id="placeholder" style="height:400px">
13
- </div>
14
- <script type="module">
15
- import { HexBin } from "@hpcc-js/chart";
16
-
17
- new HexBin()
18
- .target("placeholder")
19
- .columns(["X-Value", "Y-Value"])
20
- .data(randomData(1000))
21
- .xAxisType("linear")
22
- .render()
23
- ;
24
-
25
- function randomData(count){
26
- return Array(count).fill(1).map((n,x)=>{
27
- const y = Math.sqrt(x) * Math.random();
28
- return [x,y];
29
- });
30
- }
31
- </script>
32
- </hpcc-vitepress>
33
- </ClientOnly>
34
-
35
-
36
- _binSize_ can be used to set the size of the hexagon bins. The results can be seen in the below example.
37
-
38
-
39
- <ClientOnly>
40
- <hpcc-vitepress style="width:100%;height:600px">
41
- <div id="placeholder" style="height:400px">
42
- </div>
43
- <script type="module">
44
- import { HexBin } from "@hpcc-js/chart";
45
-
46
- let binSize = 5;
47
-
48
- const widget = new HexBin()
49
- .target("placeholder")
50
- .columns(["X-Value", "Y-Value"])
51
- .data(randomData(1000))
52
- .xAxisType("linear")
53
- .xAxisTickCount(10)
54
- .binSize(binSize)
55
- .render()
56
- ;
57
-
58
- function randomData(count){
59
- return Array(count).fill(1).map((n,x)=>{
60
- const y = Math.sqrt(x) * Math.random();
61
- return [x,y];
62
- });
63
- }
64
- let interval = 5;
65
- setInterval(function(){
66
- const next = binSize + interval;
67
- if(next > 20 || next <= 0){
68
- interval *= -1;
69
- }
70
- binSize += interval;
71
- widget
72
- .xAxisTitle("binSize = " + binSize)
73
- .binSize(binSize)
74
- .render()
75
- ;
76
- },1000);
77
- </script>
78
- </hpcc-vitepress>
79
- </ClientOnly>
80
-
81
-
82
- For documentation on axis-specific properties take a look at the [Axis Documentation](./XYAxis.md).
83
-
84
- ## API
85
-
86
- ## Published Properties
87
- ```@hpcc-js/chart:HexBin
88
- ```
1
+ # HexBin
2
+
3
+ <!--meta
4
+
5
+ -->
6
+
7
+ HexBin and [Contour](./Contour.md) serve a similar purpose. They summarize high density data across two continuous axes.
8
+
9
+
10
+ <ClientOnly>
11
+ <hpcc-vitepress style="width:100%;height:600px">
12
+ <div id="placeholder" style="height:400px">
13
+ </div>
14
+ <script type="module">
15
+ import { HexBin } from "@hpcc-js/chart";
16
+
17
+ new HexBin()
18
+ .target("placeholder")
19
+ .columns(["X-Value", "Y-Value"])
20
+ .data(randomData(1000))
21
+ .xAxisType("linear")
22
+ .render()
23
+ ;
24
+
25
+ function randomData(count){
26
+ return Array(count).fill(1).map((n,x)=>{
27
+ const y = Math.sqrt(x) * Math.random();
28
+ return [x,y];
29
+ });
30
+ }
31
+ </script>
32
+ </hpcc-vitepress>
33
+ </ClientOnly>
34
+
35
+
36
+ _binSize_ can be used to set the size of the hexagon bins. The results can be seen in the below example.
37
+
38
+
39
+ <ClientOnly>
40
+ <hpcc-vitepress style="width:100%;height:600px">
41
+ <div id="placeholder" style="height:400px">
42
+ </div>
43
+ <script type="module">
44
+ import { HexBin } from "@hpcc-js/chart";
45
+
46
+ let binSize = 5;
47
+
48
+ const widget = new HexBin()
49
+ .target("placeholder")
50
+ .columns(["X-Value", "Y-Value"])
51
+ .data(randomData(1000))
52
+ .xAxisType("linear")
53
+ .xAxisTickCount(10)
54
+ .binSize(binSize)
55
+ .render()
56
+ ;
57
+
58
+ function randomData(count){
59
+ return Array(count).fill(1).map((n,x)=>{
60
+ const y = Math.sqrt(x) * Math.random();
61
+ return [x,y];
62
+ });
63
+ }
64
+ let interval = 5;
65
+ setInterval(function(){
66
+ const next = binSize + interval;
67
+ if(next > 20 || next <= 0){
68
+ interval *= -1;
69
+ }
70
+ binSize += interval;
71
+ widget
72
+ .xAxisTitle("binSize = " + binSize)
73
+ .binSize(binSize)
74
+ .render()
75
+ ;
76
+ },1000);
77
+ </script>
78
+ </hpcc-vitepress>
79
+ </ClientOnly>
80
+
81
+
82
+ For documentation on axis-specific properties take a look at the [Axis Documentation](./XYAxis.md).
83
+
84
+ ## API
85
+
86
+ ## Published Properties
87
+ ```@hpcc-js/chart:HexBin
88
+ ```
package/src/HexBin.ts CHANGED
@@ -1,139 +1,139 @@
1
- import { I2DAggrChart, ITooltip } from "@hpcc-js/api";
2
- import { InputField } from "@hpcc-js/common";
3
- import { extent as d3Extent, max as d3Max, min as d3Min } from "d3-array";
4
- import { hexbin as d3HexBin } from "d3-hexbin";
5
- import { XYAxis } from "./XYAxis";
6
-
7
- import "../src/HexBin.css";
8
-
9
- export class HexBin extends XYAxis {
10
- static __inputs: InputField[] = [{
11
- id: "x",
12
- type: "any"
13
- }, {
14
- id: "y",
15
- type: "number"
16
- }];
17
-
18
- protected _hexbin;
19
- protected _dataMinWeight;
20
- protected _dataMaxWeight;
21
- constructor() {
22
- super();
23
- I2DAggrChart.call(this);
24
- this.tooltipValueFormat_default(",.0f");
25
- ITooltip.call(this);
26
- this.tooltipHTML(d => {
27
- const seriesExtent = d3Extent<{ label: any, value: any }>(d, d => d.label);
28
- const labelExtent = d3Extent<{ label: any, value: any }>(d, d => d.value);
29
- return this.tooltipFormat({
30
- series: seriesExtent[0] === seriesExtent[1] ? seriesExtent[0] : `${seriesExtent[0]} -> ${seriesExtent[1]}`,
31
- label: labelExtent[0] === labelExtent[1] ? labelExtent[0] : `${labelExtent[0]} -> ${labelExtent[1]}`,
32
- value: d.length
33
- });
34
- });
35
- this._hexbin = d3HexBin()
36
- .x(d => d.x)
37
- .y(d => d.y)
38
- ;
39
- this
40
- .xAxisGuideLines_default(false)
41
- .yAxisGuideLines_default(false)
42
- .xAxisType_default("linear")
43
- ;
44
- }
45
-
46
- xPos(host: XYAxis, d) {
47
- return host.orientation() === "horizontal" ? host.dataPos(d.label) : host.valuePos(d.value);
48
- }
49
-
50
- yPos(host: XYAxis, d) {
51
- return host.orientation() === "horizontal" ? host.valuePos(d.value) : host.dataPos(d.label);
52
- }
53
-
54
- layerUpdate(host: XYAxis, element, duration: number = 250) {
55
- super.layerUpdate(host, element, duration);
56
- const context = this;
57
-
58
- this._palette = this._palette.switch(this.paletteID());
59
- if (this.useClonedPalette()) {
60
- this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
61
- }
62
-
63
- this._hexbin
64
- .extent([0, 0], [this.width(), this.height()])
65
- .radius(this.binSize())
66
- ;
67
-
68
- const flatData = this.flattenData();
69
- const dataPoints = flatData.map(d => {
70
- return {
71
- x: context.xPos(host, d),
72
- y: context.yPos(host, d),
73
- label: host.parseData(d.label),
74
- value: host.parseValue(d.value),
75
- origRow: d
76
- };
77
- });
78
- const hexBinPoints = this._hexbin(dataPoints);
79
- const minBinPoints = d3Min(hexBinPoints, function (d: any) { return d.length; });
80
- const maxBinPoints = d3Max(hexBinPoints, function (d: any) { return d.length; });
81
- this._dataMinWeight = minBinPoints;
82
- this._dataMaxWeight = maxBinPoints;
83
-
84
- const points = element.selectAll(".hexagon").data(hexBinPoints, function (d) { return d.i + "_" + d.j; });
85
- points.enter().append("path")
86
- .attr("class", "hexagon")
87
- .call(host._selection.enter.bind(host._selection))
88
- .on("click", function (d: any) {
89
- const data = context.data();
90
- context.click(d.map(row => host.rowToObj(data[row.origRow.rowIdx])), context.columns()[1], host._selection.selected(this));
91
- })
92
- .on("dblclick", function (d: any) {
93
- const data = context.data();
94
- context.dblclick(d.map(row => host.rowToObj(data[row.origRow.rowIdx])), context.columns()[1], host._selection.selected(this));
95
- })
96
- .on("mouseout.tooltip", context.tooltip.hide)
97
- .on("mousemove.tooltip", context.tooltip.show)
98
- .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")scale(0)"; })
99
- .merge(points).transition().duration(duration)
100
- .attr("d", this._hexbin.hexagon())
101
- .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")scale(1)"; })
102
- .style("fill", function (d) { return context._palette(d.length, minBinPoints, maxBinPoints); })
103
- ;
104
- points.exit().transition().duration(duration)
105
- .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")scale(0)"; })
106
- .remove()
107
- ;
108
- }
109
-
110
- exit(domNode, element) {
111
- super.exit(domNode, element);
112
- }
113
-
114
- // Events ---
115
- click(row: object[], column, selected) {
116
- // console.log("Click: " + JSON.stringify(row) + ", " + column + ", " + selected);
117
- }
118
- dblclick(row: object[], column, selected) {
119
- // console.log("Click: " + JSON.stringify(row) + ", " + column + ", " + selected);
120
- }
121
-
122
- // ITooltip
123
- tooltip;
124
- tooltipHTML: (_) => string;
125
- tooltipFormat: (_) => string;
126
- tooltipValueFormat: (_) => string;
127
- tooltipValueFormat_default: (_) => string;
128
-
129
- paletteID: { (): string; (_: string): HexBin; };
130
- useClonedPalette: { (): boolean; (_: boolean): HexBin; };
131
- binSize: { (): number; (_: number): HexBin; };
132
- }
133
- HexBin.prototype._class += " chart_HexBin";
134
- HexBin.prototype.implements(I2DAggrChart.prototype);
135
- HexBin.prototype.implements(ITooltip.prototype);
136
-
137
- HexBin.prototype.publish("paletteID", "Blues", "set", "Color palette for this widget", HexBin.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
138
- HexBin.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
139
- HexBin.prototype.publish("binSize", 20, "number", "Bin radius", null, { range: { min: 1, max: 300, step: 1 } });
1
+ import { I2DAggrChart, ITooltip } from "@hpcc-js/api";
2
+ import { InputField } from "@hpcc-js/common";
3
+ import { extent as d3Extent, max as d3Max, min as d3Min } from "d3-array";
4
+ import { hexbin as d3HexBin } from "d3-hexbin";
5
+ import { XYAxis } from "./XYAxis";
6
+
7
+ import "../src/HexBin.css";
8
+
9
+ export class HexBin extends XYAxis {
10
+ static __inputs: InputField[] = [{
11
+ id: "x",
12
+ type: "any"
13
+ }, {
14
+ id: "y",
15
+ type: "number"
16
+ }];
17
+
18
+ protected _hexbin;
19
+ protected _dataMinWeight;
20
+ protected _dataMaxWeight;
21
+ constructor() {
22
+ super();
23
+ I2DAggrChart.call(this);
24
+ this.tooltipValueFormat_default(",.0f");
25
+ ITooltip.call(this);
26
+ this.tooltipHTML(d => {
27
+ const seriesExtent = d3Extent<{ label: any, value: any }>(d, d => d.label);
28
+ const labelExtent = d3Extent<{ label: any, value: any }>(d, d => d.value);
29
+ return this.tooltipFormat({
30
+ series: seriesExtent[0] === seriesExtent[1] ? seriesExtent[0] : `${seriesExtent[0]} -> ${seriesExtent[1]}`,
31
+ label: labelExtent[0] === labelExtent[1] ? labelExtent[0] : `${labelExtent[0]} -> ${labelExtent[1]}`,
32
+ value: d.length
33
+ });
34
+ });
35
+ this._hexbin = d3HexBin()
36
+ .x(d => d.x)
37
+ .y(d => d.y)
38
+ ;
39
+ this
40
+ .xAxisGuideLines_default(false)
41
+ .yAxisGuideLines_default(false)
42
+ .xAxisType_default("linear")
43
+ ;
44
+ }
45
+
46
+ xPos(host: XYAxis, d) {
47
+ return host.orientation() === "horizontal" ? host.dataPos(d.label) : host.valuePos(d.value);
48
+ }
49
+
50
+ yPos(host: XYAxis, d) {
51
+ return host.orientation() === "horizontal" ? host.valuePos(d.value) : host.dataPos(d.label);
52
+ }
53
+
54
+ layerUpdate(host: XYAxis, element, duration: number = 250) {
55
+ super.layerUpdate(host, element, duration);
56
+ const context = this;
57
+
58
+ this._palette = this._palette.switch(this.paletteID());
59
+ if (this.useClonedPalette()) {
60
+ this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
61
+ }
62
+
63
+ this._hexbin
64
+ .extent([0, 0], [this.width(), this.height()])
65
+ .radius(this.binSize())
66
+ ;
67
+
68
+ const flatData = this.flattenData();
69
+ const dataPoints = flatData.map(d => {
70
+ return {
71
+ x: context.xPos(host, d),
72
+ y: context.yPos(host, d),
73
+ label: host.parseData(d.label),
74
+ value: host.parseValue(d.value),
75
+ origRow: d
76
+ };
77
+ });
78
+ const hexBinPoints = this._hexbin(dataPoints);
79
+ const minBinPoints = d3Min(hexBinPoints, function (d: any) { return d.length; });
80
+ const maxBinPoints = d3Max(hexBinPoints, function (d: any) { return d.length; });
81
+ this._dataMinWeight = minBinPoints;
82
+ this._dataMaxWeight = maxBinPoints;
83
+
84
+ const points = element.selectAll(".hexagon").data(hexBinPoints, function (d) { return d.i + "_" + d.j; });
85
+ points.enter().append("path")
86
+ .attr("class", "hexagon")
87
+ .call(host._selection.enter.bind(host._selection))
88
+ .on("click", function (d: any) {
89
+ const data = context.data();
90
+ context.click(d.map(row => host.rowToObj(data[row.origRow.rowIdx])), context.columns()[1], host._selection.selected(this));
91
+ })
92
+ .on("dblclick", function (d: any) {
93
+ const data = context.data();
94
+ context.dblclick(d.map(row => host.rowToObj(data[row.origRow.rowIdx])), context.columns()[1], host._selection.selected(this));
95
+ })
96
+ .on("mouseout.tooltip", context.tooltip.hide)
97
+ .on("mousemove.tooltip", context.tooltip.show)
98
+ .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")scale(0)"; })
99
+ .merge(points).transition().duration(duration)
100
+ .attr("d", this._hexbin.hexagon())
101
+ .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")scale(1)"; })
102
+ .style("fill", function (d) { return context._palette(d.length, minBinPoints, maxBinPoints); })
103
+ ;
104
+ points.exit().transition().duration(duration)
105
+ .attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")scale(0)"; })
106
+ .remove()
107
+ ;
108
+ }
109
+
110
+ exit(domNode, element) {
111
+ super.exit(domNode, element);
112
+ }
113
+
114
+ // Events ---
115
+ click(row: object[], column, selected) {
116
+ // console.log("Click: " + JSON.stringify(row) + ", " + column + ", " + selected);
117
+ }
118
+ dblclick(row: object[], column, selected) {
119
+ // console.log("Click: " + JSON.stringify(row) + ", " + column + ", " + selected);
120
+ }
121
+
122
+ // ITooltip
123
+ tooltip;
124
+ tooltipHTML: (_) => string;
125
+ tooltipFormat: (_) => string;
126
+ tooltipValueFormat: (_) => string;
127
+ tooltipValueFormat_default: (_) => string;
128
+
129
+ paletteID: { (): string; (_: string): HexBin; };
130
+ useClonedPalette: { (): boolean; (_: boolean): HexBin; };
131
+ binSize: { (): number; (_: number): HexBin; };
132
+ }
133
+ HexBin.prototype._class += " chart_HexBin";
134
+ HexBin.prototype.implements(I2DAggrChart.prototype);
135
+ HexBin.prototype.implements(ITooltip.prototype);
136
+
137
+ HexBin.prototype.publish("paletteID", "Blues", "set", "Color palette for this widget", HexBin.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
138
+ HexBin.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
139
+ HexBin.prototype.publish("binSize", 20, "number", "Bin radius", null, { range: { min: 1, max: 300, step: 1 } });
package/src/Line.css CHANGED
@@ -1,6 +1,6 @@
1
- .chart_Line .dataLine {
2
- fill: none;
3
- stroke: steelblue;
4
- stroke-width: 1.5px;
5
- }
6
-
1
+ .chart_Line .dataLine {
2
+ fill: none;
3
+ stroke: steelblue;
4
+ stroke-width: 1.5px;
5
+ }
6
+