@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.
- package/LICENSE +43 -43
- package/README.md +93 -93
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +6 -6
- package/src/Area.md +176 -176
- package/src/Area.ts +12 -12
- package/src/Axis.css +35 -35
- package/src/Axis.ts +781 -781
- package/src/Bar.md +90 -90
- package/src/Bar.ts +9 -9
- package/src/Bubble.css +16 -16
- package/src/Bubble.md +69 -69
- package/src/Bubble.ts +196 -196
- package/src/BubbleXY.ts +14 -14
- package/src/Bullet.css +59 -59
- package/src/Bullet.md +104 -104
- package/src/Bullet.ts +176 -176
- package/src/Column.css +44 -44
- package/src/Column.md +90 -90
- package/src/Column.ts +684 -684
- package/src/Contour.md +88 -88
- package/src/Contour.ts +97 -97
- package/src/D3Cloud.ts +403 -403
- package/src/Gantt.md +119 -119
- package/src/Gantt.ts +14 -14
- package/src/Gauge.md +148 -148
- package/src/Gauge.ts +368 -368
- package/src/HalfPie.md +62 -62
- package/src/HalfPie.ts +26 -26
- package/src/Heat.md +42 -42
- package/src/Heat.ts +283 -283
- package/src/HexBin.css +8 -8
- package/src/HexBin.md +88 -88
- package/src/HexBin.ts +144 -144
- package/src/Line.css +4 -4
- package/src/Line.md +170 -170
- package/src/Line.ts +14 -14
- package/src/Pie.css +50 -50
- package/src/Pie.md +88 -88
- package/src/Pie.ts +546 -546
- package/src/QuarterPie.md +61 -61
- package/src/QuarterPie.ts +35 -35
- package/src/QuartileCandlestick.md +129 -129
- package/src/QuartileCandlestick.ts +349 -349
- package/src/Radar.css +14 -14
- package/src/Radar.md +104 -104
- package/src/Radar.ts +336 -336
- package/src/RadialBar.css +25 -25
- package/src/RadialBar.md +91 -91
- package/src/RadialBar.ts +217 -217
- package/src/Scatter.css +42 -42
- package/src/Scatter.md +163 -163
- package/src/Scatter.ts +412 -412
- package/src/StatChart.md +117 -117
- package/src/StatChart.ts +261 -261
- package/src/Step.md +163 -163
- package/src/Step.ts +12 -12
- package/src/Summary.css +55 -55
- package/src/Summary.md +219 -219
- package/src/Summary.ts +322 -322
- package/src/SummaryC.md +154 -154
- package/src/SummaryC.ts +240 -240
- package/src/WordCloud.css +2 -2
- package/src/WordCloud.md +144 -144
- package/src/WordCloud.ts +268 -268
- package/src/XYAxis.css +40 -40
- package/src/XYAxis.md +149 -149
- package/src/XYAxis.ts +809 -809
- package/src/__package__.ts +3 -3
- package/src/__tests__/heat.ts +71 -71
- package/src/__tests__/index.ts +3 -3
- package/src/__tests__/pie.ts +20 -20
- package/src/__tests__/stat.ts +16 -16
- package/src/__tests__/test3.ts +68 -68
- package/src/index.ts +28 -28
- package/src/test.ts +70 -70
- package/src/timeFormats.ts +26 -26
package/src/Contour.md
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
# Contour
|
|
2
|
-
|
|
3
|
-
<!--meta
|
|
4
|
-
|
|
5
|
-
-->
|
|
6
|
-
|
|
7
|
-
Contour and [HexBin](./HexBin.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 { Contour } from "@hpcc-js/chart";
|
|
16
|
-
|
|
17
|
-
new Contour()
|
|
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
|
-
_contourBandwidth_ can be used to control the standard deviation of the contour algorithm. 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 { Contour } from "@hpcc-js/chart";
|
|
45
|
-
|
|
46
|
-
let bandwidth = 10;
|
|
47
|
-
|
|
48
|
-
const widget = new Contour()
|
|
49
|
-
.target("placeholder")
|
|
50
|
-
.columns(["X-Value", "Y-Value"])
|
|
51
|
-
.data(randomData(1000))
|
|
52
|
-
.xAxisType("linear")
|
|
53
|
-
.xAxisTickCount(10)
|
|
54
|
-
.contourBandwidth(bandwidth)
|
|
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 = 10;
|
|
65
|
-
setInterval(function(){
|
|
66
|
-
const next = bandwidth + interval;
|
|
67
|
-
if(next > 100 || next <= 0){
|
|
68
|
-
interval *= -1;
|
|
69
|
-
}
|
|
70
|
-
bandwidth += interval;
|
|
71
|
-
widget
|
|
72
|
-
.xAxisTitle("bandwidth = " + bandwidth)
|
|
73
|
-
.contourBandwidth(bandwidth)
|
|
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:Contour
|
|
88
|
-
```
|
|
1
|
+
# Contour
|
|
2
|
+
|
|
3
|
+
<!--meta
|
|
4
|
+
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
Contour and [HexBin](./HexBin.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 { Contour } from "@hpcc-js/chart";
|
|
16
|
+
|
|
17
|
+
new Contour()
|
|
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
|
+
_contourBandwidth_ can be used to control the standard deviation of the contour algorithm. 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 { Contour } from "@hpcc-js/chart";
|
|
45
|
+
|
|
46
|
+
let bandwidth = 10;
|
|
47
|
+
|
|
48
|
+
const widget = new Contour()
|
|
49
|
+
.target("placeholder")
|
|
50
|
+
.columns(["X-Value", "Y-Value"])
|
|
51
|
+
.data(randomData(1000))
|
|
52
|
+
.xAxisType("linear")
|
|
53
|
+
.xAxisTickCount(10)
|
|
54
|
+
.contourBandwidth(bandwidth)
|
|
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 = 10;
|
|
65
|
+
setInterval(function(){
|
|
66
|
+
const next = bandwidth + interval;
|
|
67
|
+
if(next > 100 || next <= 0){
|
|
68
|
+
interval *= -1;
|
|
69
|
+
}
|
|
70
|
+
bandwidth += interval;
|
|
71
|
+
widget
|
|
72
|
+
.xAxisTitle("bandwidth = " + bandwidth)
|
|
73
|
+
.contourBandwidth(bandwidth)
|
|
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:Contour
|
|
88
|
+
```
|
package/src/Contour.ts
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { I1DChart } from "@hpcc-js/api";
|
|
2
|
-
import { InputField } from "@hpcc-js/common";
|
|
3
|
-
import { contourDensity as d3ContourDensity } from "d3-contour";
|
|
4
|
-
import { geoPath } from "d3-geo";
|
|
5
|
-
import { XYAxis } from "./XYAxis.ts";
|
|
6
|
-
|
|
7
|
-
export class Contour extends XYAxis {
|
|
8
|
-
static __inputs: InputField[] = [{
|
|
9
|
-
id: "x",
|
|
10
|
-
type: "any"
|
|
11
|
-
}, {
|
|
12
|
-
id: "y",
|
|
13
|
-
type: "number"
|
|
14
|
-
}];
|
|
15
|
-
|
|
16
|
-
protected _dataMinWeight;
|
|
17
|
-
protected _dataMaxWeight;
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
this
|
|
21
|
-
.xAxisGuideLines_default(false)
|
|
22
|
-
.yAxisGuideLines_default(false)
|
|
23
|
-
.xAxisType_default("linear")
|
|
24
|
-
;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
xPos(host: XYAxis, d) {
|
|
28
|
-
return host.orientation() === "horizontal" ? host.dataPos(d.label) : host.valuePos(d.value);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
yPos(host: XYAxis, d) {
|
|
32
|
-
return host.orientation() === "horizontal" ? host.valuePos(d.value) : host.dataPos(d.label);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
layerEnter(host: XYAxis, element, duration: number = 250) {
|
|
36
|
-
super.layerEnter(host, element, duration);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
layerUpdate(host: XYAxis, element, duration: number = 250) {
|
|
40
|
-
super.layerUpdate(host, element, duration);
|
|
41
|
-
|
|
42
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
43
|
-
|
|
44
|
-
const data = this.flattenData(this.layerColumns(host), this.layerData(host));
|
|
45
|
-
const contourData = d3ContourDensity()
|
|
46
|
-
.x(d => this.xPos(host, d))
|
|
47
|
-
.y(d => this.yPos(host, d))
|
|
48
|
-
.size([this.width(), this.height()])
|
|
49
|
-
.bandwidth(this.contourBandwidth())(data)
|
|
50
|
-
;
|
|
51
|
-
const _vals = contourData.map(d => d.value);
|
|
52
|
-
const minValue = Math.min.apply(this, _vals);
|
|
53
|
-
const maxValue = Math.max.apply(this, _vals);
|
|
54
|
-
this._dataMinWeight = minValue;
|
|
55
|
-
this._dataMaxWeight = maxValue;
|
|
56
|
-
const lines = element.selectAll("path").data(contourData);
|
|
57
|
-
lines.enter().append("path")
|
|
58
|
-
.merge(lines)
|
|
59
|
-
.attr("d", geoPath())
|
|
60
|
-
.attr("fill", d => this.showContourFill() ? this._palette(d.value, minValue, maxValue) : "none")
|
|
61
|
-
.attr("stroke", this.contourStrokeColor())
|
|
62
|
-
.attr("stroke-linejoin", "round")
|
|
63
|
-
.attr("stroke-width", this.contourStrokeWidth())
|
|
64
|
-
;
|
|
65
|
-
lines.exit().remove();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
exit(_domNode, _element) {
|
|
69
|
-
super.exit(_domNode, _element);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
Contour.prototype._class += " chart_Contour";
|
|
73
|
-
Contour.prototype.implements(I1DChart.prototype);
|
|
74
|
-
|
|
75
|
-
export interface Contour {
|
|
76
|
-
paletteID(): string;
|
|
77
|
-
paletteID(_: string): this;
|
|
78
|
-
useClonedPalette(): boolean;
|
|
79
|
-
useClonedPalette(_: boolean): this;
|
|
80
|
-
showContourFill(): boolean;
|
|
81
|
-
showContourFill(_: boolean): this;
|
|
82
|
-
showContour(): boolean;
|
|
83
|
-
showContour(_: boolean): this;
|
|
84
|
-
contourBandwidth(): number;
|
|
85
|
-
contourBandwidth(_: number): this;
|
|
86
|
-
contourStrokeColor(): string;
|
|
87
|
-
contourStrokeColor(_: string): this;
|
|
88
|
-
contourStrokeWidth(): number;
|
|
89
|
-
contourStrokeWidth(_: number): this;
|
|
90
|
-
}
|
|
91
|
-
Contour.prototype.publish("paletteID", "YlGnBu", "string", "Color palette for this widget");
|
|
92
|
-
Contour.prototype.publish("useClonedPalette", true, "boolean", "Enable or disable using a cloned palette");
|
|
93
|
-
Contour.prototype.publish("showContourFill", true, "boolean", "Show/hide the contour background colors");
|
|
94
|
-
Contour.prototype.publish("showContour", true, "boolean", "Show/hide the contour border lines");
|
|
95
|
-
Contour.prototype.publish("contourBandwidth", 40, "number", "Controls the sensitivity of the contour grouping algorithm");
|
|
96
|
-
Contour.prototype.publish("contourStrokeColor", "#2C3A47", "html-color", "Color of the contour border lines");
|
|
97
|
-
Contour.prototype.publish("contourStrokeWidth", 1, "number", "Width of the contour border lines");
|
|
1
|
+
import { I1DChart } from "@hpcc-js/api";
|
|
2
|
+
import { InputField } from "@hpcc-js/common";
|
|
3
|
+
import { contourDensity as d3ContourDensity } from "d3-contour";
|
|
4
|
+
import { geoPath } from "d3-geo";
|
|
5
|
+
import { XYAxis } from "./XYAxis.ts";
|
|
6
|
+
|
|
7
|
+
export class Contour extends XYAxis {
|
|
8
|
+
static __inputs: InputField[] = [{
|
|
9
|
+
id: "x",
|
|
10
|
+
type: "any"
|
|
11
|
+
}, {
|
|
12
|
+
id: "y",
|
|
13
|
+
type: "number"
|
|
14
|
+
}];
|
|
15
|
+
|
|
16
|
+
protected _dataMinWeight;
|
|
17
|
+
protected _dataMaxWeight;
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this
|
|
21
|
+
.xAxisGuideLines_default(false)
|
|
22
|
+
.yAxisGuideLines_default(false)
|
|
23
|
+
.xAxisType_default("linear")
|
|
24
|
+
;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
xPos(host: XYAxis, d) {
|
|
28
|
+
return host.orientation() === "horizontal" ? host.dataPos(d.label) : host.valuePos(d.value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
yPos(host: XYAxis, d) {
|
|
32
|
+
return host.orientation() === "horizontal" ? host.valuePos(d.value) : host.dataPos(d.label);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
layerEnter(host: XYAxis, element, duration: number = 250) {
|
|
36
|
+
super.layerEnter(host, element, duration);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
layerUpdate(host: XYAxis, element, duration: number = 250) {
|
|
40
|
+
super.layerUpdate(host, element, duration);
|
|
41
|
+
|
|
42
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
43
|
+
|
|
44
|
+
const data = this.flattenData(this.layerColumns(host), this.layerData(host));
|
|
45
|
+
const contourData = d3ContourDensity()
|
|
46
|
+
.x(d => this.xPos(host, d))
|
|
47
|
+
.y(d => this.yPos(host, d))
|
|
48
|
+
.size([this.width(), this.height()])
|
|
49
|
+
.bandwidth(this.contourBandwidth())(data)
|
|
50
|
+
;
|
|
51
|
+
const _vals = contourData.map(d => d.value);
|
|
52
|
+
const minValue = Math.min.apply(this, _vals);
|
|
53
|
+
const maxValue = Math.max.apply(this, _vals);
|
|
54
|
+
this._dataMinWeight = minValue;
|
|
55
|
+
this._dataMaxWeight = maxValue;
|
|
56
|
+
const lines = element.selectAll("path").data(contourData);
|
|
57
|
+
lines.enter().append("path")
|
|
58
|
+
.merge(lines)
|
|
59
|
+
.attr("d", geoPath())
|
|
60
|
+
.attr("fill", d => this.showContourFill() ? this._palette(d.value, minValue, maxValue) : "none")
|
|
61
|
+
.attr("stroke", this.contourStrokeColor())
|
|
62
|
+
.attr("stroke-linejoin", "round")
|
|
63
|
+
.attr("stroke-width", this.contourStrokeWidth())
|
|
64
|
+
;
|
|
65
|
+
lines.exit().remove();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exit(_domNode, _element) {
|
|
69
|
+
super.exit(_domNode, _element);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
Contour.prototype._class += " chart_Contour";
|
|
73
|
+
Contour.prototype.implements(I1DChart.prototype);
|
|
74
|
+
|
|
75
|
+
export interface Contour {
|
|
76
|
+
paletteID(): string;
|
|
77
|
+
paletteID(_: string): this;
|
|
78
|
+
useClonedPalette(): boolean;
|
|
79
|
+
useClonedPalette(_: boolean): this;
|
|
80
|
+
showContourFill(): boolean;
|
|
81
|
+
showContourFill(_: boolean): this;
|
|
82
|
+
showContour(): boolean;
|
|
83
|
+
showContour(_: boolean): this;
|
|
84
|
+
contourBandwidth(): number;
|
|
85
|
+
contourBandwidth(_: number): this;
|
|
86
|
+
contourStrokeColor(): string;
|
|
87
|
+
contourStrokeColor(_: string): this;
|
|
88
|
+
contourStrokeWidth(): number;
|
|
89
|
+
contourStrokeWidth(_: number): this;
|
|
90
|
+
}
|
|
91
|
+
Contour.prototype.publish("paletteID", "YlGnBu", "string", "Color palette for this widget");
|
|
92
|
+
Contour.prototype.publish("useClonedPalette", true, "boolean", "Enable or disable using a cloned palette");
|
|
93
|
+
Contour.prototype.publish("showContourFill", true, "boolean", "Show/hide the contour background colors");
|
|
94
|
+
Contour.prototype.publish("showContour", true, "boolean", "Show/hide the contour border lines");
|
|
95
|
+
Contour.prototype.publish("contourBandwidth", 40, "number", "Controls the sensitivity of the contour grouping algorithm");
|
|
96
|
+
Contour.prototype.publish("contourStrokeColor", "#2C3A47", "html-color", "Color of the contour border lines");
|
|
97
|
+
Contour.prototype.publish("contourStrokeWidth", 1, "number", "Width of the contour border lines");
|