@hpcc-js/chart 3.7.2 → 3.7.4

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 +6 -6
  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/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,144 +1,144 @@
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.ts";
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
- HexBin.prototype._class += " chart_HexBin";
123
- HexBin.prototype.implements(I2DAggrChart.prototype);
124
- HexBin.prototype.implements(ITooltip.prototype);
125
-
126
- export interface HexBin {
127
- // ITooltip
128
- tooltip;
129
- tooltipHTML(_): string;
130
- tooltipFormat(_): string;
131
- tooltipValueFormat(_): string;
132
- tooltipValueFormat_default(_): string;
133
-
134
- paletteID(): string;
135
- paletteID(_: string): this;
136
- useClonedPalette(): boolean;
137
- useClonedPalette(_: boolean): this;
138
- binSize(): number;
139
- binSize(_: number): this;
140
- }
141
-
142
- HexBin.prototype.publish("paletteID", "Blues", "set", "Color palette for this widget", HexBin.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
143
- HexBin.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
144
- 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.ts";
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
+ HexBin.prototype._class += " chart_HexBin";
123
+ HexBin.prototype.implements(I2DAggrChart.prototype);
124
+ HexBin.prototype.implements(ITooltip.prototype);
125
+
126
+ export interface HexBin {
127
+ // ITooltip
128
+ tooltip;
129
+ tooltipHTML(_): string;
130
+ tooltipFormat(_): string;
131
+ tooltipValueFormat(_): string;
132
+ tooltipValueFormat_default(_): string;
133
+
134
+ paletteID(): string;
135
+ paletteID(_: string): this;
136
+ useClonedPalette(): boolean;
137
+ useClonedPalette(_: boolean): this;
138
+ binSize(): number;
139
+ binSize(_: number): this;
140
+ }
141
+
142
+ HexBin.prototype.publish("paletteID", "Blues", "set", "Color palette for this widget", HexBin.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
143
+ HexBin.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
144
+ HexBin.prototype.publish("binSize", 20, "number", "Bin radius", null, { range: { min: 1, max: 300, step: 1 } });
package/src/Line.css CHANGED
@@ -1,5 +1,5 @@
1
- .chart_Line .dataLine {
2
- fill: none;
3
- stroke: steelblue;
4
- stroke-width: 1.5px;
1
+ .chart_Line .dataLine {
2
+ fill: none;
3
+ stroke: steelblue;
4
+ stroke-width: 1.5px;
5
5
  }