@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/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,176 +1,176 @@
|
|
|
1
|
-
import { HTMLWidget, 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
|
-
|
|
9
|
-
private _hiddenColumns = {};
|
|
10
|
-
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
Utility.SimpleSelectionMixin.call(this, true);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
bulletData() {
|
|
17
|
-
const context = this;
|
|
18
|
-
this._hiddenColumns = {};
|
|
19
|
-
const columns = this.columns();
|
|
20
|
-
return this.data().map(function (row) {
|
|
21
|
-
return {
|
|
22
|
-
title: valueOf(row, this.titleColumn()),
|
|
23
|
-
subtitle: valueOf(row, this.subtitleColumn()),
|
|
24
|
-
ranges: valueOf(row, this.rangesColumn(), "range"),
|
|
25
|
-
measures: valueOf(row, this.measuresColumn(), "measure"),
|
|
26
|
-
markers: valueOf(row, this.markersColumn(), "marker"),
|
|
27
|
-
origRow: row
|
|
28
|
-
};
|
|
29
|
-
}, this);
|
|
30
|
-
|
|
31
|
-
function valueOf(row, column, columnType?) {
|
|
32
|
-
const colIdx = columns.indexOf(column);
|
|
33
|
-
if (colIdx >= 0) {
|
|
34
|
-
if (row[colIdx] instanceof Array) {
|
|
35
|
-
return row[colIdx];
|
|
36
|
-
}
|
|
37
|
-
return [row[colIdx]];
|
|
38
|
-
}
|
|
39
|
-
if (columnType) {
|
|
40
|
-
context._hiddenColumns[columnType] = true;
|
|
41
|
-
}
|
|
42
|
-
return [0];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
enter(domNode, element) {
|
|
47
|
-
super.enter(domNode, element);
|
|
48
|
-
d3Select(domNode.parentNode).style("overflow", "auto");
|
|
49
|
-
this._selection.widgetElement(element);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
update(_domNode, element) {
|
|
53
|
-
super.update(_domNode, element);
|
|
54
|
-
const context = this;
|
|
55
|
-
|
|
56
|
-
element.selectAll(".axis")
|
|
57
|
-
.style("display", "none")
|
|
58
|
-
;
|
|
59
|
-
element.selectAll(".range,.measure,.marker")
|
|
60
|
-
.style("display", null)
|
|
61
|
-
;
|
|
62
|
-
|
|
63
|
-
const margin = { left: 2, top: 8, right: 2, bottom: 8 };
|
|
64
|
-
const width = this.width() - margin.left - margin.right;
|
|
65
|
-
const height = 40 - margin.top - margin.bottom;
|
|
66
|
-
|
|
67
|
-
const svg = element.selectAll("svg").data(this.bulletData());
|
|
68
|
-
const svgUpdate = svg.enter().append("svg")
|
|
69
|
-
.attr("class", "bullet")
|
|
70
|
-
.call(this._selection.enter.bind(this._selection))
|
|
71
|
-
.on("click", function (d) {
|
|
72
|
-
context.click(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
73
|
-
})
|
|
74
|
-
.on("dblclick", function (d) {
|
|
75
|
-
context.dblclick(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
76
|
-
})
|
|
77
|
-
.each(function () {
|
|
78
|
-
const element2 = d3Select(this);
|
|
79
|
-
const bulletBar = element2.append("g")
|
|
80
|
-
.attr("class", (d, i) => "bulletBar series series-" + context.cssTag(context.titleColumn()))
|
|
81
|
-
;
|
|
82
|
-
const bulletTitle = bulletBar.append("g")
|
|
83
|
-
.attr("class", "bulletTitle")
|
|
84
|
-
;
|
|
85
|
-
bulletTitle.append("text")
|
|
86
|
-
.attr("class", "title")
|
|
87
|
-
;
|
|
88
|
-
bulletTitle.append("text")
|
|
89
|
-
.attr("class", "subtitle")
|
|
90
|
-
.attr("dy", "1em")
|
|
91
|
-
;
|
|
92
|
-
})
|
|
93
|
-
.merge(svg)
|
|
94
|
-
;
|
|
95
|
-
|
|
96
|
-
// Title ---
|
|
97
|
-
const title = svgUpdate.select(".bulletTitle")
|
|
98
|
-
.style("text-anchor", "end")
|
|
99
|
-
.attr("transform", "translate(-6," + height / 2 + ")")
|
|
100
|
-
;
|
|
101
|
-
title.select(".title")
|
|
102
|
-
.text(function (d) { return d.title; })
|
|
103
|
-
;
|
|
104
|
-
title.select(".subtitle")
|
|
105
|
-
.text(function (d) { return d.subtitle; })
|
|
106
|
-
;
|
|
107
|
-
|
|
108
|
-
let titleWidth = 0;
|
|
109
|
-
title.each(function () {
|
|
110
|
-
const bbox = this.getBBox();
|
|
111
|
-
if (bbox.width > titleWidth) {
|
|
112
|
-
titleWidth = bbox.width;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// Bullet Chart ---
|
|
117
|
-
const chart = d3Bullet()
|
|
118
|
-
.width(width - titleWidth - 6)
|
|
119
|
-
.height(height)
|
|
120
|
-
;
|
|
121
|
-
svgUpdate
|
|
122
|
-
.attr("width", width)
|
|
123
|
-
.attr("height", height + margin.top + margin.bottom)
|
|
124
|
-
.style("margin-left", `${margin.left}px`)
|
|
125
|
-
;
|
|
126
|
-
svgUpdate.select(".bulletBar")
|
|
127
|
-
.attr("transform", "translate(" + (titleWidth + 6) + "," + margin.top + ")")
|
|
128
|
-
.call(chart)
|
|
129
|
-
;
|
|
130
|
-
|
|
131
|
-
svg.exit().remove();
|
|
132
|
-
|
|
133
|
-
if (Object.keys(this._hiddenColumns).length > 0) {
|
|
134
|
-
element.selectAll(`.${Object.keys(this._hiddenColumns).join(",.")}`)
|
|
135
|
-
.style("display", "none")
|
|
136
|
-
;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
exit(domNode, element) {
|
|
141
|
-
super.exit(domNode, element);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Events ---
|
|
145
|
-
click(row, column, selected) {
|
|
146
|
-
// console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
dblclick(row, column, selected) {
|
|
150
|
-
// console.log("Double click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// SimpleSelectionMixin
|
|
154
|
-
_selection;
|
|
155
|
-
}
|
|
156
|
-
Bullet.prototype._class += " chart_Bullet";
|
|
157
|
-
|
|
158
|
-
export interface Bullet {
|
|
159
|
-
titleColumn(): string;
|
|
160
|
-
titleColumn(_: string): this;
|
|
161
|
-
subtitleColumn(): string;
|
|
162
|
-
subtitleColumn(_: string): this;
|
|
163
|
-
rangesColumn(): string;
|
|
164
|
-
rangesColumn(_: string): this;
|
|
165
|
-
measuresColumn(): string;
|
|
166
|
-
measuresColumn(_: string): this;
|
|
167
|
-
markersColumn(): string;
|
|
168
|
-
markersColumn(_: string): this;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
Bullet.prototype.publish("titleColumn", null, "set", "Title Column", function () { return this.columns(); }, { optional: true });
|
|
172
|
-
Bullet.prototype.publish("subtitleColumn", null, "set", "Subtitle Column", function () { return this.columns(); }, { optional: true });
|
|
173
|
-
Bullet.prototype.publish("rangesColumn", null, "set", "Ranges Column", function () { return this.columns(); }, { optional: true });
|
|
174
|
-
Bullet.prototype.publish("measuresColumn", null, "set", "Measures Column", function () { return this.columns(); }, { optional: true });
|
|
175
|
-
Bullet.prototype.publish("markersColumn", null, "set", "Markers Column", function () { return this.columns(); }, { optional: true });
|
|
176
|
-
|
|
1
|
+
import { HTMLWidget, 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
|
+
|
|
9
|
+
private _hiddenColumns = {};
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
Utility.SimpleSelectionMixin.call(this, true);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
bulletData() {
|
|
17
|
+
const context = this;
|
|
18
|
+
this._hiddenColumns = {};
|
|
19
|
+
const columns = this.columns();
|
|
20
|
+
return this.data().map(function (row) {
|
|
21
|
+
return {
|
|
22
|
+
title: valueOf(row, this.titleColumn()),
|
|
23
|
+
subtitle: valueOf(row, this.subtitleColumn()),
|
|
24
|
+
ranges: valueOf(row, this.rangesColumn(), "range"),
|
|
25
|
+
measures: valueOf(row, this.measuresColumn(), "measure"),
|
|
26
|
+
markers: valueOf(row, this.markersColumn(), "marker"),
|
|
27
|
+
origRow: row
|
|
28
|
+
};
|
|
29
|
+
}, this);
|
|
30
|
+
|
|
31
|
+
function valueOf(row, column, columnType?) {
|
|
32
|
+
const colIdx = columns.indexOf(column);
|
|
33
|
+
if (colIdx >= 0) {
|
|
34
|
+
if (row[colIdx] instanceof Array) {
|
|
35
|
+
return row[colIdx];
|
|
36
|
+
}
|
|
37
|
+
return [row[colIdx]];
|
|
38
|
+
}
|
|
39
|
+
if (columnType) {
|
|
40
|
+
context._hiddenColumns[columnType] = true;
|
|
41
|
+
}
|
|
42
|
+
return [0];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
enter(domNode, element) {
|
|
47
|
+
super.enter(domNode, element);
|
|
48
|
+
d3Select(domNode.parentNode).style("overflow", "auto");
|
|
49
|
+
this._selection.widgetElement(element);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update(_domNode, element) {
|
|
53
|
+
super.update(_domNode, element);
|
|
54
|
+
const context = this;
|
|
55
|
+
|
|
56
|
+
element.selectAll(".axis")
|
|
57
|
+
.style("display", "none")
|
|
58
|
+
;
|
|
59
|
+
element.selectAll(".range,.measure,.marker")
|
|
60
|
+
.style("display", null)
|
|
61
|
+
;
|
|
62
|
+
|
|
63
|
+
const margin = { left: 2, top: 8, right: 2, bottom: 8 };
|
|
64
|
+
const width = this.width() - margin.left - margin.right;
|
|
65
|
+
const height = 40 - margin.top - margin.bottom;
|
|
66
|
+
|
|
67
|
+
const svg = element.selectAll("svg").data(this.bulletData());
|
|
68
|
+
const svgUpdate = svg.enter().append("svg")
|
|
69
|
+
.attr("class", "bullet")
|
|
70
|
+
.call(this._selection.enter.bind(this._selection))
|
|
71
|
+
.on("click", function (d) {
|
|
72
|
+
context.click(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
73
|
+
})
|
|
74
|
+
.on("dblclick", function (d) {
|
|
75
|
+
context.dblclick(context.rowToObj(d.origRow), context.titleColumn(), context._selection.selected(this));
|
|
76
|
+
})
|
|
77
|
+
.each(function () {
|
|
78
|
+
const element2 = d3Select(this);
|
|
79
|
+
const bulletBar = element2.append("g")
|
|
80
|
+
.attr("class", (d, i) => "bulletBar series series-" + context.cssTag(context.titleColumn()))
|
|
81
|
+
;
|
|
82
|
+
const bulletTitle = bulletBar.append("g")
|
|
83
|
+
.attr("class", "bulletTitle")
|
|
84
|
+
;
|
|
85
|
+
bulletTitle.append("text")
|
|
86
|
+
.attr("class", "title")
|
|
87
|
+
;
|
|
88
|
+
bulletTitle.append("text")
|
|
89
|
+
.attr("class", "subtitle")
|
|
90
|
+
.attr("dy", "1em")
|
|
91
|
+
;
|
|
92
|
+
})
|
|
93
|
+
.merge(svg)
|
|
94
|
+
;
|
|
95
|
+
|
|
96
|
+
// Title ---
|
|
97
|
+
const title = svgUpdate.select(".bulletTitle")
|
|
98
|
+
.style("text-anchor", "end")
|
|
99
|
+
.attr("transform", "translate(-6," + height / 2 + ")")
|
|
100
|
+
;
|
|
101
|
+
title.select(".title")
|
|
102
|
+
.text(function (d) { return d.title; })
|
|
103
|
+
;
|
|
104
|
+
title.select(".subtitle")
|
|
105
|
+
.text(function (d) { return d.subtitle; })
|
|
106
|
+
;
|
|
107
|
+
|
|
108
|
+
let titleWidth = 0;
|
|
109
|
+
title.each(function () {
|
|
110
|
+
const bbox = this.getBBox();
|
|
111
|
+
if (bbox.width > titleWidth) {
|
|
112
|
+
titleWidth = bbox.width;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Bullet Chart ---
|
|
117
|
+
const chart = d3Bullet()
|
|
118
|
+
.width(width - titleWidth - 6)
|
|
119
|
+
.height(height)
|
|
120
|
+
;
|
|
121
|
+
svgUpdate
|
|
122
|
+
.attr("width", width)
|
|
123
|
+
.attr("height", height + margin.top + margin.bottom)
|
|
124
|
+
.style("margin-left", `${margin.left}px`)
|
|
125
|
+
;
|
|
126
|
+
svgUpdate.select(".bulletBar")
|
|
127
|
+
.attr("transform", "translate(" + (titleWidth + 6) + "," + margin.top + ")")
|
|
128
|
+
.call(chart)
|
|
129
|
+
;
|
|
130
|
+
|
|
131
|
+
svg.exit().remove();
|
|
132
|
+
|
|
133
|
+
if (Object.keys(this._hiddenColumns).length > 0) {
|
|
134
|
+
element.selectAll(`.${Object.keys(this._hiddenColumns).join(",.")}`)
|
|
135
|
+
.style("display", "none")
|
|
136
|
+
;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exit(domNode, element) {
|
|
141
|
+
super.exit(domNode, element);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Events ---
|
|
145
|
+
click(row, column, selected) {
|
|
146
|
+
// console.log("Click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
dblclick(row, column, selected) {
|
|
150
|
+
// console.log("Double click: " + JSON.stringify(row) + ", " + column + "," + selected);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// SimpleSelectionMixin
|
|
154
|
+
_selection;
|
|
155
|
+
}
|
|
156
|
+
Bullet.prototype._class += " chart_Bullet";
|
|
157
|
+
|
|
158
|
+
export interface Bullet {
|
|
159
|
+
titleColumn(): string;
|
|
160
|
+
titleColumn(_: string): this;
|
|
161
|
+
subtitleColumn(): string;
|
|
162
|
+
subtitleColumn(_: string): this;
|
|
163
|
+
rangesColumn(): string;
|
|
164
|
+
rangesColumn(_: string): this;
|
|
165
|
+
measuresColumn(): string;
|
|
166
|
+
measuresColumn(_: string): this;
|
|
167
|
+
markersColumn(): string;
|
|
168
|
+
markersColumn(_: string): this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Bullet.prototype.publish("titleColumn", null, "set", "Title Column", function () { return this.columns(); }, { optional: true });
|
|
172
|
+
Bullet.prototype.publish("subtitleColumn", null, "set", "Subtitle Column", function () { return this.columns(); }, { optional: true });
|
|
173
|
+
Bullet.prototype.publish("rangesColumn", null, "set", "Ranges Column", function () { return this.columns(); }, { optional: true });
|
|
174
|
+
Bullet.prototype.publish("measuresColumn", null, "set", "Measures Column", function () { return this.columns(); }, { optional: true });
|
|
175
|
+
Bullet.prototype.publish("markersColumn", null, "set", "Markers Column", function () { return this.columns(); }, { optional: true });
|
|
176
|
+
|
package/src/Column.css
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
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: 2px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.chart_Column .dataCell.selected .columnRect {
|
|
16
|
-
stroke: #dc3545 !important;
|
|
17
|
-
stroke-width: 3px !important;
|
|
18
|
-
paint-order: fill stroke !important;
|
|
19
|
-
transition: all 0.2s ease;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.chart_Column .dataCell:hover .columnRect {
|
|
23
|
-
stroke: rgba(108, 117, 125, 0.6);
|
|
24
|
-
stroke-width: 2px;
|
|
25
|
-
filter: brightness(1.05);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.chart_Column .dataCell:focus .columnRect {
|
|
29
|
-
stroke: #007bff !important;
|
|
30
|
-
stroke-width: 3px !important;
|
|
31
|
-
paint-order: fill stroke !important;
|
|
32
|
-
transition: all 0.2s ease;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.chart_Column .dataCell.selected:focus .columnRect {
|
|
36
|
-
stroke: #6f42c1 !important;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.chart_Column .dataCell:focus-visible {
|
|
40
|
-
outline: none;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.chart_Column .dataCell:active {
|
|
44
|
-
outline: none !important;
|
|
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: 2px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.chart_Column .dataCell.selected .columnRect {
|
|
16
|
+
stroke: #dc3545 !important;
|
|
17
|
+
stroke-width: 3px !important;
|
|
18
|
+
paint-order: fill stroke !important;
|
|
19
|
+
transition: all 0.2s ease;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.chart_Column .dataCell:hover .columnRect {
|
|
23
|
+
stroke: rgba(108, 117, 125, 0.6);
|
|
24
|
+
stroke-width: 2px;
|
|
25
|
+
filter: brightness(1.05);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.chart_Column .dataCell:focus .columnRect {
|
|
29
|
+
stroke: #007bff !important;
|
|
30
|
+
stroke-width: 3px !important;
|
|
31
|
+
paint-order: fill stroke !important;
|
|
32
|
+
transition: all 0.2s ease;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.chart_Column .dataCell.selected:focus .columnRect {
|
|
36
|
+
stroke: #6f42c1 !important;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.chart_Column .dataCell:focus-visible {
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.chart_Column .dataCell:active {
|
|
44
|
+
outline: none !important;
|
|
45
45
|
}
|