@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/Summary.ts
CHANGED
|
@@ -1,322 +1,322 @@
|
|
|
1
|
-
import { I2DChart } from "@hpcc-js/api";
|
|
2
|
-
import { HTMLWidget } from "@hpcc-js/common";
|
|
3
|
-
import { rgb as d3Rgb } from "d3-color";
|
|
4
|
-
import { select as d3Select } from "d3-selection";
|
|
5
|
-
|
|
6
|
-
import "../src/Summary.css";
|
|
7
|
-
|
|
8
|
-
const TEXT = "text";
|
|
9
|
-
const HTML = "html";
|
|
10
|
-
|
|
11
|
-
export class Summary extends HTMLWidget {
|
|
12
|
-
protected _playIntervalIdx = 0;
|
|
13
|
-
protected _mainDiv;
|
|
14
|
-
protected _headerDiv;
|
|
15
|
-
protected _textDiv;
|
|
16
|
-
|
|
17
|
-
constructor() {
|
|
18
|
-
super();
|
|
19
|
-
this._tag = "div";
|
|
20
|
-
|
|
21
|
-
this._drawStartPos = "center";
|
|
22
|
-
this.playInterval(this.playInterval());
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
lookupFieldIdx(propID, defaultIdx?: number) {
|
|
26
|
-
let retVal = defaultIdx;
|
|
27
|
-
if (this[propID + "_exists"]()) {
|
|
28
|
-
retVal = this.columns().indexOf(this[propID]());
|
|
29
|
-
if (retVal < 0) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return retVal;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
lookupFieldText(propID, defaultIdx?: number) {
|
|
37
|
-
if (this[propID + "_exists"]()) {
|
|
38
|
-
return this[propID]();
|
|
39
|
-
}
|
|
40
|
-
if (defaultIdx !== undefined) {
|
|
41
|
-
return this.columns()[defaultIdx] || "";
|
|
42
|
-
}
|
|
43
|
-
return "";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
currentRow() {
|
|
47
|
-
return this.data()[this._playIntervalIdx];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
summaryData() {
|
|
51
|
-
let labelFieldIdx; // undefined
|
|
52
|
-
if (!this.hideLabel()) {
|
|
53
|
-
labelFieldIdx = this.lookupFieldIdx("labelColumn", 0);
|
|
54
|
-
}
|
|
55
|
-
const iconFieldIdx = this.lookupFieldIdx("iconColumn");
|
|
56
|
-
const valueFieldIdx = this.lookupFieldIdx("valueColumn", 1);
|
|
57
|
-
let moreIconIdx; // undefined
|
|
58
|
-
let moreTextIdx; // undefined
|
|
59
|
-
if (!this.hideMore()) {
|
|
60
|
-
moreIconIdx = this.lookupFieldIdx("moreIconColumn");
|
|
61
|
-
moreTextIdx = this.lookupFieldIdx("moreTextColumn");
|
|
62
|
-
}
|
|
63
|
-
const colorFillIdx = this.lookupFieldIdx("colorFillColumn");
|
|
64
|
-
const colorStrokeIdx = this.lookupFieldIdx("colorStrokeColumn");
|
|
65
|
-
return this.formattedData().map(function (row) {
|
|
66
|
-
return {
|
|
67
|
-
icon: iconFieldIdx === undefined ? this.icon() : row[iconFieldIdx],
|
|
68
|
-
label: labelFieldIdx === undefined ? "" : row[labelFieldIdx],
|
|
69
|
-
value: row[valueFieldIdx],
|
|
70
|
-
moreIcon: moreIconIdx === undefined ? (this.hideMore() ? "" : this.moreIcon()) : row[moreIconIdx],
|
|
71
|
-
moreText: moreTextIdx === undefined ? (this.hideMore() ? "" : this.moreText()) : row[moreTextIdx],
|
|
72
|
-
fill: colorFillIdx === undefined ? this.colorFill() : row[colorFillIdx],
|
|
73
|
-
stroke: colorStrokeIdx === undefined ? this.colorStroke() : row[colorStrokeIdx]
|
|
74
|
-
};
|
|
75
|
-
}, this);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
enter(domNode, element) {
|
|
79
|
-
super.enter(domNode, element);
|
|
80
|
-
this._mainDiv = element.append("div")
|
|
81
|
-
;
|
|
82
|
-
const context = this;
|
|
83
|
-
this._headerDiv = this._mainDiv.append("h2")
|
|
84
|
-
.on("click", function () {
|
|
85
|
-
context.click(context.rowToObj(context.currentRow()), context.lookupFieldText("valueColumn", 1), true);
|
|
86
|
-
})
|
|
87
|
-
.on("dblclick", function () {
|
|
88
|
-
context.dblclick(context.rowToObj(context.currentRow()), context.lookupFieldText("valueColumn", 1), true);
|
|
89
|
-
})
|
|
90
|
-
;
|
|
91
|
-
this._textDiv = this._mainDiv.append("div")
|
|
92
|
-
.attr("class", "text")
|
|
93
|
-
.on("click", function () {
|
|
94
|
-
context.click(context.rowToObj(context.currentRow()), context.lookupFieldText("labelColumn", 0), true);
|
|
95
|
-
})
|
|
96
|
-
.on("dblclick", function () {
|
|
97
|
-
context.dblclick(context.rowToObj(context.currentRow()), context.lookupFieldText("labelColumn", 0), true);
|
|
98
|
-
})
|
|
99
|
-
;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
update(domNode, element) {
|
|
103
|
-
super.update(domNode, element);
|
|
104
|
-
if (this.data().length) {
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
const data = this.summaryData();
|
|
108
|
-
if (this._playIntervalIdx >= data.length) {
|
|
109
|
-
this._playIntervalIdx = 0;
|
|
110
|
-
}
|
|
111
|
-
const row: any = this._playIntervalIdx < data.length ? data[this._playIntervalIdx] : ["", ""];
|
|
112
|
-
element
|
|
113
|
-
.style("width", this.fixedSize() ? this.minWidth_exists() ? this.minWidth() + "px" : null : "100%")
|
|
114
|
-
.style("height", this.fixedSize() ? this.minHeight_exists() ? this.minHeight() + "px" : null : "100%")
|
|
115
|
-
;
|
|
116
|
-
this._mainDiv
|
|
117
|
-
.attr("class", "content bgIcon " + row.icon)
|
|
118
|
-
.transition()
|
|
119
|
-
.style("background-color", row.fill)
|
|
120
|
-
.style("color", row.stroke)
|
|
121
|
-
.style("min-width", this.minWidth_exists() ? this.minWidth() + "px" : null)
|
|
122
|
-
.style("min-height", this.minHeight_exists() ? this.minHeight() + "px" : null)
|
|
123
|
-
.style("font-size", this.iconFontSize() + "px")
|
|
124
|
-
;
|
|
125
|
-
this._headerDiv
|
|
126
|
-
.transition()
|
|
127
|
-
.style("color", row.stroke)
|
|
128
|
-
.style("font-size", this.headerFontSize() + "px")
|
|
129
|
-
[this.valueHTML() ? HTML : TEXT](row.value)
|
|
130
|
-
;
|
|
131
|
-
this._textDiv
|
|
132
|
-
.style("font-size", this.textFontSize() + "px")
|
|
133
|
-
[this.labelHTML() ? HTML : TEXT](row.label)
|
|
134
|
-
;
|
|
135
|
-
const context = this;
|
|
136
|
-
const moreDivs = this._mainDiv.selectAll(".more").data([row]);
|
|
137
|
-
const moreDivsEnter = moreDivs.enter()
|
|
138
|
-
.append("div")
|
|
139
|
-
.attr("class", "more")
|
|
140
|
-
.on("click", function (d) {
|
|
141
|
-
context.click(context.rowToObj(context.currentRow()), context.lookupFieldText("moreTextColumn") || "more", true);
|
|
142
|
-
})
|
|
143
|
-
.each(function () {
|
|
144
|
-
const element2 = d3Select(this);
|
|
145
|
-
element2.append("i");
|
|
146
|
-
element2.append("span");
|
|
147
|
-
})
|
|
148
|
-
;
|
|
149
|
-
const moreDivsUpdate = moreDivsEnter
|
|
150
|
-
.merge(moreDivs)
|
|
151
|
-
.style("display", this.hideMoreWrapper() ? "none" : null)
|
|
152
|
-
.style("font-size", this.moreFontSize() + "px")
|
|
153
|
-
.style("height", this.moreWrapperHeight_exists() ? this.moreWrapperHeight() + "px" : null)
|
|
154
|
-
.transition()
|
|
155
|
-
.style("background-color", d3Rgb(row.fill).darker(0.75).toString())
|
|
156
|
-
;
|
|
157
|
-
moreDivsUpdate
|
|
158
|
-
.select("i")
|
|
159
|
-
.attr("class", function (d) {
|
|
160
|
-
return "fa " + d.moreIcon;
|
|
161
|
-
})
|
|
162
|
-
;
|
|
163
|
-
if (this.moreTextHTML()) {
|
|
164
|
-
moreDivsUpdate.select("span")
|
|
165
|
-
.each(function (d) {
|
|
166
|
-
this.innerHTML = d.moreText;
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
moreDivsUpdate.select("span").text(d => d.moreText);
|
|
170
|
-
}
|
|
171
|
-
moreDivs.exit().remove();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
exit(domNode, element) {
|
|
175
|
-
super.exit(domNode, element);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
Summary.prototype._class += " chart_Summary";
|
|
179
|
-
Summary.prototype.implements(I2DChart.prototype);
|
|
180
|
-
|
|
181
|
-
export interface Summary {
|
|
182
|
-
iconColumn(): string;
|
|
183
|
-
iconColumn(_: string): this;
|
|
184
|
-
iconColumn_exists(): boolean;
|
|
185
|
-
icon(): string;
|
|
186
|
-
icon(_: string): this;
|
|
187
|
-
icon_exists(): boolean;
|
|
188
|
-
|
|
189
|
-
headerFontSize(): number;
|
|
190
|
-
headerFontSize(_: number): this;
|
|
191
|
-
textFontSize(): number;
|
|
192
|
-
textFontSize(_: number): this;
|
|
193
|
-
moreFontSize(): number;
|
|
194
|
-
moreFontSize(_: number): this;
|
|
195
|
-
iconFontSize(): number;
|
|
196
|
-
iconFontSize(_: number): this;
|
|
197
|
-
|
|
198
|
-
hideLabel(): boolean;
|
|
199
|
-
hideLabel(_: boolean): this;
|
|
200
|
-
hideLabel_exists(): boolean;
|
|
201
|
-
labelColumn(): string;
|
|
202
|
-
labelColumn(_: string): this;
|
|
203
|
-
labelColumn_exists(): boolean;
|
|
204
|
-
labelHTML(): boolean;
|
|
205
|
-
labelHTML(_: boolean): this;
|
|
206
|
-
labelHTML_exists(): boolean;
|
|
207
|
-
|
|
208
|
-
valueColumn(): string;
|
|
209
|
-
valueColumn(_: string): this;
|
|
210
|
-
valueColumn_exists(): boolean;
|
|
211
|
-
valueHTML(): boolean;
|
|
212
|
-
valueHTML(_: boolean): this;
|
|
213
|
-
valueHTML_exists(): boolean;
|
|
214
|
-
|
|
215
|
-
hideMore(): boolean;
|
|
216
|
-
hideMore(_: boolean): this;
|
|
217
|
-
hideMore_exists(): boolean;
|
|
218
|
-
hideMoreWrapper(): boolean;
|
|
219
|
-
hideMoreWrapper(_: boolean): this;
|
|
220
|
-
moreWrapperHeight(): number;
|
|
221
|
-
moreWrapperHeight(_: number): this;
|
|
222
|
-
moreWrapperHeight_exists(): boolean;
|
|
223
|
-
moreIconColumn(): string;
|
|
224
|
-
moreIconColumn(_: string): this;
|
|
225
|
-
moreIconColumn_exists(): boolean;
|
|
226
|
-
moreIcon(): string;
|
|
227
|
-
moreIcon(_: string): this;
|
|
228
|
-
moreIcon_exists(): boolean;
|
|
229
|
-
moreTextColumn(): string;
|
|
230
|
-
moreTextColumn(_: string): this;
|
|
231
|
-
moreTextColumn_exists(): boolean;
|
|
232
|
-
moreText(): string;
|
|
233
|
-
moreText(_: string): this;
|
|
234
|
-
moreText_exists(): boolean;
|
|
235
|
-
moreTextHTML(): boolean;
|
|
236
|
-
moreTextHTML(_: boolean): this;
|
|
237
|
-
moreTextHTML_exists(): boolean;
|
|
238
|
-
|
|
239
|
-
colorFillColumn(): string;
|
|
240
|
-
colorFillColumn(_: string): this;
|
|
241
|
-
colorFillColumn_exists(): boolean;
|
|
242
|
-
colorFill(): string;
|
|
243
|
-
colorFill(_: string): this;
|
|
244
|
-
colorFill_exists(): boolean;
|
|
245
|
-
colorStrokeColumn(): string;
|
|
246
|
-
colorStrokeColumn(_: string): this;
|
|
247
|
-
colorStrokeColumn_exists(): boolean;
|
|
248
|
-
colorStroke(): string;
|
|
249
|
-
colorStroke(_: string): this;
|
|
250
|
-
colorStroke_exists(): boolean;
|
|
251
|
-
|
|
252
|
-
fixedSize(): boolean;
|
|
253
|
-
fixedSize(_: boolean): this;
|
|
254
|
-
fixedSize_exists(): boolean;
|
|
255
|
-
minWidth(): number;
|
|
256
|
-
minWidth(_: number): this;
|
|
257
|
-
minWidth_exists(): boolean;
|
|
258
|
-
minHeight(): number;
|
|
259
|
-
minHeight(_: number): this;
|
|
260
|
-
minHeight_exists(): boolean;
|
|
261
|
-
playInterval(): number;
|
|
262
|
-
playInterval(_: number): this;
|
|
263
|
-
playInterval_exists(): boolean;
|
|
264
|
-
|
|
265
|
-
// I2DChart ---
|
|
266
|
-
click(row, column, selected);
|
|
267
|
-
dblclick(row, column, selected);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
Summary.prototype.publish("iconColumn", null, "set", "Select Icon Column", function () { return this.columns(); }, { optional: true });
|
|
271
|
-
Summary.prototype.publish("icon", "fa-briefcase", "string", "FA Char icon class", null, { disable: (w) => w.iconColumn() });
|
|
272
|
-
|
|
273
|
-
Summary.prototype.publish("headerFontSize", null, "number", "headerFontSize");
|
|
274
|
-
Summary.prototype.publish("textFontSize", null, "number", "textFontSize");
|
|
275
|
-
Summary.prototype.publish("moreFontSize", null, "number", "moreFontSize");
|
|
276
|
-
Summary.prototype.publish("iconFontSize", null, "number", "iconFontSize");
|
|
277
|
-
|
|
278
|
-
Summary.prototype.publish("hideLabel", false, "boolean", "Hide label column");
|
|
279
|
-
Summary.prototype.publish("labelColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true, disable: (w) => w.hideLabel() });
|
|
280
|
-
Summary.prototype.publish("labelHTML", false, "boolean", "Allow HTML", null, { disable: (w) => w.hideLabel() });
|
|
281
|
-
|
|
282
|
-
Summary.prototype.publish("valueColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true });
|
|
283
|
-
Summary.prototype.publish("valueHTML", false, "boolean", "Allow HTML");
|
|
284
|
-
|
|
285
|
-
Summary.prototype.publish("hideMore", false, "boolean", "Hide More Information");
|
|
286
|
-
Summary.prototype.publish("hideMoreWrapper", false, "boolean", "Hide More Information Wrapper");
|
|
287
|
-
Summary.prototype.publish("moreWrapperHeight", null, "number", "Height of the 'more' text wrapper (pixels)");
|
|
288
|
-
Summary.prototype.publish("moreIconColumn", null, "set", "Select More Icon Column", function () { return this.columns(); }, { optional: true, disable: (w) => w.hideMore() });
|
|
289
|
-
Summary.prototype.publish("moreIcon", "fa-info-circle", "string", "FA Char icon class", null, { disable: (w) => w.hideMore() || w.moreIconColumn() });
|
|
290
|
-
Summary.prototype.publish("moreTextColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true, disable: (w) => w.hideMore() });
|
|
291
|
-
Summary.prototype.publish("moreText", "More Info", "string", "More text", null, { disable: (w) => w.hideMore() || w.moreTextColumn() });
|
|
292
|
-
Summary.prototype.publish("moreTextHTML", false, "boolean", "Allow HTML", null, { disable: (w) => w.hideMore() });
|
|
293
|
-
|
|
294
|
-
Summary.prototype.publish("colorFillColumn", null, "set", "Column for color", function () { return this.columns(); }, { optional: true });
|
|
295
|
-
Summary.prototype.publish("colorFill", "#3498db", "html-color", "Fill Color", null, { disable: (w) => w.colorFillColumn() });
|
|
296
|
-
Summary.prototype.publish("colorStrokeColumn", null, "set", "Column for color", function () { return this.columns(); }, { optional: true });
|
|
297
|
-
Summary.prototype.publish("colorStroke", "#ffffff", "html-color", "Fill Color", null, { disable: (w) => w.colorStrokeColumn() });
|
|
298
|
-
|
|
299
|
-
Summary.prototype.publish("fixedSize", true, "boolean", "Fix Size to Min Width/Height");
|
|
300
|
-
Summary.prototype.publish("minWidth", 225, "number", "Minimum Width");
|
|
301
|
-
Summary.prototype.publish("minHeight", 150, "number", "Minimum Height");
|
|
302
|
-
Summary.prototype.publish("playInterval", null, "number", "Play Interval", null, { optional: true });
|
|
303
|
-
|
|
304
|
-
const playInterval = Summary.prototype.playInterval;
|
|
305
|
-
Summary.prototype.playInterval = function (_?: number): number | any {
|
|
306
|
-
const retVal = playInterval.apply(this, arguments);
|
|
307
|
-
if (arguments.length) {
|
|
308
|
-
if (this._playIntervalHandle) {
|
|
309
|
-
clearInterval(this._playIntervalHandle);
|
|
310
|
-
}
|
|
311
|
-
const context = this;
|
|
312
|
-
if (_) {
|
|
313
|
-
this._playIntervalHandle = setInterval(function () {
|
|
314
|
-
context._playIntervalIdx++;
|
|
315
|
-
if (context._renderCount && context.data().length) {
|
|
316
|
-
context.render();
|
|
317
|
-
}
|
|
318
|
-
}, _);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return retVal;
|
|
322
|
-
};
|
|
1
|
+
import { I2DChart } from "@hpcc-js/api";
|
|
2
|
+
import { HTMLWidget } from "@hpcc-js/common";
|
|
3
|
+
import { rgb as d3Rgb } from "d3-color";
|
|
4
|
+
import { select as d3Select } from "d3-selection";
|
|
5
|
+
|
|
6
|
+
import "../src/Summary.css";
|
|
7
|
+
|
|
8
|
+
const TEXT = "text";
|
|
9
|
+
const HTML = "html";
|
|
10
|
+
|
|
11
|
+
export class Summary extends HTMLWidget {
|
|
12
|
+
protected _playIntervalIdx = 0;
|
|
13
|
+
protected _mainDiv;
|
|
14
|
+
protected _headerDiv;
|
|
15
|
+
protected _textDiv;
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this._tag = "div";
|
|
20
|
+
|
|
21
|
+
this._drawStartPos = "center";
|
|
22
|
+
this.playInterval(this.playInterval());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
lookupFieldIdx(propID, defaultIdx?: number) {
|
|
26
|
+
let retVal = defaultIdx;
|
|
27
|
+
if (this[propID + "_exists"]()) {
|
|
28
|
+
retVal = this.columns().indexOf(this[propID]());
|
|
29
|
+
if (retVal < 0) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return retVal;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
lookupFieldText(propID, defaultIdx?: number) {
|
|
37
|
+
if (this[propID + "_exists"]()) {
|
|
38
|
+
return this[propID]();
|
|
39
|
+
}
|
|
40
|
+
if (defaultIdx !== undefined) {
|
|
41
|
+
return this.columns()[defaultIdx] || "";
|
|
42
|
+
}
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
currentRow() {
|
|
47
|
+
return this.data()[this._playIntervalIdx];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
summaryData() {
|
|
51
|
+
let labelFieldIdx; // undefined
|
|
52
|
+
if (!this.hideLabel()) {
|
|
53
|
+
labelFieldIdx = this.lookupFieldIdx("labelColumn", 0);
|
|
54
|
+
}
|
|
55
|
+
const iconFieldIdx = this.lookupFieldIdx("iconColumn");
|
|
56
|
+
const valueFieldIdx = this.lookupFieldIdx("valueColumn", 1);
|
|
57
|
+
let moreIconIdx; // undefined
|
|
58
|
+
let moreTextIdx; // undefined
|
|
59
|
+
if (!this.hideMore()) {
|
|
60
|
+
moreIconIdx = this.lookupFieldIdx("moreIconColumn");
|
|
61
|
+
moreTextIdx = this.lookupFieldIdx("moreTextColumn");
|
|
62
|
+
}
|
|
63
|
+
const colorFillIdx = this.lookupFieldIdx("colorFillColumn");
|
|
64
|
+
const colorStrokeIdx = this.lookupFieldIdx("colorStrokeColumn");
|
|
65
|
+
return this.formattedData().map(function (row) {
|
|
66
|
+
return {
|
|
67
|
+
icon: iconFieldIdx === undefined ? this.icon() : row[iconFieldIdx],
|
|
68
|
+
label: labelFieldIdx === undefined ? "" : row[labelFieldIdx],
|
|
69
|
+
value: row[valueFieldIdx],
|
|
70
|
+
moreIcon: moreIconIdx === undefined ? (this.hideMore() ? "" : this.moreIcon()) : row[moreIconIdx],
|
|
71
|
+
moreText: moreTextIdx === undefined ? (this.hideMore() ? "" : this.moreText()) : row[moreTextIdx],
|
|
72
|
+
fill: colorFillIdx === undefined ? this.colorFill() : row[colorFillIdx],
|
|
73
|
+
stroke: colorStrokeIdx === undefined ? this.colorStroke() : row[colorStrokeIdx]
|
|
74
|
+
};
|
|
75
|
+
}, this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
enter(domNode, element) {
|
|
79
|
+
super.enter(domNode, element);
|
|
80
|
+
this._mainDiv = element.append("div")
|
|
81
|
+
;
|
|
82
|
+
const context = this;
|
|
83
|
+
this._headerDiv = this._mainDiv.append("h2")
|
|
84
|
+
.on("click", function () {
|
|
85
|
+
context.click(context.rowToObj(context.currentRow()), context.lookupFieldText("valueColumn", 1), true);
|
|
86
|
+
})
|
|
87
|
+
.on("dblclick", function () {
|
|
88
|
+
context.dblclick(context.rowToObj(context.currentRow()), context.lookupFieldText("valueColumn", 1), true);
|
|
89
|
+
})
|
|
90
|
+
;
|
|
91
|
+
this._textDiv = this._mainDiv.append("div")
|
|
92
|
+
.attr("class", "text")
|
|
93
|
+
.on("click", function () {
|
|
94
|
+
context.click(context.rowToObj(context.currentRow()), context.lookupFieldText("labelColumn", 0), true);
|
|
95
|
+
})
|
|
96
|
+
.on("dblclick", function () {
|
|
97
|
+
context.dblclick(context.rowToObj(context.currentRow()), context.lookupFieldText("labelColumn", 0), true);
|
|
98
|
+
})
|
|
99
|
+
;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
update(domNode, element) {
|
|
103
|
+
super.update(domNode, element);
|
|
104
|
+
if (this.data().length) {
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
const data = this.summaryData();
|
|
108
|
+
if (this._playIntervalIdx >= data.length) {
|
|
109
|
+
this._playIntervalIdx = 0;
|
|
110
|
+
}
|
|
111
|
+
const row: any = this._playIntervalIdx < data.length ? data[this._playIntervalIdx] : ["", ""];
|
|
112
|
+
element
|
|
113
|
+
.style("width", this.fixedSize() ? this.minWidth_exists() ? this.minWidth() + "px" : null : "100%")
|
|
114
|
+
.style("height", this.fixedSize() ? this.minHeight_exists() ? this.minHeight() + "px" : null : "100%")
|
|
115
|
+
;
|
|
116
|
+
this._mainDiv
|
|
117
|
+
.attr("class", "content bgIcon " + row.icon)
|
|
118
|
+
.transition()
|
|
119
|
+
.style("background-color", row.fill)
|
|
120
|
+
.style("color", row.stroke)
|
|
121
|
+
.style("min-width", this.minWidth_exists() ? this.minWidth() + "px" : null)
|
|
122
|
+
.style("min-height", this.minHeight_exists() ? this.minHeight() + "px" : null)
|
|
123
|
+
.style("font-size", this.iconFontSize() + "px")
|
|
124
|
+
;
|
|
125
|
+
this._headerDiv
|
|
126
|
+
.transition()
|
|
127
|
+
.style("color", row.stroke)
|
|
128
|
+
.style("font-size", this.headerFontSize() + "px")
|
|
129
|
+
[this.valueHTML() ? HTML : TEXT](row.value)
|
|
130
|
+
;
|
|
131
|
+
this._textDiv
|
|
132
|
+
.style("font-size", this.textFontSize() + "px")
|
|
133
|
+
[this.labelHTML() ? HTML : TEXT](row.label)
|
|
134
|
+
;
|
|
135
|
+
const context = this;
|
|
136
|
+
const moreDivs = this._mainDiv.selectAll(".more").data([row]);
|
|
137
|
+
const moreDivsEnter = moreDivs.enter()
|
|
138
|
+
.append("div")
|
|
139
|
+
.attr("class", "more")
|
|
140
|
+
.on("click", function (d) {
|
|
141
|
+
context.click(context.rowToObj(context.currentRow()), context.lookupFieldText("moreTextColumn") || "more", true);
|
|
142
|
+
})
|
|
143
|
+
.each(function () {
|
|
144
|
+
const element2 = d3Select(this);
|
|
145
|
+
element2.append("i");
|
|
146
|
+
element2.append("span");
|
|
147
|
+
})
|
|
148
|
+
;
|
|
149
|
+
const moreDivsUpdate = moreDivsEnter
|
|
150
|
+
.merge(moreDivs)
|
|
151
|
+
.style("display", this.hideMoreWrapper() ? "none" : null)
|
|
152
|
+
.style("font-size", this.moreFontSize() + "px")
|
|
153
|
+
.style("height", this.moreWrapperHeight_exists() ? this.moreWrapperHeight() + "px" : null)
|
|
154
|
+
.transition()
|
|
155
|
+
.style("background-color", d3Rgb(row.fill).darker(0.75).toString())
|
|
156
|
+
;
|
|
157
|
+
moreDivsUpdate
|
|
158
|
+
.select("i")
|
|
159
|
+
.attr("class", function (d) {
|
|
160
|
+
return "fa " + d.moreIcon;
|
|
161
|
+
})
|
|
162
|
+
;
|
|
163
|
+
if (this.moreTextHTML()) {
|
|
164
|
+
moreDivsUpdate.select("span")
|
|
165
|
+
.each(function (d) {
|
|
166
|
+
this.innerHTML = d.moreText;
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
moreDivsUpdate.select("span").text(d => d.moreText);
|
|
170
|
+
}
|
|
171
|
+
moreDivs.exit().remove();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
exit(domNode, element) {
|
|
175
|
+
super.exit(domNode, element);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
Summary.prototype._class += " chart_Summary";
|
|
179
|
+
Summary.prototype.implements(I2DChart.prototype);
|
|
180
|
+
|
|
181
|
+
export interface Summary {
|
|
182
|
+
iconColumn(): string;
|
|
183
|
+
iconColumn(_: string): this;
|
|
184
|
+
iconColumn_exists(): boolean;
|
|
185
|
+
icon(): string;
|
|
186
|
+
icon(_: string): this;
|
|
187
|
+
icon_exists(): boolean;
|
|
188
|
+
|
|
189
|
+
headerFontSize(): number;
|
|
190
|
+
headerFontSize(_: number): this;
|
|
191
|
+
textFontSize(): number;
|
|
192
|
+
textFontSize(_: number): this;
|
|
193
|
+
moreFontSize(): number;
|
|
194
|
+
moreFontSize(_: number): this;
|
|
195
|
+
iconFontSize(): number;
|
|
196
|
+
iconFontSize(_: number): this;
|
|
197
|
+
|
|
198
|
+
hideLabel(): boolean;
|
|
199
|
+
hideLabel(_: boolean): this;
|
|
200
|
+
hideLabel_exists(): boolean;
|
|
201
|
+
labelColumn(): string;
|
|
202
|
+
labelColumn(_: string): this;
|
|
203
|
+
labelColumn_exists(): boolean;
|
|
204
|
+
labelHTML(): boolean;
|
|
205
|
+
labelHTML(_: boolean): this;
|
|
206
|
+
labelHTML_exists(): boolean;
|
|
207
|
+
|
|
208
|
+
valueColumn(): string;
|
|
209
|
+
valueColumn(_: string): this;
|
|
210
|
+
valueColumn_exists(): boolean;
|
|
211
|
+
valueHTML(): boolean;
|
|
212
|
+
valueHTML(_: boolean): this;
|
|
213
|
+
valueHTML_exists(): boolean;
|
|
214
|
+
|
|
215
|
+
hideMore(): boolean;
|
|
216
|
+
hideMore(_: boolean): this;
|
|
217
|
+
hideMore_exists(): boolean;
|
|
218
|
+
hideMoreWrapper(): boolean;
|
|
219
|
+
hideMoreWrapper(_: boolean): this;
|
|
220
|
+
moreWrapperHeight(): number;
|
|
221
|
+
moreWrapperHeight(_: number): this;
|
|
222
|
+
moreWrapperHeight_exists(): boolean;
|
|
223
|
+
moreIconColumn(): string;
|
|
224
|
+
moreIconColumn(_: string): this;
|
|
225
|
+
moreIconColumn_exists(): boolean;
|
|
226
|
+
moreIcon(): string;
|
|
227
|
+
moreIcon(_: string): this;
|
|
228
|
+
moreIcon_exists(): boolean;
|
|
229
|
+
moreTextColumn(): string;
|
|
230
|
+
moreTextColumn(_: string): this;
|
|
231
|
+
moreTextColumn_exists(): boolean;
|
|
232
|
+
moreText(): string;
|
|
233
|
+
moreText(_: string): this;
|
|
234
|
+
moreText_exists(): boolean;
|
|
235
|
+
moreTextHTML(): boolean;
|
|
236
|
+
moreTextHTML(_: boolean): this;
|
|
237
|
+
moreTextHTML_exists(): boolean;
|
|
238
|
+
|
|
239
|
+
colorFillColumn(): string;
|
|
240
|
+
colorFillColumn(_: string): this;
|
|
241
|
+
colorFillColumn_exists(): boolean;
|
|
242
|
+
colorFill(): string;
|
|
243
|
+
colorFill(_: string): this;
|
|
244
|
+
colorFill_exists(): boolean;
|
|
245
|
+
colorStrokeColumn(): string;
|
|
246
|
+
colorStrokeColumn(_: string): this;
|
|
247
|
+
colorStrokeColumn_exists(): boolean;
|
|
248
|
+
colorStroke(): string;
|
|
249
|
+
colorStroke(_: string): this;
|
|
250
|
+
colorStroke_exists(): boolean;
|
|
251
|
+
|
|
252
|
+
fixedSize(): boolean;
|
|
253
|
+
fixedSize(_: boolean): this;
|
|
254
|
+
fixedSize_exists(): boolean;
|
|
255
|
+
minWidth(): number;
|
|
256
|
+
minWidth(_: number): this;
|
|
257
|
+
minWidth_exists(): boolean;
|
|
258
|
+
minHeight(): number;
|
|
259
|
+
minHeight(_: number): this;
|
|
260
|
+
minHeight_exists(): boolean;
|
|
261
|
+
playInterval(): number;
|
|
262
|
+
playInterval(_: number): this;
|
|
263
|
+
playInterval_exists(): boolean;
|
|
264
|
+
|
|
265
|
+
// I2DChart ---
|
|
266
|
+
click(row, column, selected);
|
|
267
|
+
dblclick(row, column, selected);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
Summary.prototype.publish("iconColumn", null, "set", "Select Icon Column", function () { return this.columns(); }, { optional: true });
|
|
271
|
+
Summary.prototype.publish("icon", "fa-briefcase", "string", "FA Char icon class", null, { disable: (w) => w.iconColumn() });
|
|
272
|
+
|
|
273
|
+
Summary.prototype.publish("headerFontSize", null, "number", "headerFontSize");
|
|
274
|
+
Summary.prototype.publish("textFontSize", null, "number", "textFontSize");
|
|
275
|
+
Summary.prototype.publish("moreFontSize", null, "number", "moreFontSize");
|
|
276
|
+
Summary.prototype.publish("iconFontSize", null, "number", "iconFontSize");
|
|
277
|
+
|
|
278
|
+
Summary.prototype.publish("hideLabel", false, "boolean", "Hide label column");
|
|
279
|
+
Summary.prototype.publish("labelColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true, disable: (w) => w.hideLabel() });
|
|
280
|
+
Summary.prototype.publish("labelHTML", false, "boolean", "Allow HTML", null, { disable: (w) => w.hideLabel() });
|
|
281
|
+
|
|
282
|
+
Summary.prototype.publish("valueColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true });
|
|
283
|
+
Summary.prototype.publish("valueHTML", false, "boolean", "Allow HTML");
|
|
284
|
+
|
|
285
|
+
Summary.prototype.publish("hideMore", false, "boolean", "Hide More Information");
|
|
286
|
+
Summary.prototype.publish("hideMoreWrapper", false, "boolean", "Hide More Information Wrapper");
|
|
287
|
+
Summary.prototype.publish("moreWrapperHeight", null, "number", "Height of the 'more' text wrapper (pixels)");
|
|
288
|
+
Summary.prototype.publish("moreIconColumn", null, "set", "Select More Icon Column", function () { return this.columns(); }, { optional: true, disable: (w) => w.hideMore() });
|
|
289
|
+
Summary.prototype.publish("moreIcon", "fa-info-circle", "string", "FA Char icon class", null, { disable: (w) => w.hideMore() || w.moreIconColumn() });
|
|
290
|
+
Summary.prototype.publish("moreTextColumn", null, "set", "Select display value", function () { return this.columns(); }, { optional: true, disable: (w) => w.hideMore() });
|
|
291
|
+
Summary.prototype.publish("moreText", "More Info", "string", "More text", null, { disable: (w) => w.hideMore() || w.moreTextColumn() });
|
|
292
|
+
Summary.prototype.publish("moreTextHTML", false, "boolean", "Allow HTML", null, { disable: (w) => w.hideMore() });
|
|
293
|
+
|
|
294
|
+
Summary.prototype.publish("colorFillColumn", null, "set", "Column for color", function () { return this.columns(); }, { optional: true });
|
|
295
|
+
Summary.prototype.publish("colorFill", "#3498db", "html-color", "Fill Color", null, { disable: (w) => w.colorFillColumn() });
|
|
296
|
+
Summary.prototype.publish("colorStrokeColumn", null, "set", "Column for color", function () { return this.columns(); }, { optional: true });
|
|
297
|
+
Summary.prototype.publish("colorStroke", "#ffffff", "html-color", "Fill Color", null, { disable: (w) => w.colorStrokeColumn() });
|
|
298
|
+
|
|
299
|
+
Summary.prototype.publish("fixedSize", true, "boolean", "Fix Size to Min Width/Height");
|
|
300
|
+
Summary.prototype.publish("minWidth", 225, "number", "Minimum Width");
|
|
301
|
+
Summary.prototype.publish("minHeight", 150, "number", "Minimum Height");
|
|
302
|
+
Summary.prototype.publish("playInterval", null, "number", "Play Interval", null, { optional: true });
|
|
303
|
+
|
|
304
|
+
const playInterval = Summary.prototype.playInterval;
|
|
305
|
+
Summary.prototype.playInterval = function (_?: number): number | any {
|
|
306
|
+
const retVal = playInterval.apply(this, arguments);
|
|
307
|
+
if (arguments.length) {
|
|
308
|
+
if (this._playIntervalHandle) {
|
|
309
|
+
clearInterval(this._playIntervalHandle);
|
|
310
|
+
}
|
|
311
|
+
const context = this;
|
|
312
|
+
if (_) {
|
|
313
|
+
this._playIntervalHandle = setInterval(function () {
|
|
314
|
+
context._playIntervalIdx++;
|
|
315
|
+
if (context._renderCount && context.data().length) {
|
|
316
|
+
context.render();
|
|
317
|
+
}
|
|
318
|
+
}, _);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return retVal;
|
|
322
|
+
};
|