@hpcc-js/chart 3.7.4 → 3.7.6
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 +9 -7
- 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/WordCloud.ts
CHANGED
|
@@ -1,268 +1,268 @@
|
|
|
1
|
-
import { I2DChart, ITooltip } from "@hpcc-js/api";
|
|
2
|
-
import { d3Event, InputField, SVGWidget, Utility, zoom as d3Zoom } from "@hpcc-js/common";
|
|
3
|
-
import { extent as d3Extent } from "d3-array";
|
|
4
|
-
import { scaleLinear as d3ScaleLinear, scaleLog as d3ScaleLog, scalePow as d3ScalePow, scaleSqrt as d3ScaleSqrt } from "d3-scale";
|
|
5
|
-
import { d3Cloud } from "./D3Cloud.ts";
|
|
6
|
-
|
|
7
|
-
import "../src/WordCloud.css";
|
|
8
|
-
|
|
9
|
-
export class WordCloud extends SVGWidget {
|
|
10
|
-
static __inputs: InputField[] = [{
|
|
11
|
-
id: "label",
|
|
12
|
-
type: "string"
|
|
13
|
-
}, {
|
|
14
|
-
id: "value",
|
|
15
|
-
type: "number"
|
|
16
|
-
}];
|
|
17
|
-
|
|
18
|
-
private _prevOffsetX;
|
|
19
|
-
private _prevOffsetY;
|
|
20
|
-
private _prevZoom;
|
|
21
|
-
private _root;
|
|
22
|
-
private _canvas;
|
|
23
|
-
private _d3Cloud;
|
|
24
|
-
private _d3Zoom;
|
|
25
|
-
|
|
26
|
-
constructor() {
|
|
27
|
-
super();
|
|
28
|
-
I2DChart.call(this);
|
|
29
|
-
ITooltip.call(this);
|
|
30
|
-
Utility.SimpleSelectionMixin.call(this);
|
|
31
|
-
|
|
32
|
-
this._prevOffsetX = this.offsetX();
|
|
33
|
-
this._prevOffsetY = this.offsetY();
|
|
34
|
-
this._prevZoom = this.zoom();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
calcData() {
|
|
38
|
-
return this.data().map(row => {
|
|
39
|
-
return {
|
|
40
|
-
__viz_label: row[0],
|
|
41
|
-
__viz_weight: row[1],
|
|
42
|
-
__viz_row: row
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
enter(domNode, element) {
|
|
48
|
-
super.enter(domNode, element);
|
|
49
|
-
this._selection.widgetElement(element);
|
|
50
|
-
|
|
51
|
-
this._root = element.append("g");
|
|
52
|
-
this._canvas = document.createElement("canvas");
|
|
53
|
-
|
|
54
|
-
const context = this;
|
|
55
|
-
this._d3Zoom = d3Zoom()
|
|
56
|
-
.scaleExtent([0.1, 10])
|
|
57
|
-
;
|
|
58
|
-
this._d3Zoom
|
|
59
|
-
.on("zoom", function (evt) {
|
|
60
|
-
const event = d3Event();
|
|
61
|
-
if (event && event.transform) {
|
|
62
|
-
context.zoomed(context._d3Zoom, [event.transform.x, event.transform.y], event.transform.k);
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
;
|
|
66
|
-
element.call(this._d3Zoom);
|
|
67
|
-
|
|
68
|
-
this
|
|
69
|
-
.tooltipHTML(function (d) {
|
|
70
|
-
const columns = context.columns();
|
|
71
|
-
const series = columns && columns.length ? columns[0] : "Word";
|
|
72
|
-
return context.tooltipFormat({ label: d.__viz_label, series, value: d.__viz_weight });
|
|
73
|
-
})
|
|
74
|
-
;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
update(domNode, element) {
|
|
78
|
-
super.update(domNode, element);
|
|
79
|
-
|
|
80
|
-
this._palette = this._palette.switch(this.paletteID());
|
|
81
|
-
if (this.useClonedPalette()) {
|
|
82
|
-
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this._d3Cloud = d3Cloud()
|
|
86
|
-
.canvas(() => this._canvas)
|
|
87
|
-
;
|
|
88
|
-
|
|
89
|
-
this.zoomed(this, [this.offsetX(), this.offsetY()], this.zoom());
|
|
90
|
-
|
|
91
|
-
const data = this.calcData();
|
|
92
|
-
const context = this;
|
|
93
|
-
const extent = d3Extent(data, function (d: any) { return d.__viz_weight; });
|
|
94
|
-
let scaler;
|
|
95
|
-
switch (this.scaleMode()) {
|
|
96
|
-
case "log":
|
|
97
|
-
scaler = d3ScaleLog;
|
|
98
|
-
break;
|
|
99
|
-
case "sqrt":
|
|
100
|
-
scaler = d3ScaleSqrt;
|
|
101
|
-
break;
|
|
102
|
-
case "pow":
|
|
103
|
-
scaler = d3ScalePow;
|
|
104
|
-
break;
|
|
105
|
-
case "linear":
|
|
106
|
-
default:
|
|
107
|
-
scaler = d3ScaleLinear;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
const scale = scaler().domain(extent).range([this.fontSizeFrom(), this.fontSizeTo()]);
|
|
111
|
-
const angleDomain = d3ScaleLinear().domain([0, context.angleCount() - 1]).range([context.angleFrom(), context.angleTo()]);
|
|
112
|
-
|
|
113
|
-
this._d3Cloud.stop()
|
|
114
|
-
.size([this.width(), this.height()])
|
|
115
|
-
.words(data)
|
|
116
|
-
.font(this.fontFamily())
|
|
117
|
-
.padding(this.padding())
|
|
118
|
-
.spiral(this.spiral())
|
|
119
|
-
.text(function (d) {
|
|
120
|
-
return d.__viz_label.trim();
|
|
121
|
-
})
|
|
122
|
-
.fontSize(function (d) {
|
|
123
|
-
return scale(d.__viz_weight);
|
|
124
|
-
})
|
|
125
|
-
.rotate((d, i) => angleDomain(i % context.angleCount()))
|
|
126
|
-
.on("word", w => {
|
|
127
|
-
})
|
|
128
|
-
.on("end", draw)
|
|
129
|
-
.start()
|
|
130
|
-
;
|
|
131
|
-
|
|
132
|
-
function draw(data, bounds) {
|
|
133
|
-
const text = context._root.selectAll("text")
|
|
134
|
-
.data(data, function (d) { return d.__viz_label ? d.__viz_label.toLowerCase() : ""; })
|
|
135
|
-
;
|
|
136
|
-
text.enter().append("text")
|
|
137
|
-
.attr("text-anchor", "middle")
|
|
138
|
-
.call(context._selection.enter.bind(context._selection))
|
|
139
|
-
.text(function (d) { return d.__viz_label; })
|
|
140
|
-
.on("click", function (d) {
|
|
141
|
-
context.click(context.rowToObj(d.__viz_row), context.columns()[1], context._selection.selected(this));
|
|
142
|
-
})
|
|
143
|
-
.on("dblclick", function (d) {
|
|
144
|
-
context.dblclick(context.rowToObj(d.__viz_row), context.columns()[1], context._selection.selected(this));
|
|
145
|
-
})
|
|
146
|
-
.on("mouseout.tooltip", context.tooltip.hide)
|
|
147
|
-
.on("mousemove.tooltip", context.tooltip.show)
|
|
148
|
-
.style("opacity", 1e-6)
|
|
149
|
-
.merge(text)
|
|
150
|
-
.style("font-size", function (d) { return scale(d.__viz_weight) + "px"; })
|
|
151
|
-
.style("font-family", context.fontFamily())
|
|
152
|
-
.transition().duration(1000)
|
|
153
|
-
.attr("transform", function (d) { return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")"; })
|
|
154
|
-
.style("fill", function (d) { return context._palette(d.__viz_label ? d.__viz_label.toLowerCase() : ""); })
|
|
155
|
-
.style("opacity", 1)
|
|
156
|
-
;
|
|
157
|
-
text.exit().transition().duration(1000)
|
|
158
|
-
.style("opacity", 1e-4)
|
|
159
|
-
.remove()
|
|
160
|
-
;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
zoomed(source, translate, scale) {
|
|
165
|
-
if (translate[0] !== this._prevOffsetX || translate[1] !== this._prevOffsetY || scale !== this._prevZoom) {
|
|
166
|
-
this._root.attr("transform", translate);
|
|
167
|
-
switch (source) {
|
|
168
|
-
case this:
|
|
169
|
-
/*
|
|
170
|
-
this._d3Zoom
|
|
171
|
-
.scale(scale)
|
|
172
|
-
.translate(translate)
|
|
173
|
-
;
|
|
174
|
-
*/
|
|
175
|
-
break;
|
|
176
|
-
case this._d3Zoom:
|
|
177
|
-
this.offsetX(translate[0]);
|
|
178
|
-
this.offsetY(translate[1]);
|
|
179
|
-
this.zoom(scale);
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
this._prevOffsetX = translate[0];
|
|
183
|
-
this._prevOffsetY = translate[1];
|
|
184
|
-
this._prevZoom = scale;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
WordCloud.prototype._class += " chart_WordCloud";
|
|
189
|
-
WordCloud.prototype.implements(I2DChart.prototype);
|
|
190
|
-
WordCloud.prototype.implements(ITooltip.prototype);
|
|
191
|
-
WordCloud.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
192
|
-
|
|
193
|
-
export interface WordCloud {
|
|
194
|
-
|
|
195
|
-
paletteID(): string;
|
|
196
|
-
paletteID(_: string): this;
|
|
197
|
-
useClonedPalette(): boolean;
|
|
198
|
-
useClonedPalette(_: boolean): this;
|
|
199
|
-
fontFamily(): string;
|
|
200
|
-
fontFamily(_: string): this;
|
|
201
|
-
fontSizeFrom(): number;
|
|
202
|
-
fontSizeFrom(_: number): this;
|
|
203
|
-
fontSizeTo(): number;
|
|
204
|
-
fontSizeTo(_: number): this;
|
|
205
|
-
angleFrom(): number;
|
|
206
|
-
angleFrom(_: number): this;
|
|
207
|
-
angleTo(): number;
|
|
208
|
-
angleTo(_: number): this;
|
|
209
|
-
angleCount(): number;
|
|
210
|
-
angleCount(_: number): this;
|
|
211
|
-
padding(): number;
|
|
212
|
-
padding(_: number): this;
|
|
213
|
-
scaleMode(): string;
|
|
214
|
-
scaleMode(_: string): this;
|
|
215
|
-
spiral(): string;
|
|
216
|
-
spiral(_: string): this;
|
|
217
|
-
offsetX(): number;
|
|
218
|
-
offsetX(_: number): this;
|
|
219
|
-
offsetY(): number;
|
|
220
|
-
offsetY(_: number): this;
|
|
221
|
-
zoom(): number;
|
|
222
|
-
zoom(_: number): this;
|
|
223
|
-
zoom_exists(): boolean;
|
|
224
|
-
|
|
225
|
-
// I2DChart
|
|
226
|
-
_palette;
|
|
227
|
-
click(row, column, selected): void;
|
|
228
|
-
dblclick(row, column, selected): void;
|
|
229
|
-
|
|
230
|
-
// ITooltip ---
|
|
231
|
-
tooltip;
|
|
232
|
-
tooltipHTML(_?): any;
|
|
233
|
-
tooltipFormat(opts): any;
|
|
234
|
-
tooltipStyle(): string;
|
|
235
|
-
tooltipStyle(_: string): this;
|
|
236
|
-
tooltipValueFormat(): string;
|
|
237
|
-
tooltipValueFormat(_: string): this;
|
|
238
|
-
tooltipSeriesColor(): string;
|
|
239
|
-
tooltipSeriesColor(_: string): this;
|
|
240
|
-
tooltipLabelColor(): string;
|
|
241
|
-
tooltipLabelColor(_: string): this;
|
|
242
|
-
tooltipValueColor(): string;
|
|
243
|
-
tooltipValueColor(_: string): this;
|
|
244
|
-
tooltipTick(): boolean;
|
|
245
|
-
tooltipTick(_: boolean): this;
|
|
246
|
-
tooltipOffset(): number;
|
|
247
|
-
tooltipOffset(_: number): this;
|
|
248
|
-
tooltipOffset_exists(): boolean;
|
|
249
|
-
|
|
250
|
-
// SimpleSelectionMixin
|
|
251
|
-
_selection: Utility.SimpleSelection;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
WordCloud.prototype.publish("paletteID", "default", "set", "Color palette for this widget", WordCloud.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
255
|
-
WordCloud.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
256
|
-
|
|
257
|
-
WordCloud.prototype.publish("fontFamily", "Impact", "string", "Font Name", null, { tags: ["Basic"] });
|
|
258
|
-
WordCloud.prototype.publish("fontSizeFrom", 6, "number", "Minimum font size (pixels)", null, { tags: ["Basic"] });
|
|
259
|
-
WordCloud.prototype.publish("fontSizeTo", 48, "number", "Maximum font size (pixels)", null, { tags: ["Basic"] });
|
|
260
|
-
WordCloud.prototype.publish("angleFrom", -60, "number", "Minimum angle (degrees)", null, { tags: ["Basic"] });
|
|
261
|
-
WordCloud.prototype.publish("angleTo", 60, "number", "Maximum angle (degrees)", null, { tags: ["Basic"] });
|
|
262
|
-
WordCloud.prototype.publish("angleCount", 5, "number", "Number of different angles", null, { tags: ["Basic"] });
|
|
263
|
-
WordCloud.prototype.publish("padding", 0, "number", "Padding between words (pixels)", null, { tags: ["Intermediate"] });
|
|
264
|
-
WordCloud.prototype.publish("scaleMode", "linear", "set", "Text scaling mode", ["linear", "log", "sqrt", "pow"], { tags: ["Intermediate"] });
|
|
265
|
-
WordCloud.prototype.publish("spiral", "archimedean", "set", "Text scaling mode", ["archimedean", "rectangular"], { tags: ["Intermediate"] });
|
|
266
|
-
WordCloud.prototype.publish("offsetX", 0, "number", "X offset", null, { tags: ["Advanced"] });
|
|
267
|
-
WordCloud.prototype.publish("offsetY", 0, "number", "Y offset", null, { tags: ["Advanced"] });
|
|
268
|
-
WordCloud.prototype.publish("zoom", 1, "number", "Zoom", null, { tags: ["Advanced"] });
|
|
1
|
+
import { I2DChart, ITooltip } from "@hpcc-js/api";
|
|
2
|
+
import { d3Event, InputField, SVGWidget, Utility, zoom as d3Zoom } from "@hpcc-js/common";
|
|
3
|
+
import { extent as d3Extent } from "d3-array";
|
|
4
|
+
import { scaleLinear as d3ScaleLinear, scaleLog as d3ScaleLog, scalePow as d3ScalePow, scaleSqrt as d3ScaleSqrt } from "d3-scale";
|
|
5
|
+
import { d3Cloud } from "./D3Cloud.ts";
|
|
6
|
+
|
|
7
|
+
import "../src/WordCloud.css";
|
|
8
|
+
|
|
9
|
+
export class WordCloud extends SVGWidget {
|
|
10
|
+
static __inputs: InputField[] = [{
|
|
11
|
+
id: "label",
|
|
12
|
+
type: "string"
|
|
13
|
+
}, {
|
|
14
|
+
id: "value",
|
|
15
|
+
type: "number"
|
|
16
|
+
}];
|
|
17
|
+
|
|
18
|
+
private _prevOffsetX;
|
|
19
|
+
private _prevOffsetY;
|
|
20
|
+
private _prevZoom;
|
|
21
|
+
private _root;
|
|
22
|
+
private _canvas;
|
|
23
|
+
private _d3Cloud;
|
|
24
|
+
private _d3Zoom;
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
I2DChart.call(this);
|
|
29
|
+
ITooltip.call(this);
|
|
30
|
+
Utility.SimpleSelectionMixin.call(this);
|
|
31
|
+
|
|
32
|
+
this._prevOffsetX = this.offsetX();
|
|
33
|
+
this._prevOffsetY = this.offsetY();
|
|
34
|
+
this._prevZoom = this.zoom();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
calcData() {
|
|
38
|
+
return this.data().map(row => {
|
|
39
|
+
return {
|
|
40
|
+
__viz_label: row[0],
|
|
41
|
+
__viz_weight: row[1],
|
|
42
|
+
__viz_row: row
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
enter(domNode, element) {
|
|
48
|
+
super.enter(domNode, element);
|
|
49
|
+
this._selection.widgetElement(element);
|
|
50
|
+
|
|
51
|
+
this._root = element.append("g");
|
|
52
|
+
this._canvas = document.createElement("canvas");
|
|
53
|
+
|
|
54
|
+
const context = this;
|
|
55
|
+
this._d3Zoom = d3Zoom()
|
|
56
|
+
.scaleExtent([0.1, 10])
|
|
57
|
+
;
|
|
58
|
+
this._d3Zoom
|
|
59
|
+
.on("zoom", function (evt) {
|
|
60
|
+
const event = d3Event();
|
|
61
|
+
if (event && event.transform) {
|
|
62
|
+
context.zoomed(context._d3Zoom, [event.transform.x, event.transform.y], event.transform.k);
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
;
|
|
66
|
+
element.call(this._d3Zoom);
|
|
67
|
+
|
|
68
|
+
this
|
|
69
|
+
.tooltipHTML(function (d) {
|
|
70
|
+
const columns = context.columns();
|
|
71
|
+
const series = columns && columns.length ? columns[0] : "Word";
|
|
72
|
+
return context.tooltipFormat({ label: d.__viz_label, series, value: d.__viz_weight });
|
|
73
|
+
})
|
|
74
|
+
;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
update(domNode, element) {
|
|
78
|
+
super.update(domNode, element);
|
|
79
|
+
|
|
80
|
+
this._palette = this._palette.switch(this.paletteID());
|
|
81
|
+
if (this.useClonedPalette()) {
|
|
82
|
+
this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this._d3Cloud = d3Cloud()
|
|
86
|
+
.canvas(() => this._canvas)
|
|
87
|
+
;
|
|
88
|
+
|
|
89
|
+
this.zoomed(this, [this.offsetX(), this.offsetY()], this.zoom());
|
|
90
|
+
|
|
91
|
+
const data = this.calcData();
|
|
92
|
+
const context = this;
|
|
93
|
+
const extent = d3Extent(data, function (d: any) { return d.__viz_weight; });
|
|
94
|
+
let scaler;
|
|
95
|
+
switch (this.scaleMode()) {
|
|
96
|
+
case "log":
|
|
97
|
+
scaler = d3ScaleLog;
|
|
98
|
+
break;
|
|
99
|
+
case "sqrt":
|
|
100
|
+
scaler = d3ScaleSqrt;
|
|
101
|
+
break;
|
|
102
|
+
case "pow":
|
|
103
|
+
scaler = d3ScalePow;
|
|
104
|
+
break;
|
|
105
|
+
case "linear":
|
|
106
|
+
default:
|
|
107
|
+
scaler = d3ScaleLinear;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
const scale = scaler().domain(extent).range([this.fontSizeFrom(), this.fontSizeTo()]);
|
|
111
|
+
const angleDomain = d3ScaleLinear().domain([0, context.angleCount() - 1]).range([context.angleFrom(), context.angleTo()]);
|
|
112
|
+
|
|
113
|
+
this._d3Cloud.stop()
|
|
114
|
+
.size([this.width(), this.height()])
|
|
115
|
+
.words(data)
|
|
116
|
+
.font(this.fontFamily())
|
|
117
|
+
.padding(this.padding())
|
|
118
|
+
.spiral(this.spiral())
|
|
119
|
+
.text(function (d) {
|
|
120
|
+
return d.__viz_label.trim();
|
|
121
|
+
})
|
|
122
|
+
.fontSize(function (d) {
|
|
123
|
+
return scale(d.__viz_weight);
|
|
124
|
+
})
|
|
125
|
+
.rotate((d, i) => angleDomain(i % context.angleCount()))
|
|
126
|
+
.on("word", w => {
|
|
127
|
+
})
|
|
128
|
+
.on("end", draw)
|
|
129
|
+
.start()
|
|
130
|
+
;
|
|
131
|
+
|
|
132
|
+
function draw(data, bounds) {
|
|
133
|
+
const text = context._root.selectAll("text")
|
|
134
|
+
.data(data, function (d) { return d.__viz_label ? d.__viz_label.toLowerCase() : ""; })
|
|
135
|
+
;
|
|
136
|
+
text.enter().append("text")
|
|
137
|
+
.attr("text-anchor", "middle")
|
|
138
|
+
.call(context._selection.enter.bind(context._selection))
|
|
139
|
+
.text(function (d) { return d.__viz_label; })
|
|
140
|
+
.on("click", function (d) {
|
|
141
|
+
context.click(context.rowToObj(d.__viz_row), context.columns()[1], context._selection.selected(this));
|
|
142
|
+
})
|
|
143
|
+
.on("dblclick", function (d) {
|
|
144
|
+
context.dblclick(context.rowToObj(d.__viz_row), context.columns()[1], context._selection.selected(this));
|
|
145
|
+
})
|
|
146
|
+
.on("mouseout.tooltip", context.tooltip.hide)
|
|
147
|
+
.on("mousemove.tooltip", context.tooltip.show)
|
|
148
|
+
.style("opacity", 1e-6)
|
|
149
|
+
.merge(text)
|
|
150
|
+
.style("font-size", function (d) { return scale(d.__viz_weight) + "px"; })
|
|
151
|
+
.style("font-family", context.fontFamily())
|
|
152
|
+
.transition().duration(1000)
|
|
153
|
+
.attr("transform", function (d) { return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")"; })
|
|
154
|
+
.style("fill", function (d) { return context._palette(d.__viz_label ? d.__viz_label.toLowerCase() : ""); })
|
|
155
|
+
.style("opacity", 1)
|
|
156
|
+
;
|
|
157
|
+
text.exit().transition().duration(1000)
|
|
158
|
+
.style("opacity", 1e-4)
|
|
159
|
+
.remove()
|
|
160
|
+
;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
zoomed(source, translate, scale) {
|
|
165
|
+
if (translate[0] !== this._prevOffsetX || translate[1] !== this._prevOffsetY || scale !== this._prevZoom) {
|
|
166
|
+
this._root.attr("transform", translate);
|
|
167
|
+
switch (source) {
|
|
168
|
+
case this:
|
|
169
|
+
/*
|
|
170
|
+
this._d3Zoom
|
|
171
|
+
.scale(scale)
|
|
172
|
+
.translate(translate)
|
|
173
|
+
;
|
|
174
|
+
*/
|
|
175
|
+
break;
|
|
176
|
+
case this._d3Zoom:
|
|
177
|
+
this.offsetX(translate[0]);
|
|
178
|
+
this.offsetY(translate[1]);
|
|
179
|
+
this.zoom(scale);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
this._prevOffsetX = translate[0];
|
|
183
|
+
this._prevOffsetY = translate[1];
|
|
184
|
+
this._prevZoom = scale;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
WordCloud.prototype._class += " chart_WordCloud";
|
|
189
|
+
WordCloud.prototype.implements(I2DChart.prototype);
|
|
190
|
+
WordCloud.prototype.implements(ITooltip.prototype);
|
|
191
|
+
WordCloud.prototype.mixin(Utility.SimpleSelectionMixin);
|
|
192
|
+
|
|
193
|
+
export interface WordCloud {
|
|
194
|
+
|
|
195
|
+
paletteID(): string;
|
|
196
|
+
paletteID(_: string): this;
|
|
197
|
+
useClonedPalette(): boolean;
|
|
198
|
+
useClonedPalette(_: boolean): this;
|
|
199
|
+
fontFamily(): string;
|
|
200
|
+
fontFamily(_: string): this;
|
|
201
|
+
fontSizeFrom(): number;
|
|
202
|
+
fontSizeFrom(_: number): this;
|
|
203
|
+
fontSizeTo(): number;
|
|
204
|
+
fontSizeTo(_: number): this;
|
|
205
|
+
angleFrom(): number;
|
|
206
|
+
angleFrom(_: number): this;
|
|
207
|
+
angleTo(): number;
|
|
208
|
+
angleTo(_: number): this;
|
|
209
|
+
angleCount(): number;
|
|
210
|
+
angleCount(_: number): this;
|
|
211
|
+
padding(): number;
|
|
212
|
+
padding(_: number): this;
|
|
213
|
+
scaleMode(): string;
|
|
214
|
+
scaleMode(_: string): this;
|
|
215
|
+
spiral(): string;
|
|
216
|
+
spiral(_: string): this;
|
|
217
|
+
offsetX(): number;
|
|
218
|
+
offsetX(_: number): this;
|
|
219
|
+
offsetY(): number;
|
|
220
|
+
offsetY(_: number): this;
|
|
221
|
+
zoom(): number;
|
|
222
|
+
zoom(_: number): this;
|
|
223
|
+
zoom_exists(): boolean;
|
|
224
|
+
|
|
225
|
+
// I2DChart
|
|
226
|
+
_palette;
|
|
227
|
+
click(row, column, selected): void;
|
|
228
|
+
dblclick(row, column, selected): void;
|
|
229
|
+
|
|
230
|
+
// ITooltip ---
|
|
231
|
+
tooltip;
|
|
232
|
+
tooltipHTML(_?): any;
|
|
233
|
+
tooltipFormat(opts): any;
|
|
234
|
+
tooltipStyle(): string;
|
|
235
|
+
tooltipStyle(_: string): this;
|
|
236
|
+
tooltipValueFormat(): string;
|
|
237
|
+
tooltipValueFormat(_: string): this;
|
|
238
|
+
tooltipSeriesColor(): string;
|
|
239
|
+
tooltipSeriesColor(_: string): this;
|
|
240
|
+
tooltipLabelColor(): string;
|
|
241
|
+
tooltipLabelColor(_: string): this;
|
|
242
|
+
tooltipValueColor(): string;
|
|
243
|
+
tooltipValueColor(_: string): this;
|
|
244
|
+
tooltipTick(): boolean;
|
|
245
|
+
tooltipTick(_: boolean): this;
|
|
246
|
+
tooltipOffset(): number;
|
|
247
|
+
tooltipOffset(_: number): this;
|
|
248
|
+
tooltipOffset_exists(): boolean;
|
|
249
|
+
|
|
250
|
+
// SimpleSelectionMixin
|
|
251
|
+
_selection: Utility.SimpleSelection;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
WordCloud.prototype.publish("paletteID", "default", "set", "Color palette for this widget", WordCloud.prototype._palette.switch(), { tags: ["Basic", "Shared"] });
|
|
255
|
+
WordCloud.prototype.publish("useClonedPalette", false, "boolean", "Enable or disable using a cloned palette", null, { tags: ["Intermediate", "Shared"] });
|
|
256
|
+
|
|
257
|
+
WordCloud.prototype.publish("fontFamily", "Impact", "string", "Font Name", null, { tags: ["Basic"] });
|
|
258
|
+
WordCloud.prototype.publish("fontSizeFrom", 6, "number", "Minimum font size (pixels)", null, { tags: ["Basic"] });
|
|
259
|
+
WordCloud.prototype.publish("fontSizeTo", 48, "number", "Maximum font size (pixels)", null, { tags: ["Basic"] });
|
|
260
|
+
WordCloud.prototype.publish("angleFrom", -60, "number", "Minimum angle (degrees)", null, { tags: ["Basic"] });
|
|
261
|
+
WordCloud.prototype.publish("angleTo", 60, "number", "Maximum angle (degrees)", null, { tags: ["Basic"] });
|
|
262
|
+
WordCloud.prototype.publish("angleCount", 5, "number", "Number of different angles", null, { tags: ["Basic"] });
|
|
263
|
+
WordCloud.prototype.publish("padding", 0, "number", "Padding between words (pixels)", null, { tags: ["Intermediate"] });
|
|
264
|
+
WordCloud.prototype.publish("scaleMode", "linear", "set", "Text scaling mode", ["linear", "log", "sqrt", "pow"], { tags: ["Intermediate"] });
|
|
265
|
+
WordCloud.prototype.publish("spiral", "archimedean", "set", "Text scaling mode", ["archimedean", "rectangular"], { tags: ["Intermediate"] });
|
|
266
|
+
WordCloud.prototype.publish("offsetX", 0, "number", "X offset", null, { tags: ["Advanced"] });
|
|
267
|
+
WordCloud.prototype.publish("offsetY", 0, "number", "Y offset", null, { tags: ["Advanced"] });
|
|
268
|
+
WordCloud.prototype.publish("zoom", 1, "number", "Zoom", null, { tags: ["Advanced"] });
|
package/src/XYAxis.css
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
.chart_XYAxis .axis {
|
|
2
|
-
fill: black;
|
|
3
|
-
font: 10px sans-serif;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.chart_XYAxis .tick>text {
|
|
7
|
-
font: 10px sans-serif;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.chart_XYAxis .focus .chart_Axis.value .tick {
|
|
11
|
-
visibility: hidden;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.chart_XYAxis .axis path,
|
|
15
|
-
.chart_XYAxis .axis line {
|
|
16
|
-
fill: none;
|
|
17
|
-
stroke: #000;
|
|
18
|
-
shape-rendering: crispEdges;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.chart_XYAxis .region {
|
|
22
|
-
opacity: 0.33;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.chart_XYAxis .brush rect.background {
|
|
26
|
-
z-index: -999;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.chart_XYAxis .brush .selection {
|
|
30
|
-
stroke: steelblue;
|
|
31
|
-
stroke-opacity: 1;
|
|
32
|
-
stroke-width: 1px;
|
|
33
|
-
fill: steelblue;
|
|
34
|
-
fill-opacity: .125;
|
|
35
|
-
shape-rendering: crispEdges;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.chart_XYAxis .brush path.handle--custom {
|
|
39
|
-
fill: #eee;
|
|
40
|
-
stroke: #666;
|
|
1
|
+
.chart_XYAxis .axis {
|
|
2
|
+
fill: black;
|
|
3
|
+
font: 10px sans-serif;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.chart_XYAxis .tick>text {
|
|
7
|
+
font: 10px sans-serif;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.chart_XYAxis .focus .chart_Axis.value .tick {
|
|
11
|
+
visibility: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.chart_XYAxis .axis path,
|
|
15
|
+
.chart_XYAxis .axis line {
|
|
16
|
+
fill: none;
|
|
17
|
+
stroke: #000;
|
|
18
|
+
shape-rendering: crispEdges;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.chart_XYAxis .region {
|
|
22
|
+
opacity: 0.33;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.chart_XYAxis .brush rect.background {
|
|
26
|
+
z-index: -999;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.chart_XYAxis .brush .selection {
|
|
30
|
+
stroke: steelblue;
|
|
31
|
+
stroke-opacity: 1;
|
|
32
|
+
stroke-width: 1px;
|
|
33
|
+
fill: steelblue;
|
|
34
|
+
fill-opacity: .125;
|
|
35
|
+
shape-rendering: crispEdges;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.chart_XYAxis .brush path.handle--custom {
|
|
39
|
+
fill: #eee;
|
|
40
|
+
stroke: #666;
|
|
41
41
|
}
|