@hpcc-js/chart 3.6.3 → 3.6.5
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 +34 -34
- 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 +60 -60
- 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 +9 -9
- package/src/HexBin.md +88 -88
- package/src/HexBin.ts +144 -144
- package/src/Line.css +6 -6
- 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 +15 -15
- 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 +56 -56
- 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 +3 -3
- package/src/WordCloud.md +144 -144
- package/src/WordCloud.ts +268 -268
- package/src/XYAxis.css +41 -41
- 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/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,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
|
+
|