@hpcc-js/chart 2.86.1 → 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.
- package/LICENSE +43 -43
- package/README.md +93 -93
- package/dist/index.es6.js +2 -2
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.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 +733 -733
- 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 +191 -191
- package/src/BubbleXY.ts +14 -14
- package/src/Bullet.css +60 -60
- package/src/Bullet.md +104 -104
- package/src/Bullet.ts +167 -167
- package/src/Column.css +17 -17
- package/src/Column.md +90 -90
- package/src/Column.ts +659 -659
- package/src/Contour.md +88 -88
- package/src/Contour.ts +97 -97
- package/src/D3Cloud.ts +400 -400
- package/src/Gantt.md +119 -119
- package/src/Gantt.ts +14 -14
- package/src/Gauge.md +148 -148
- package/src/Gauge.ts +358 -358
- 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 +139 -139
- package/src/Line.css +6 -6
- package/src/Line.md +170 -170
- package/src/Line.ts +14 -14
- package/src/Pie.css +23 -23
- package/src/Pie.md +88 -88
- package/src/Pie.ts +503 -503
- 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 +212 -212
- package/src/Scatter.css +16 -16
- package/src/Scatter.md +163 -163
- package/src/Scatter.ts +376 -376
- package/src/StatChart.md +117 -117
- package/src/StatChart.ts +253 -253
- 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 +263 -263
- package/src/XYAxis.css +41 -41
- package/src/XYAxis.md +149 -149
- package/src/XYAxis.ts +803 -803
- 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 +69 -69
- package/src/index.ts +27 -27
- package/src/test.ts +71 -71
- package/types/__package__.d.ts +2 -2
- package/types-3.4/__package__.d.ts +2 -2
package/src/Bullet.md
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
# Bullet
|
|
2
|
-
|
|
3
|
-
<!--meta
|
|
4
|
-
|
|
5
|
-
-->
|
|
6
|
-
|
|
7
|
-
The Bullet chart displays a title and subtitle along with three types of values to the right. Each row's values are placed relative to the other values in that row. Their placement is unaffected by the values in other rows.
|
|
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 { Bullet } from "@hpcc-js/chart";
|
|
16
|
-
|
|
17
|
-
new Bullet()
|
|
18
|
-
.target("placeholder")
|
|
19
|
-
.columns(["title", "subtitle", "measures"])
|
|
20
|
-
.data([
|
|
21
|
-
["Revenue", "US$, in thousands", [220, 270, 345]],
|
|
22
|
-
["Profit ", "%", [21, 23]],
|
|
23
|
-
["Order Size", "US$, average", [100, 320, 432]],
|
|
24
|
-
["New Customers", "count", [1000, 1650, 1943]],
|
|
25
|
-
["Satisfaction", "out of 5", [3.2, 4.7, 4.9]]
|
|
26
|
-
])
|
|
27
|
-
.titleColumn("title")
|
|
28
|
-
.subtitleColumn("subtitle")
|
|
29
|
-
.measuresColumn("measures")
|
|
30
|
-
.render()
|
|
31
|
-
;
|
|
32
|
-
</script>
|
|
33
|
-
</hpcc-vitepress>
|
|
34
|
-
</ClientOnly>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
In this example "markers" have been added.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<ClientOnly>
|
|
41
|
-
<hpcc-vitepress style="width:100%;height:600px">
|
|
42
|
-
<div id="placeholder" style="height:400px">
|
|
43
|
-
</div>
|
|
44
|
-
<script type="module">
|
|
45
|
-
import { Bullet } from "@hpcc-js/chart";
|
|
46
|
-
|
|
47
|
-
new Bullet()
|
|
48
|
-
.target("placeholder")
|
|
49
|
-
.columns(["title", "subtitle", "measures", "markers"])
|
|
50
|
-
.data([
|
|
51
|
-
["Revenue", "US$, in thousands", [220, 270], [250, 25]],
|
|
52
|
-
["Profit ", "%", [21, 23], [26]],
|
|
53
|
-
["Order Size", "US$, average", [100, 320], [150, 550]],
|
|
54
|
-
["New Customers", "count", [1000, 1650], [190, 540, 750, 850, 2100]],
|
|
55
|
-
["Satisfaction", "out of 5", [3.2, 4.7], [4.4]]
|
|
56
|
-
])
|
|
57
|
-
.titleColumn("title")
|
|
58
|
-
.subtitleColumn("subtitle")
|
|
59
|
-
.measuresColumn("measures")
|
|
60
|
-
.markersColumn("markers")
|
|
61
|
-
.render()
|
|
62
|
-
;
|
|
63
|
-
</script>
|
|
64
|
-
</hpcc-vitepress>
|
|
65
|
-
</ClientOnly>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
In this example "ranges" have been added.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<ClientOnly>
|
|
72
|
-
<hpcc-vitepress style="width:100%;height:600px">
|
|
73
|
-
<div id="placeholder" style="height:400px">
|
|
74
|
-
</div>
|
|
75
|
-
<script type="module">
|
|
76
|
-
import { Bullet } from "@hpcc-js/chart";
|
|
77
|
-
|
|
78
|
-
new Bullet()
|
|
79
|
-
.target("placeholder")
|
|
80
|
-
.columns(["title", "subtitle", "ranges", "measures", "markers"])
|
|
81
|
-
.data([
|
|
82
|
-
["Revenue", "US$, in thousands", [150, 225, 300], [220, 270], [250, 25]],
|
|
83
|
-
["Profit ", "%", [20, 25, 30], [21, 23], [26]],
|
|
84
|
-
["Order Size", "US$, average", [350, 500, 600], [100, 320], [550]],
|
|
85
|
-
["New Customers", "count", [1400, 2000, 2500], [1000, 1650], 2100],
|
|
86
|
-
["Satisfaction", "out of 5", [3.5, 4.25, 5], [3.2, 4.7], [4.4]]
|
|
87
|
-
])
|
|
88
|
-
.titleColumn("title")
|
|
89
|
-
.subtitleColumn("subtitle")
|
|
90
|
-
.rangesColumn("ranges")
|
|
91
|
-
.measuresColumn("measures")
|
|
92
|
-
.markersColumn("markers")
|
|
93
|
-
.render()
|
|
94
|
-
;
|
|
95
|
-
</script>
|
|
96
|
-
</hpcc-vitepress>
|
|
97
|
-
</ClientOnly>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
## API
|
|
101
|
-
|
|
102
|
-
## Published Properties
|
|
103
|
-
```@hpcc-js/chart:Bullet
|
|
104
|
-
```
|
|
1
|
+
# Bullet
|
|
2
|
+
|
|
3
|
+
<!--meta
|
|
4
|
+
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
The Bullet chart displays a title and subtitle along with three types of values to the right. Each row's values are placed relative to the other values in that row. Their placement is unaffected by the values in other rows.
|
|
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 { Bullet } from "@hpcc-js/chart";
|
|
16
|
+
|
|
17
|
+
new Bullet()
|
|
18
|
+
.target("placeholder")
|
|
19
|
+
.columns(["title", "subtitle", "measures"])
|
|
20
|
+
.data([
|
|
21
|
+
["Revenue", "US$, in thousands", [220, 270, 345]],
|
|
22
|
+
["Profit ", "%", [21, 23]],
|
|
23
|
+
["Order Size", "US$, average", [100, 320, 432]],
|
|
24
|
+
["New Customers", "count", [1000, 1650, 1943]],
|
|
25
|
+
["Satisfaction", "out of 5", [3.2, 4.7, 4.9]]
|
|
26
|
+
])
|
|
27
|
+
.titleColumn("title")
|
|
28
|
+
.subtitleColumn("subtitle")
|
|
29
|
+
.measuresColumn("measures")
|
|
30
|
+
.render()
|
|
31
|
+
;
|
|
32
|
+
</script>
|
|
33
|
+
</hpcc-vitepress>
|
|
34
|
+
</ClientOnly>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
In this example "markers" have been added.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<ClientOnly>
|
|
41
|
+
<hpcc-vitepress style="width:100%;height:600px">
|
|
42
|
+
<div id="placeholder" style="height:400px">
|
|
43
|
+
</div>
|
|
44
|
+
<script type="module">
|
|
45
|
+
import { Bullet } from "@hpcc-js/chart";
|
|
46
|
+
|
|
47
|
+
new Bullet()
|
|
48
|
+
.target("placeholder")
|
|
49
|
+
.columns(["title", "subtitle", "measures", "markers"])
|
|
50
|
+
.data([
|
|
51
|
+
["Revenue", "US$, in thousands", [220, 270], [250, 25]],
|
|
52
|
+
["Profit ", "%", [21, 23], [26]],
|
|
53
|
+
["Order Size", "US$, average", [100, 320], [150, 550]],
|
|
54
|
+
["New Customers", "count", [1000, 1650], [190, 540, 750, 850, 2100]],
|
|
55
|
+
["Satisfaction", "out of 5", [3.2, 4.7], [4.4]]
|
|
56
|
+
])
|
|
57
|
+
.titleColumn("title")
|
|
58
|
+
.subtitleColumn("subtitle")
|
|
59
|
+
.measuresColumn("measures")
|
|
60
|
+
.markersColumn("markers")
|
|
61
|
+
.render()
|
|
62
|
+
;
|
|
63
|
+
</script>
|
|
64
|
+
</hpcc-vitepress>
|
|
65
|
+
</ClientOnly>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
In this example "ranges" have been added.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
<ClientOnly>
|
|
72
|
+
<hpcc-vitepress style="width:100%;height:600px">
|
|
73
|
+
<div id="placeholder" style="height:400px">
|
|
74
|
+
</div>
|
|
75
|
+
<script type="module">
|
|
76
|
+
import { Bullet } from "@hpcc-js/chart";
|
|
77
|
+
|
|
78
|
+
new Bullet()
|
|
79
|
+
.target("placeholder")
|
|
80
|
+
.columns(["title", "subtitle", "ranges", "measures", "markers"])
|
|
81
|
+
.data([
|
|
82
|
+
["Revenue", "US$, in thousands", [150, 225, 300], [220, 270], [250, 25]],
|
|
83
|
+
["Profit ", "%", [20, 25, 30], [21, 23], [26]],
|
|
84
|
+
["Order Size", "US$, average", [350, 500, 600], [100, 320], [550]],
|
|
85
|
+
["New Customers", "count", [1400, 2000, 2500], [1000, 1650], 2100],
|
|
86
|
+
["Satisfaction", "out of 5", [3.5, 4.25, 5], [3.2, 4.7], [4.4]]
|
|
87
|
+
])
|
|
88
|
+
.titleColumn("title")
|
|
89
|
+
.subtitleColumn("subtitle")
|
|
90
|
+
.rangesColumn("ranges")
|
|
91
|
+
.measuresColumn("measures")
|
|
92
|
+
.markersColumn("markers")
|
|
93
|
+
.render()
|
|
94
|
+
;
|
|
95
|
+
</script>
|
|
96
|
+
</hpcc-vitepress>
|
|
97
|
+
</ClientOnly>
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## API
|
|
101
|
+
|
|
102
|
+
## Published Properties
|
|
103
|
+
```@hpcc-js/chart:Bullet
|
|
104
|
+
```
|
package/src/Bullet.ts
CHANGED
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
import { HTMLWidget, publish, Utility } from "@hpcc-js/common";
|
|
2
|
-
import { select as d3Select } from "d3-selection";
|
|
3
|
-
import { bullet as d3Bullet } from "d3v4-bullet";
|
|
4
|
-
|
|
5
|
-
import "../src/Bullet.css";
|
|
6
|
-
|
|
7
|
-
export class Bullet extends HTMLWidget {
|
|
8
|
-
@publish(null, "set", "Title Column", function () { return this.columns(); }, { optional: true })
|
|
9
|
-
titleColumn: publish<this, string>;
|
|
10
|
-
@publish(null, "set", "Subtitle Column", function () { return this.columns(); }, { optional: true })
|
|
11
|
-
subtitleColumn: publish<this, string>;
|
|
12
|
-
@publish(null, "set", "Ranges Column", function () { return this.columns(); }, { optional: true })
|
|
13
|
-
rangesColumn: publish<this, string>;
|
|
14
|
-
@publish(null, "set", "Measures Column", function () { return this.columns(); }, { optional: true })
|
|
15
|
-
measuresColumn: publish<this, string>;
|
|
16
|
-
@publish(null, "set", "Markers Column", function () { return this.columns(); }, { optional: true })
|
|
17
|
-
markersColumn: publish<this, string>;
|
|
18
|
-
|
|
19
|
-
private _hiddenColumns = {};
|
|
20
|
-
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
Utility.SimpleSelectionMixin.call(this, true);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
bulletData() {
|
|
27
|
-
const context = this;
|
|
28
|
-
this._hiddenColumns = {};
|
|
29
|
-
const columns = this.columns();
|
|
30
|
-
return this.data().map(function (row) {
|
|
31
|
-
return {
|
|
32
|
-
title: valueOf(row, this.titleColumn()),
|
|
33
|
-
subtitle: valueOf(row, this.subtitleColumn()),
|
|
34
|
-
ranges: valueOf(row, this.rangesColumn(), "range"),
|
|
35
|
-
measures: valueOf(row, this.measuresColumn(), "measure"),
|
|
36
|
-
markers: valueOf(row, this.markersColumn(), "marker"),
|
|
37
|
-
origRow: row
|
|
38
|
-
};
|
|
39
|
-
}, this);
|
|
40
|
-
|
|
41
|
-
function valueOf(row, column, columnType?) {
|
|
42
|
-
const colIdx = columns.indexOf(column);
|
|
43
|
-
if (colIdx >= 0) {
|
|
44
|
-
if (row[colIdx] instanceof Array) {
|
|
45
|
-
return row[colIdx];
|
|
46
|
-
}
|
|
47
|
-
return [row[colIdx]];
|
|
48
|
-
}
|
|
49
|
-
if (columnType) {
|
|
50
|
-
context._hiddenColumns[columnType] = true;
|
|
51
|
-
}
|
|
52
|
-
return [0];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
enter(domNode, element) {
|
|
57
|
-
super.enter(domNode, element);
|
|
58
|
-
d3Select(domNode.parentNode).style("overflow", "auto");
|
|
59
|
-
this._selection.widgetElement(element);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
update(_domNode, element) {
|
|
63
|
-
super.update(_domNode, element);
|
|
64
|
-
const context = this;
|
|
65
|
-
|
|
66
|
-
element.selectAll(".axis")
|
|
67
|
-
.style("display", "none")
|
|
68
|
-
;
|
|
69
|
-
element.selectAll(".range,.measure,.marker")
|
|
70
|
-
.style("display", null)
|
|
71
|
-
;
|
|
72
|
-
|
|
73
|
-
const margin = { left: 2, top: 8, right: 2, bottom: 8 };
|
|
74
|
-
const width = this.width() - margin.left - margin.right;
|
|
75
|
-
const height = 40 - margin.top - margin.bottom;
|
|
76
|
-
|
|
77
|
-
const svg = element.selectAll("svg").data(this.bulletData());
|
|
78
|
-
const svgUpdate = svg.enter().append("svg")
|
|
79
|
-
.attr("class", "bullet")
|
|
80
|
-
.call(this._selection.enter.bind(this._selection))
|
|
81
|
-
.on("click", function (d) {
|
|
82
|
-
context.click(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
83
|
-
})
|
|
84
|
-
.on("dblclick", function (d) {
|
|
85
|
-
context.dblclick(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
86
|
-
})
|
|
87
|
-
.each(function () {
|
|
88
|
-
const element2 = d3Select(this);
|
|
89
|
-
const bulletBar = element2.append("g")
|
|
90
|
-
.attr("class", (d, i) => "bulletBar series series-" + context.cssTag(context.titleColumn()))
|
|
91
|
-
;
|
|
92
|
-
const bulletTitle = bulletBar.append("g")
|
|
93
|
-
.attr("class", "bulletTitle")
|
|
94
|
-
;
|
|
95
|
-
bulletTitle.append("text")
|
|
96
|
-
.attr("class", "title")
|
|
97
|
-
;
|
|
98
|
-
bulletTitle.append("text")
|
|
99
|
-
.attr("class", "subtitle")
|
|
100
|
-
.attr("dy", "1em")
|
|
101
|
-
;
|
|
102
|
-
})
|
|
103
|
-
.merge(svg)
|
|
104
|
-
;
|
|
105
|
-
|
|
106
|
-
// Title ---
|
|
107
|
-
const title = svgUpdate.select(".bulletTitle")
|
|
108
|
-
.style("text-anchor", "end")
|
|
109
|
-
.attr("transform", "translate(-6," + height / 2 + ")")
|
|
110
|
-
;
|
|
111
|
-
title.select(".title")
|
|
112
|
-
.text(function (d) { return d.title; })
|
|
113
|
-
;
|
|
114
|
-
title.select(".subtitle")
|
|
115
|
-
.text(function (d) { return d.subtitle; })
|
|
116
|
-
;
|
|
117
|
-
|
|
118
|
-
let titleWidth = 0;
|
|
119
|
-
title.each(function () {
|
|
120
|
-
const bbox = this.getBBox();
|
|
121
|
-
if (bbox.width > titleWidth) {
|
|
122
|
-
titleWidth = bbox.width;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
titleWidth; // Gap between title and bullet bar.
|
|
126
|
-
|
|
127
|
-
// Bullet Chart ---
|
|
128
|
-
const chart = d3Bullet()
|
|
129
|
-
.width(width - titleWidth - 6)
|
|
130
|
-
.height(height)
|
|
131
|
-
;
|
|
132
|
-
svgUpdate
|
|
133
|
-
.attr("width", width)
|
|
134
|
-
.attr("height", height + margin.top + margin.bottom)
|
|
135
|
-
.style("margin-left", `${margin.left}px`)
|
|
136
|
-
;
|
|
137
|
-
svgUpdate.select(".bulletBar")
|
|
138
|
-
.attr("transform", "translate(" + (titleWidth + 6) + "," + margin.top + ")")
|
|
139
|
-
.call(chart)
|
|
140
|
-
;
|
|
141
|
-
|
|
142
|
-
svg.exit().remove();
|
|
143
|
-
|
|
144
|
-
if (Object.keys(this._hiddenColumns).length > 0) {
|
|
145
|
-
element.selectAll(`.${Object.keys(this._hiddenColumns).join(",.")}`)
|
|
146
|
-
.style("display", "none")
|
|
147
|
-
;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
exit(domNode, element) {
|
|
152
|
-
super.exit(domNode, element);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Events ---
|
|
156
|
-
click(row, column, selected) {
|
|
157
|
-
// console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
dblclick(row, column, selected) {
|
|
161
|
-
// console.log("Double click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// SimpleSelectionMixin
|
|
165
|
-
_selection;
|
|
166
|
-
}
|
|
167
|
-
Bullet.prototype._class += " chart_Bullet";
|
|
1
|
+
import { HTMLWidget, publish, Utility } from "@hpcc-js/common";
|
|
2
|
+
import { select as d3Select } from "d3-selection";
|
|
3
|
+
import { bullet as d3Bullet } from "d3v4-bullet";
|
|
4
|
+
|
|
5
|
+
import "../src/Bullet.css";
|
|
6
|
+
|
|
7
|
+
export class Bullet extends HTMLWidget {
|
|
8
|
+
@publish(null, "set", "Title Column", function () { return this.columns(); }, { optional: true })
|
|
9
|
+
titleColumn: publish<this, string>;
|
|
10
|
+
@publish(null, "set", "Subtitle Column", function () { return this.columns(); }, { optional: true })
|
|
11
|
+
subtitleColumn: publish<this, string>;
|
|
12
|
+
@publish(null, "set", "Ranges Column", function () { return this.columns(); }, { optional: true })
|
|
13
|
+
rangesColumn: publish<this, string>;
|
|
14
|
+
@publish(null, "set", "Measures Column", function () { return this.columns(); }, { optional: true })
|
|
15
|
+
measuresColumn: publish<this, string>;
|
|
16
|
+
@publish(null, "set", "Markers Column", function () { return this.columns(); }, { optional: true })
|
|
17
|
+
markersColumn: publish<this, string>;
|
|
18
|
+
|
|
19
|
+
private _hiddenColumns = {};
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
Utility.SimpleSelectionMixin.call(this, true);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
bulletData() {
|
|
27
|
+
const context = this;
|
|
28
|
+
this._hiddenColumns = {};
|
|
29
|
+
const columns = this.columns();
|
|
30
|
+
return this.data().map(function (row) {
|
|
31
|
+
return {
|
|
32
|
+
title: valueOf(row, this.titleColumn()),
|
|
33
|
+
subtitle: valueOf(row, this.subtitleColumn()),
|
|
34
|
+
ranges: valueOf(row, this.rangesColumn(), "range"),
|
|
35
|
+
measures: valueOf(row, this.measuresColumn(), "measure"),
|
|
36
|
+
markers: valueOf(row, this.markersColumn(), "marker"),
|
|
37
|
+
origRow: row
|
|
38
|
+
};
|
|
39
|
+
}, this);
|
|
40
|
+
|
|
41
|
+
function valueOf(row, column, columnType?) {
|
|
42
|
+
const colIdx = columns.indexOf(column);
|
|
43
|
+
if (colIdx >= 0) {
|
|
44
|
+
if (row[colIdx] instanceof Array) {
|
|
45
|
+
return row[colIdx];
|
|
46
|
+
}
|
|
47
|
+
return [row[colIdx]];
|
|
48
|
+
}
|
|
49
|
+
if (columnType) {
|
|
50
|
+
context._hiddenColumns[columnType] = true;
|
|
51
|
+
}
|
|
52
|
+
return [0];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
enter(domNode, element) {
|
|
57
|
+
super.enter(domNode, element);
|
|
58
|
+
d3Select(domNode.parentNode).style("overflow", "auto");
|
|
59
|
+
this._selection.widgetElement(element);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
update(_domNode, element) {
|
|
63
|
+
super.update(_domNode, element);
|
|
64
|
+
const context = this;
|
|
65
|
+
|
|
66
|
+
element.selectAll(".axis")
|
|
67
|
+
.style("display", "none")
|
|
68
|
+
;
|
|
69
|
+
element.selectAll(".range,.measure,.marker")
|
|
70
|
+
.style("display", null)
|
|
71
|
+
;
|
|
72
|
+
|
|
73
|
+
const margin = { left: 2, top: 8, right: 2, bottom: 8 };
|
|
74
|
+
const width = this.width() - margin.left - margin.right;
|
|
75
|
+
const height = 40 - margin.top - margin.bottom;
|
|
76
|
+
|
|
77
|
+
const svg = element.selectAll("svg").data(this.bulletData());
|
|
78
|
+
const svgUpdate = svg.enter().append("svg")
|
|
79
|
+
.attr("class", "bullet")
|
|
80
|
+
.call(this._selection.enter.bind(this._selection))
|
|
81
|
+
.on("click", function (d) {
|
|
82
|
+
context.click(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
83
|
+
})
|
|
84
|
+
.on("dblclick", function (d) {
|
|
85
|
+
context.dblclick(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
86
|
+
})
|
|
87
|
+
.each(function () {
|
|
88
|
+
const element2 = d3Select(this);
|
|
89
|
+
const bulletBar = element2.append("g")
|
|
90
|
+
.attr("class", (d, i) => "bulletBar series series-" + context.cssTag(context.titleColumn()))
|
|
91
|
+
;
|
|
92
|
+
const bulletTitle = bulletBar.append("g")
|
|
93
|
+
.attr("class", "bulletTitle")
|
|
94
|
+
;
|
|
95
|
+
bulletTitle.append("text")
|
|
96
|
+
.attr("class", "title")
|
|
97
|
+
;
|
|
98
|
+
bulletTitle.append("text")
|
|
99
|
+
.attr("class", "subtitle")
|
|
100
|
+
.attr("dy", "1em")
|
|
101
|
+
;
|
|
102
|
+
})
|
|
103
|
+
.merge(svg)
|
|
104
|
+
;
|
|
105
|
+
|
|
106
|
+
// Title ---
|
|
107
|
+
const title = svgUpdate.select(".bulletTitle")
|
|
108
|
+
.style("text-anchor", "end")
|
|
109
|
+
.attr("transform", "translate(-6," + height / 2 + ")")
|
|
110
|
+
;
|
|
111
|
+
title.select(".title")
|
|
112
|
+
.text(function (d) { return d.title; })
|
|
113
|
+
;
|
|
114
|
+
title.select(".subtitle")
|
|
115
|
+
.text(function (d) { return d.subtitle; })
|
|
116
|
+
;
|
|
117
|
+
|
|
118
|
+
let titleWidth = 0;
|
|
119
|
+
title.each(function () {
|
|
120
|
+
const bbox = this.getBBox();
|
|
121
|
+
if (bbox.width > titleWidth) {
|
|
122
|
+
titleWidth = bbox.width;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
titleWidth; // Gap between title and bullet bar.
|
|
126
|
+
|
|
127
|
+
// Bullet Chart ---
|
|
128
|
+
const chart = d3Bullet()
|
|
129
|
+
.width(width - titleWidth - 6)
|
|
130
|
+
.height(height)
|
|
131
|
+
;
|
|
132
|
+
svgUpdate
|
|
133
|
+
.attr("width", width)
|
|
134
|
+
.attr("height", height + margin.top + margin.bottom)
|
|
135
|
+
.style("margin-left", `${margin.left}px`)
|
|
136
|
+
;
|
|
137
|
+
svgUpdate.select(".bulletBar")
|
|
138
|
+
.attr("transform", "translate(" + (titleWidth + 6) + "," + margin.top + ")")
|
|
139
|
+
.call(chart)
|
|
140
|
+
;
|
|
141
|
+
|
|
142
|
+
svg.exit().remove();
|
|
143
|
+
|
|
144
|
+
if (Object.keys(this._hiddenColumns).length > 0) {
|
|
145
|
+
element.selectAll(`.${Object.keys(this._hiddenColumns).join(",.")}`)
|
|
146
|
+
.style("display", "none")
|
|
147
|
+
;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
exit(domNode, element) {
|
|
152
|
+
super.exit(domNode, element);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Events ---
|
|
156
|
+
click(row, column, selected) {
|
|
157
|
+
// console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
dblclick(row, column, selected) {
|
|
161
|
+
// console.log("Double click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// SimpleSelectionMixin
|
|
165
|
+
_selection;
|
|
166
|
+
}
|
|
167
|
+
Bullet.prototype._class += " chart_Bullet";
|
package/src/Column.css
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
.chart_Column .columnRect {
|
|
2
|
-
fill: steelblue;
|
|
3
|
-
cursor: pointer;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.chart_Column .data.axis path {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.chart_Column .columnRect {
|
|
11
|
-
stroke: transparent;
|
|
12
|
-
border-width: 1.5px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.chart_Column .columnRect.selected {
|
|
16
|
-
stroke: red;
|
|
17
|
-
}
|
|
1
|
+
.chart_Column .columnRect {
|
|
2
|
+
fill: steelblue;
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.chart_Column .data.axis path {
|
|
7
|
+
display: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.chart_Column .columnRect {
|
|
11
|
+
stroke: transparent;
|
|
12
|
+
border-width: 1.5px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.chart_Column .columnRect.selected {
|
|
16
|
+
stroke: red;
|
|
17
|
+
}
|