billboard.js 4.1.4 → 4.1.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/dist/billboard.css +1 -1
- package/dist/billboard.js +154 -87
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +19 -19
- package/dist/billboard.pkgd.js +154 -87
- package/dist/billboard.pkgd.min.js +23 -23
- package/dist/billboard.react.js +1 -1
- package/dist/billboard.react.min.js +1 -1
- package/dist/billboard.worker.js +1 -1
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/Chart/Chart.js +1 -1
- package/dist-esm/Chart/api/axis.js +1 -1
- package/dist-esm/Chart/api/category.js +1 -1
- package/dist-esm/Chart/api/chart.js +2 -2
- package/dist-esm/Chart/api/color.js +1 -1
- package/dist-esm/Chart/api/data.js +1 -1
- package/dist-esm/Chart/api/export.js +1 -1
- package/dist-esm/Chart/api/flow.js +13 -6
- package/dist-esm/Chart/api/focus.js +1 -1
- package/dist-esm/Chart/api/grid.js +1 -1
- package/dist-esm/Chart/api/group.js +1 -1
- package/dist-esm/Chart/api/legend.js +1 -1
- package/dist-esm/Chart/api/load.js +1 -1
- package/dist-esm/Chart/api/regions.js +1 -1
- package/dist-esm/Chart/api/selection.js +1 -1
- package/dist-esm/Chart/api/show.js +1 -1
- package/dist-esm/Chart/api/stubs.js +1 -1
- package/dist-esm/Chart/api/subchart.js +1 -1
- package/dist-esm/Chart/api/tooltip.js +1 -1
- package/dist-esm/Chart/api/x.js +1 -1
- package/dist-esm/Chart/api/zoom.js +1 -1
- package/dist-esm/ChartInternal/Axis/Axis.js +1 -1
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +18 -11
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +2 -2
- package/dist-esm/ChartInternal/ChartInternal.js +1 -1
- package/dist-esm/ChartInternal/data/convert.helper.js +1 -1
- package/dist-esm/ChartInternal/data/convert.js +1 -1
- package/dist-esm/ChartInternal/data/data.js +1 -1
- package/dist-esm/ChartInternal/data/load.js +1 -1
- package/dist-esm/ChartInternal/interactions/drag.js +1 -1
- package/dist-esm/ChartInternal/interactions/eventrect.js +1 -1
- package/dist-esm/ChartInternal/interactions/flow.js +23 -16
- package/dist-esm/ChartInternal/interactions/interaction.js +1 -1
- package/dist-esm/ChartInternal/interactions/subchart.js +1 -1
- package/dist-esm/ChartInternal/interactions/zoom.js +1 -1
- package/dist-esm/ChartInternal/internals/category.js +1 -1
- package/dist-esm/ChartInternal/internals/class.js +1 -1
- package/dist-esm/ChartInternal/internals/clip.js +1 -1
- package/dist-esm/ChartInternal/internals/color.js +1 -1
- package/dist-esm/ChartInternal/internals/domain.js +1 -1
- package/dist-esm/ChartInternal/internals/format.js +1 -1
- package/dist-esm/ChartInternal/internals/grid.js +1 -1
- package/dist-esm/ChartInternal/internals/legend.js +1 -1
- package/dist-esm/ChartInternal/internals/redraw.js +6 -6
- package/dist-esm/ChartInternal/internals/region.js +1 -1
- package/dist-esm/ChartInternal/internals/scale.js +1 -1
- package/dist-esm/ChartInternal/internals/selection.js +1 -1
- package/dist-esm/ChartInternal/internals/size.axis.js +1 -1
- package/dist-esm/ChartInternal/internals/size.js +1 -1
- package/dist-esm/ChartInternal/internals/style.js +1 -1
- package/dist-esm/ChartInternal/internals/subchart.util.js +1 -1
- package/dist-esm/ChartInternal/internals/text.arc.js +1 -1
- package/dist-esm/ChartInternal/internals/text.js +1 -1
- package/dist-esm/ChartInternal/internals/text.util.js +1 -1
- package/dist-esm/ChartInternal/internals/title.js +1 -1
- package/dist-esm/ChartInternal/internals/tooltip.js +23 -4
- package/dist-esm/ChartInternal/internals/transform.js +1 -1
- package/dist-esm/ChartInternal/internals/type.js +1 -1
- package/dist-esm/ChartInternal/shape/arc.js +1 -1
- package/dist-esm/ChartInternal/shape/area.js +1 -1
- package/dist-esm/ChartInternal/shape/bar.js +1 -1
- package/dist-esm/ChartInternal/shape/bubble.js +1 -1
- package/dist-esm/ChartInternal/shape/candlestick.js +1 -1
- package/dist-esm/ChartInternal/shape/core/barRadius.js +1 -1
- package/dist-esm/ChartInternal/shape/core/bubble.js +1 -1
- package/dist-esm/ChartInternal/shape/core/candlestick.js +1 -1
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +1 -1
- package/dist-esm/ChartInternal/shape/core/geometry.js +1 -1
- package/dist-esm/ChartInternal/shape/core/path.js +1 -1
- package/dist-esm/ChartInternal/shape/core/point.js +1 -1
- package/dist-esm/ChartInternal/shape/core/treemap.js +1 -1
- package/dist-esm/ChartInternal/shape/funnel.js +1 -1
- package/dist-esm/ChartInternal/shape/gauge.js +1 -1
- package/dist-esm/ChartInternal/shape/line.js +1 -1
- package/dist-esm/ChartInternal/shape/point.js +5 -4
- package/dist-esm/ChartInternal/shape/polar.js +1 -1
- package/dist-esm/ChartInternal/shape/radar.js +1 -1
- package/dist-esm/ChartInternal/shape/shape.js +9 -5
- package/dist-esm/ChartInternal/shape/treemap.js +1 -1
- package/dist-esm/canvas/CanvasAxisRenderer.js +18 -15
- package/dist-esm/canvas/CanvasEngine.js +1 -1
- package/dist-esm/canvas/CanvasPainter.js +1 -1
- package/dist-esm/canvas/CanvasRenderer.js +1 -1
- package/dist-esm/canvas/CanvasTheme.js +1 -1
- package/dist-esm/canvas/HitDetector.js +1 -1
- package/dist-esm/canvas/axisTicks.js +1 -1
- package/dist-esm/canvas/classes.js +1 -1
- package/dist-esm/canvas/color.js +1 -1
- package/dist-esm/canvas/geometry.js +1 -1
- package/dist-esm/canvas/labels.js +1 -1
- package/dist-esm/canvas/pointPattern.js +1 -1
- package/dist-esm/canvas/util.js +1 -1
- package/dist-esm/config/Options/Options.js +1 -1
- package/dist-esm/config/Options/axis/axis.js +1 -1
- package/dist-esm/config/Options/axis/x.js +1 -1
- package/dist-esm/config/Options/axis/y.js +1 -1
- package/dist-esm/config/Options/axis/y2.js +1 -1
- package/dist-esm/config/Options/common/boost.js +1 -1
- package/dist-esm/config/Options/common/color.js +1 -1
- package/dist-esm/config/Options/common/grid.js +1 -1
- package/dist-esm/config/Options/common/legend.js +1 -1
- package/dist-esm/config/Options/common/main.js +1 -1
- package/dist-esm/config/Options/common/point.js +1 -1
- package/dist-esm/config/Options/common/title.js +1 -1
- package/dist-esm/config/Options/common/tooltip.js +1 -1
- package/dist-esm/config/Options/data/axis.js +1 -1
- package/dist-esm/config/Options/data/data.js +1 -1
- package/dist-esm/config/Options/data/selection.js +1 -1
- package/dist-esm/config/Options/interaction/interaction.js +1 -1
- package/dist-esm/config/Options/interaction/subchart.js +5 -1
- package/dist-esm/config/Options/interaction/zoom.js +1 -1
- package/dist-esm/config/Options/shape/arc.js +1 -1
- package/dist-esm/config/Options/shape/area.js +1 -1
- package/dist-esm/config/Options/shape/bar.js +1 -1
- package/dist-esm/config/Options/shape/bubble.js +1 -1
- package/dist-esm/config/Options/shape/candlestick.js +1 -1
- package/dist-esm/config/Options/shape/donut.js +1 -1
- package/dist-esm/config/Options/shape/funnel.js +1 -1
- package/dist-esm/config/Options/shape/gauge.js +1 -1
- package/dist-esm/config/Options/shape/line.js +1 -1
- package/dist-esm/config/Options/shape/pie.js +1 -1
- package/dist-esm/config/Options/shape/polar.js +1 -1
- package/dist-esm/config/Options/shape/radar.js +1 -1
- package/dist-esm/config/Options/shape/scatter.js +1 -1
- package/dist-esm/config/Options/shape/spline.js +1 -1
- package/dist-esm/config/Options/shape/treemap.js +1 -1
- package/dist-esm/config/Store/Element.js +1 -1
- package/dist-esm/config/Store/State.js +2 -1
- package/dist-esm/config/Store/Store.js +1 -1
- package/dist-esm/config/classes.js +1 -1
- package/dist-esm/config/config.js +1 -1
- package/dist-esm/config/const.js +1 -1
- package/dist-esm/config/resolver/axis.core.js +1 -1
- package/dist-esm/config/resolver/axis.js +1 -1
- package/dist-esm/config/resolver/canvas.js +15 -3
- package/dist-esm/config/resolver/canvasShape.js +1 -1
- package/dist-esm/config/resolver/category.js +1 -1
- package/dist-esm/config/resolver/export.js +1 -1
- package/dist-esm/config/resolver/flow.js +1 -1
- package/dist-esm/config/resolver/grid.js +1 -1
- package/dist-esm/config/resolver/interaction/selection.js +1 -1
- package/dist-esm/config/resolver/interaction/subchart.js +1 -1
- package/dist-esm/config/resolver/interaction/zoom.js +1 -1
- package/dist-esm/config/resolver/regions.js +1 -1
- package/dist-esm/config/resolver/shape/arc.helpers.js +1 -1
- package/dist-esm/config/resolver/shape/area.js +1 -1
- package/dist-esm/config/resolver/shape/axis.helpers.js +1 -1
- package/dist-esm/config/resolver/shape/bar.js +1 -1
- package/dist-esm/config/resolver/shape/bubble.js +1 -1
- package/dist-esm/config/resolver/shape/candlestick.js +1 -1
- package/dist-esm/config/resolver/shape/donut.js +1 -1
- package/dist-esm/config/resolver/shape/funnel.js +1 -1
- package/dist-esm/config/resolver/shape/gauge.js +1 -1
- package/dist-esm/config/resolver/shape/line.js +1 -1
- package/dist-esm/config/resolver/shape/pie.js +1 -1
- package/dist-esm/config/resolver/shape/polar.js +1 -1
- package/dist-esm/config/resolver/shape/radar.js +1 -1
- package/dist-esm/config/resolver/shape/scatter.js +1 -1
- package/dist-esm/config/resolver/shape/treemap.js +1 -1
- package/dist-esm/core.js +3 -3
- package/dist-esm/index.canvas.js +1 -1
- package/dist-esm/index.esm.js +1 -1
- package/dist-esm/module/Cache.js +1 -1
- package/dist-esm/module/browser.js +1 -1
- package/dist-esm/module/dsv.js +1 -1
- package/dist-esm/module/error.js +1 -1
- package/dist-esm/module/generator.js +1 -1
- package/dist-esm/module/sanitize.js +1 -1
- package/dist-esm/module/util/brush.js +1 -1
- package/dist-esm/module/util/dom.js +1 -1
- package/dist-esm/module/util/object.js +1 -1
- package/dist-esm/module/util/type-checks.js +1 -1
- package/dist-esm/module/worker.js +1 -1
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist-esm/react/index.js +1 -1
- package/package.json +1 -1
- package/src/Chart/api/chart.ts +2 -1
- package/src/Chart/api/flow.ts +20 -7
- package/src/ChartInternal/Axis/AxisRenderer.ts +20 -18
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +3 -1
- package/src/ChartInternal/interactions/flow.ts +50 -19
- package/src/ChartInternal/internals/redraw.ts +15 -9
- package/src/ChartInternal/internals/tooltip.ts +24 -6
- package/src/ChartInternal/shape/point.ts +6 -3
- package/src/ChartInternal/shape/shape.ts +15 -3
- package/src/canvas/CanvasAxisRenderer.ts +19 -22
- package/src/config/Options/interaction/subchart.ts +4 -0
- package/src/config/Store/State.ts +1 -0
- package/src/config/resolver/canvas.ts +20 -2
- package/types/options.d.ts +3 -0
|
@@ -15,9 +15,14 @@ export default {
|
|
|
15
15
|
*/
|
|
16
16
|
generateFlow(args): Function {
|
|
17
17
|
const $$ = this;
|
|
18
|
-
const {data, state, $el} = $$;
|
|
18
|
+
const {config, data, state, $el} = $$;
|
|
19
19
|
|
|
20
20
|
return function() {
|
|
21
|
+
// destroy() empties the instance while the redraw transition is waited on
|
|
22
|
+
if (!$$.$el) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
const flowLength = args.flow.length;
|
|
22
27
|
|
|
23
28
|
// set flag
|
|
@@ -63,7 +68,18 @@ export default {
|
|
|
63
68
|
}
|
|
64
69
|
});
|
|
65
70
|
|
|
66
|
-
|
|
71
|
+
// the focus slides with its data and the flow end moves it to the data under the pointer
|
|
72
|
+
if (config.axis_rotated) {
|
|
73
|
+
$$.hideGridFocus?.();
|
|
74
|
+
} else {
|
|
75
|
+
const xFocus = $el.main.selectAll(
|
|
76
|
+
`line.${CLASS.xgridFocus}:not(.${CLASS.xgridFocusContinuous})`
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
xFocus.size() && (elements["gridFocus.x"] = xFocus);
|
|
80
|
+
$el.main.selectAll(`line.${CLASS.ygridFocus}`).style("visibility", "hidden");
|
|
81
|
+
}
|
|
82
|
+
|
|
67
83
|
$$.setFlowList(elements, args);
|
|
68
84
|
};
|
|
69
85
|
},
|
|
@@ -79,12 +95,10 @@ export default {
|
|
|
79
95
|
const {flow, targets} = args;
|
|
80
96
|
const {
|
|
81
97
|
duration = args.duration,
|
|
82
|
-
index: flowIndex,
|
|
83
|
-
length: flowLength,
|
|
84
98
|
orgDataCount
|
|
85
99
|
} = flow;
|
|
86
100
|
|
|
87
|
-
const transform = $$.getFlowTransform(targets, orgDataCount
|
|
101
|
+
const transform = $$.getFlowTransform(targets, orgDataCount);
|
|
88
102
|
const wait = generateWait();
|
|
89
103
|
let n;
|
|
90
104
|
|
|
@@ -121,6 +135,13 @@ export default {
|
|
|
121
135
|
*/
|
|
122
136
|
cleanUpFlow(elements, args): void {
|
|
123
137
|
const $$ = this;
|
|
138
|
+
|
|
139
|
+
// destroy() interrupts the flow transition, which the wait counts as ended,
|
|
140
|
+
// and empties the instance before this runs
|
|
141
|
+
if (!$$.$el) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
124
145
|
const {config, state, $el: {svg}} = $$;
|
|
125
146
|
const isRotated = config.axis_rotated;
|
|
126
147
|
|
|
@@ -133,6 +154,11 @@ export default {
|
|
|
133
154
|
|
|
134
155
|
// Remove flowed elements
|
|
135
156
|
if (flowLength) {
|
|
157
|
+
// point.focus.only draws one circle per data series, which the focus moves to any index
|
|
158
|
+
const isFocusCircle = $$.isPointFocusOnly() ?
|
|
159
|
+
(node: Element) => node.parentElement?.classList.contains(CLASS.circles) :
|
|
160
|
+
() => false;
|
|
161
|
+
|
|
136
162
|
["circle", "text", "shape", "eventRect"].forEach(v => {
|
|
137
163
|
const target: string[] = [];
|
|
138
164
|
|
|
@@ -142,6 +168,9 @@ export default {
|
|
|
142
168
|
|
|
143
169
|
svg.selectAll(`.${CLASS[`${v}s`]}`) // circles, shapes, texts, eventRects
|
|
144
170
|
.selectAll(target)
|
|
171
|
+
.filter(function() {
|
|
172
|
+
return !isFocusCircle(this);
|
|
173
|
+
})
|
|
145
174
|
.remove();
|
|
146
175
|
});
|
|
147
176
|
|
|
@@ -190,28 +219,31 @@ export default {
|
|
|
190
219
|
|
|
191
220
|
config.interaction_enabled && $$.redrawEventRect();
|
|
192
221
|
|
|
222
|
+
state.flowing = false;
|
|
223
|
+
|
|
224
|
+
// other data is under the pointer now: show its focus and tooltip
|
|
225
|
+
if ($$.$el.tooltip?.style("display") === "block") {
|
|
226
|
+
$$.updateTooltipOnRedraw();
|
|
227
|
+
} else {
|
|
228
|
+
$$.hideGridFocus?.();
|
|
229
|
+
}
|
|
230
|
+
|
|
193
231
|
// callback for end of flow
|
|
194
232
|
done.call($$.api);
|
|
195
|
-
|
|
196
|
-
state.flowing = false;
|
|
197
233
|
},
|
|
198
234
|
|
|
199
235
|
/**
|
|
200
236
|
* Get flow transform value
|
|
201
237
|
* @param {object} targets target
|
|
202
238
|
* @param {number} orgDataCount original data count
|
|
203
|
-
* @param {number} flowIndex flow index
|
|
204
|
-
* @param {number} flowLength flow length
|
|
205
239
|
* @returns {string}
|
|
206
240
|
* @private
|
|
207
241
|
*/
|
|
208
|
-
getFlowTransform(targets, orgDataCount
|
|
242
|
+
getFlowTransform(targets, orgDataCount): string {
|
|
209
243
|
const $$ = this;
|
|
210
244
|
const {data, scale: {x}} = $$;
|
|
211
245
|
const dataValues = data.targets[0].values;
|
|
212
246
|
|
|
213
|
-
let flowStart = $$.getValueOnIndex(dataValues, flowIndex);
|
|
214
|
-
let flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength);
|
|
215
247
|
let translateX;
|
|
216
248
|
|
|
217
249
|
// update x domain to generate axis elements for flow
|
|
@@ -224,19 +256,18 @@ export default {
|
|
|
224
256
|
translateX = x(orgDomain[0]) - x(domain[0]);
|
|
225
257
|
} else {
|
|
226
258
|
if ($$.axis.isTimeSeries()) {
|
|
227
|
-
flowStart = $$.getValueOnIndex(dataValues, 0);
|
|
228
|
-
flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1);
|
|
259
|
+
const flowStart = $$.getValueOnIndex(dataValues, 0);
|
|
260
|
+
const flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1);
|
|
261
|
+
|
|
229
262
|
translateX = x(flowStart.x) - x(flowEnd.x);
|
|
230
263
|
} else {
|
|
231
264
|
translateX = diffDomain(domain) / 2;
|
|
232
265
|
}
|
|
233
266
|
}
|
|
234
|
-
} else if (orgDataCount === 1 || flowStart?.x === flowEnd?.x) {
|
|
235
|
-
translateX = x(orgDomain[0]) - x(domain[0]);
|
|
236
267
|
} else {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
268
|
+
// The flowed-out head is already spliced from the data, so the slide is
|
|
269
|
+
// measured by how far the domain start moved.
|
|
270
|
+
translateX = x(orgDomain[0]) - x(domain[0]);
|
|
240
271
|
}
|
|
241
272
|
|
|
242
273
|
const scaleX = diffDomain(orgDomain) / diffDomain(domain);
|
|
@@ -65,7 +65,8 @@ export default {
|
|
|
65
65
|
|
|
66
66
|
if (state.isCanvasMode) {
|
|
67
67
|
const zoomScale = $$.scale.zoom;
|
|
68
|
-
|
|
68
|
+
// the domain set to the scale: a category scale reads its end one category further
|
|
69
|
+
const zoomDomain = zoomScale?.orgDomain?.() ?? zoomScale?.domain();
|
|
69
70
|
|
|
70
71
|
zoomScale && ($$.scale.zoom = null);
|
|
71
72
|
$$.updateScales(initializing, wth.UpdateXDomain);
|
|
@@ -73,7 +74,8 @@ export default {
|
|
|
73
74
|
if (zoomScale) {
|
|
74
75
|
zoomScale.range($$.scale.x.range());
|
|
75
76
|
zoomDomain && zoomScale.domain(zoomDomain);
|
|
76
|
-
|
|
77
|
+
// wrap the plain scale: wrapping the customized one again shifts a category domain
|
|
78
|
+
$$.scale.zoom = $$.getCustomizedXScale(zoomScale.orgScale?.() ?? zoomScale);
|
|
77
79
|
$$.axis.x.scale($$.scale.zoom);
|
|
78
80
|
$$.scale.x.domain(config.zoom_rescale ? zoomDomain : $$.org.xDomain);
|
|
79
81
|
$$.scale.subX.domain($$.org.xDomain);
|
|
@@ -189,7 +191,7 @@ export default {
|
|
|
189
191
|
|
|
190
192
|
if (!state.resizing && !treemap && ($$.hasPointType() || state.hasRadar)) {
|
|
191
193
|
if (needShapeUpdate) {
|
|
192
|
-
$$.updateCircle();
|
|
194
|
+
$$.updateCircle(false, !!flow);
|
|
193
195
|
}
|
|
194
196
|
} else if ($$.hasLegendDefsPoint?.()) {
|
|
195
197
|
$$.data.targets.forEach($$.point("create", this));
|
|
@@ -223,6 +225,12 @@ export default {
|
|
|
223
225
|
needShapeRegen: boolean = true): void {
|
|
224
226
|
const $$ = this;
|
|
225
227
|
const {config, state} = $$;
|
|
228
|
+
|
|
229
|
+
// subchart first: its initial range narrows the x domain, which sizes the main shapes
|
|
230
|
+
if (state.hasAxis) {
|
|
231
|
+
config.subchart_show && $$.redrawSubchart(withSubchart, duration);
|
|
232
|
+
}
|
|
233
|
+
|
|
226
234
|
const shape = needShapeRegen ?
|
|
227
235
|
$$.getDrawShape() :
|
|
228
236
|
(state._cachedDrawShape || $$.getDrawShape());
|
|
@@ -231,11 +239,6 @@ export default {
|
|
|
231
239
|
state._cachedDrawShape = shape;
|
|
232
240
|
}
|
|
233
241
|
|
|
234
|
-
if (state.hasAxis) {
|
|
235
|
-
// subchart
|
|
236
|
-
config.subchart_show && $$.redrawSubchart(withSubchart, duration, shape);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
242
|
// generate flow
|
|
240
243
|
const flowFn = flow && $$.generateFlow({
|
|
241
244
|
targets,
|
|
@@ -244,7 +247,10 @@ export default {
|
|
|
244
247
|
shape,
|
|
245
248
|
xv: $$.xv.bind($$)
|
|
246
249
|
});
|
|
247
|
-
|
|
250
|
+
// A flow slides the shapes itself, so they take their new data at once: a chart
|
|
251
|
+
// transition interpolated the paths between different point counts first, which
|
|
252
|
+
// bent them and held back the slide until it ended.
|
|
253
|
+
const withTransition = !flowFn && duration && isTabVisible();
|
|
248
254
|
|
|
249
255
|
// redraw list
|
|
250
256
|
const redrawList = $$.getRedrawList(shape, flow, flowFn, withTransition);
|
|
@@ -27,6 +27,20 @@ import type {IArcData, IDataRow} from "../data/IData";
|
|
|
27
27
|
const RE_WHITESPACE = /(\r?\n|\t)/g;
|
|
28
28
|
const RE_TOOLTIP_TPL = /{{(.*)}}/;
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Get the tooltip value of ranged data: one row per value, aligned on the colon of the names
|
|
32
|
+
* @param {Array} values [name, value] pairs
|
|
33
|
+
* @returns {string} html string
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
function getRangeValueHtml(values: (string | undefined)[][]): string {
|
|
37
|
+
return `<div style="display:inline-grid;grid-template-columns:auto auto;gap:0 .3em;text-align:left">${
|
|
38
|
+
values.map(([name, v]) => `<b style="text-align:right">${name}:</b><span>${v}</span>`).join(
|
|
39
|
+
""
|
|
40
|
+
)
|
|
41
|
+
}</div>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
export default {
|
|
31
45
|
/**
|
|
32
46
|
* Initializes the tooltip
|
|
@@ -227,7 +241,7 @@ export default {
|
|
|
227
241
|
);
|
|
228
242
|
const mid = valueFormat(getRowValue(row), ...param as [number, string, number]);
|
|
229
243
|
|
|
230
|
-
value =
|
|
244
|
+
value = getRangeValueHtml([["Mid", mid], ["High", high], ["Low", low]]);
|
|
231
245
|
} else if ($$.isCandlestickType(row)) {
|
|
232
246
|
const [open, high, low, close, volume] = ["open", "high", "low", "close", "volume"]
|
|
233
247
|
.map(v => {
|
|
@@ -241,10 +255,13 @@ export default {
|
|
|
241
255
|
undefined;
|
|
242
256
|
});
|
|
243
257
|
|
|
244
|
-
value =
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
258
|
+
value = getRangeValueHtml([
|
|
259
|
+
["Open", open],
|
|
260
|
+
["High", high],
|
|
261
|
+
["Low", low],
|
|
262
|
+
["Close", close],
|
|
263
|
+
...(volume ? [["Volume", volume]] : [])
|
|
264
|
+
]);
|
|
248
265
|
} else if ($$.isBarRangeType(row)) {
|
|
249
266
|
const {value: rangeValue, id, index} = row;
|
|
250
267
|
|
|
@@ -697,7 +714,8 @@ export default {
|
|
|
697
714
|
state: {event, hasAxis, hasRadar, hasTreemap}
|
|
698
715
|
} = $$;
|
|
699
716
|
|
|
700
|
-
|
|
717
|
+
// the focus slides with a flow and its end updates the tooltip for the data moved in
|
|
718
|
+
if ($$.state.isCanvasMode || $$.state.flowing) {
|
|
701
719
|
return;
|
|
702
720
|
}
|
|
703
721
|
|
|
@@ -162,7 +162,7 @@ export default {
|
|
|
162
162
|
});
|
|
163
163
|
},
|
|
164
164
|
|
|
165
|
-
updateCircle(isSub = false): void {
|
|
165
|
+
updateCircle(isSub = false, withFlow = false): void {
|
|
166
166
|
const $$ = this;
|
|
167
167
|
const {config, state, $el} = $$;
|
|
168
168
|
const focusOnly = $$.isPointFocusOnly();
|
|
@@ -189,12 +189,15 @@ export default {
|
|
|
189
189
|
const updateCircleColor = $$.generateUpdateCircleColor();
|
|
190
190
|
const initialOpacityForCircle = $$.initialOpacityForCircle.bind($$);
|
|
191
191
|
|
|
192
|
-
circles.enter()
|
|
192
|
+
const entered = circles.enter()
|
|
193
193
|
.filter(Boolean)
|
|
194
194
|
.append($$.point("create", this, pointR, updateCircleColor));
|
|
195
195
|
|
|
196
196
|
$root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`)
|
|
197
|
-
.style("stroke", $$.getStylePropValue($$.color))
|
|
197
|
+
.style("stroke", $$.getStylePropValue($$.color));
|
|
198
|
+
|
|
199
|
+
// a flow slides the shown focus with its data and moves it to the pointer at the end
|
|
200
|
+
(focusOnly && withFlow ? entered : $root.circle)
|
|
198
201
|
.style("opacity", initialOpacityForCircle);
|
|
199
202
|
}
|
|
200
203
|
},
|
|
@@ -143,6 +143,11 @@ function getSubchartCandlestickShapeValue($$, d, isSub?: boolean) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
if ($$.isBarType(d)) {
|
|
146
|
+
// bars show the volume of the day when given, as stock charts do
|
|
147
|
+
if (isNumber(value.volume)) {
|
|
148
|
+
return value.volume;
|
|
149
|
+
}
|
|
150
|
+
|
|
146
151
|
return isNumber(value.open) && isNumber(value.close) ?
|
|
147
152
|
value._isUp ? value.close : value.open :
|
|
148
153
|
undefined;
|
|
@@ -1073,7 +1078,6 @@ export default {
|
|
|
1073
1078
|
const maxDataCount = $$.getMaxDataCount();
|
|
1074
1079
|
const isGrouped = type === "bar" && config.data_groups?.length;
|
|
1075
1080
|
const configName = `${type}_width`;
|
|
1076
|
-
const {k} = $$.getZoomTransform?.() ?? {k: 1};
|
|
1077
1081
|
const xMinMax = [
|
|
1078
1082
|
config.axis_x_min ?? org.xDomain[0],
|
|
1079
1083
|
config.axis_x_max ?? org.xDomain[1]
|
|
@@ -1084,13 +1088,21 @@ export default {
|
|
|
1084
1088
|
|
|
1085
1089
|
let tickInterval = axis.tickInterval(maxDataCount);
|
|
1086
1090
|
|
|
1087
|
-
|
|
1091
|
+
// zoom and drag zoom set 'scale.zoom', the subchart brush narrows 'scale.x'.
|
|
1092
|
+
// Either way, size the width by the data spacing of the range shown.
|
|
1093
|
+
// The subchart always shows the whole range.
|
|
1094
|
+
const xScale = scale.zoom ?? scale.x;
|
|
1095
|
+
const getSpan = ([min, max]) => Math.abs(+max - +min);
|
|
1096
|
+
const isZoomed = axis !== $$.axis.subX && !$$.axis.isCategorized() &&
|
|
1097
|
+
getSpan(xScale.domain()) < getSpan(org.xDomain);
|
|
1098
|
+
|
|
1099
|
+
if (isZoomed) {
|
|
1088
1100
|
const isSameMinMax = xMinMax.every((v, i) => v === org.xDomain[i]);
|
|
1089
1101
|
|
|
1090
1102
|
tickInterval = org.xDomain.map((v, i) => {
|
|
1091
1103
|
const value = isSameMinMax ? v : v - Math.abs(xMinMax[i]);
|
|
1092
1104
|
|
|
1093
|
-
return
|
|
1105
|
+
return xScale(value);
|
|
1094
1106
|
}).reduce((a, c) => Math.abs(a) + c) / maxDataCount;
|
|
1095
1107
|
}
|
|
1096
1108
|
|
|
@@ -356,36 +356,33 @@ function splitTickTextByWidth(text: string, width: number, painter: CanvasPainte
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
const charWidth = painter.measureText("0").width || 5.5;
|
|
359
|
+
const lines: string[] = [];
|
|
360
|
+
let start = 0;
|
|
359
361
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
* @param {Array} lines Accumulated text lines
|
|
363
|
-
* @param {string} value Remaining text fragment
|
|
364
|
-
* @returns {Array} Text lines
|
|
365
|
-
* @private
|
|
366
|
-
*/
|
|
367
|
-
function split(lines: string[], value: string): string[] {
|
|
362
|
+
// iterate rather than recurse per line, so a very long label cannot overflow the stack
|
|
363
|
+
while (true) {
|
|
368
364
|
let spaceIndex: number | undefined;
|
|
365
|
+
let splitAt = -1;
|
|
369
366
|
|
|
370
|
-
for (let i = 1; i <
|
|
371
|
-
if (
|
|
367
|
+
for (let i = 1; start + i < text.length; i++) {
|
|
368
|
+
if (text.charAt(start + i) === " ") {
|
|
372
369
|
spaceIndex = i;
|
|
373
370
|
}
|
|
374
371
|
|
|
375
372
|
if (width < charWidth * (i + 1)) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return split(
|
|
379
|
-
lines.concat(value.slice(0, splitIndex)),
|
|
380
|
-
value.slice(spaceIndex ? spaceIndex + 1 : i)
|
|
381
|
-
);
|
|
373
|
+
splitAt = i;
|
|
374
|
+
break;
|
|
382
375
|
}
|
|
383
376
|
}
|
|
384
377
|
|
|
385
|
-
|
|
386
|
-
|
|
378
|
+
if (splitAt === -1) {
|
|
379
|
+
lines.push(text.slice(start));
|
|
380
|
+
return lines;
|
|
381
|
+
}
|
|
387
382
|
|
|
388
|
-
|
|
383
|
+
lines.push(text.slice(start, start + (spaceIndex || splitAt)));
|
|
384
|
+
start += spaceIndex ? spaceIndex + 1 : splitAt;
|
|
385
|
+
}
|
|
389
386
|
}
|
|
390
387
|
|
|
391
388
|
/**
|
|
@@ -431,9 +428,9 @@ function getXTickTextWidth($$, ticks: AxisTickValue[], isRotated: boolean, targe
|
|
|
431
428
|
* @returns {Array} Tick text lines
|
|
432
429
|
* @private
|
|
433
430
|
*/
|
|
434
|
-
function getXTickTextLines($$, painter: CanvasPainter, format: AxisTickFormat,
|
|
435
|
-
ticks: AxisTickValue[] = [], isRotated = false,
|
|
436
|
-
maxWidth?: number): string[] {
|
|
431
|
+
export function getXTickTextLines($$, painter: CanvasPainter, format: AxisTickFormat,
|
|
432
|
+
tick: AxisTickValue, ticks: AxisTickValue[] = [], isRotated = false,
|
|
433
|
+
targetScale = getXScale($$), maxWidth?: number): string[] {
|
|
437
434
|
const value = format ? format(tick) : tick;
|
|
438
435
|
|
|
439
436
|
if (value == null) {
|
|
@@ -19,6 +19,10 @@ export default {
|
|
|
19
19
|
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
20
20
|
* - `show: subchart()`
|
|
21
21
|
* @property {string} [subchart.type] Set chart type for the subchart. Defaults to data.type.
|
|
22
|
+
* - **NOTE:** When candlestick data is rendered as another type in the subchart, the subchart takes one value of the data:
|
|
23
|
+
* - `bar`: the `volume` of the data. Without `volume`, the close value for a rise and the open value for a fall, from zero.
|
|
24
|
+
* - other types (`line`, `area`, etc.): the close value.
|
|
25
|
+
* - The y axis domain of the subchart follows the taken values. The `volume` is not part of the main chart's y axis domain.
|
|
22
26
|
* @property {object} [subchart.types] Set chart type for each data in the subchart. Defaults to data.types.
|
|
23
27
|
* @property {boolean} [subchart.brush.enabled=true] Enable subchart brush interaction.
|
|
24
28
|
* @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
|
|
@@ -45,6 +45,7 @@ export default class State {
|
|
|
45
45
|
isCanvasMode: false,
|
|
46
46
|
canvasShape: null,
|
|
47
47
|
canvasFocusKey: <string | null>null,
|
|
48
|
+
canvasFocusData: <any[] | null>null,
|
|
48
49
|
canvasSubchartBrushDragging: false,
|
|
49
50
|
canvasSubchartBrushMode: <"select" | "move" | "resize-start" | "resize-end" | null>null,
|
|
50
51
|
canvasSubchartBrushStart: <number | null>null,
|
|
@@ -1319,6 +1319,20 @@ const canvasInternal = {
|
|
|
1319
1319
|
callCallback && config.subchart_onbrush.bind($$.api)(scale.x.orgDomain());
|
|
1320
1320
|
},
|
|
1321
1321
|
|
|
1322
|
+
/**
|
|
1323
|
+
* Show the focus and tooltip of the data the flow moved under the pointer.
|
|
1324
|
+
* @private
|
|
1325
|
+
*/
|
|
1326
|
+
updateCanvasFlowFocus(): void {
|
|
1327
|
+
const $$ = this;
|
|
1328
|
+
const {state} = $$;
|
|
1329
|
+
|
|
1330
|
+
// the redraw cleared the focus overlay, so the same index has to be drawn again
|
|
1331
|
+
state.canvasFocusKey = null;
|
|
1332
|
+
$$.$el.tooltip?.style("display") === "block" && state.event &&
|
|
1333
|
+
$$.onCanvasMouseMove(state.event);
|
|
1334
|
+
},
|
|
1335
|
+
|
|
1322
1336
|
/**
|
|
1323
1337
|
* Finish a pending canvas flow animation before accepting another flow mutation.
|
|
1324
1338
|
* @private
|
|
@@ -1362,6 +1376,8 @@ const canvasInternal = {
|
|
|
1362
1376
|
const startDomain = scale.x.domain().slice(0, 2);
|
|
1363
1377
|
const startOrgDomain = org.xDomain?.slice?.();
|
|
1364
1378
|
const startSubXDomain = scale.subX?.domain?.().slice?.();
|
|
1379
|
+
// the focus slides with its data and the flow end moves it to the data under the pointer
|
|
1380
|
+
const focusData = state.canvasFocusKey ? state.canvasFocusData : null;
|
|
1365
1381
|
|
|
1366
1382
|
if (!isCanvasFlowDomain(startDomain, isLog)) {
|
|
1367
1383
|
return false;
|
|
@@ -1422,6 +1438,7 @@ const canvasInternal = {
|
|
|
1422
1438
|
state.canvasFlowFrame = null;
|
|
1423
1439
|
state.canvasFlowFinish = null;
|
|
1424
1440
|
state.flowing = false;
|
|
1441
|
+
$$.updateCanvasFlowFocus();
|
|
1425
1442
|
done.call($$.api);
|
|
1426
1443
|
};
|
|
1427
1444
|
const render = (timestamp: number) => {
|
|
@@ -1434,7 +1451,7 @@ const canvasInternal = {
|
|
|
1434
1451
|
state._cachedDrawShape = null;
|
|
1435
1452
|
state._canvasVisibleRangeCache = null;
|
|
1436
1453
|
state._canvasXTickValuesCache = null;
|
|
1437
|
-
$$.renderCanvasFrame(undefined,
|
|
1454
|
+
$$.renderCanvasFrame(undefined, focusData, false);
|
|
1438
1455
|
|
|
1439
1456
|
if (ratio < 1) {
|
|
1440
1457
|
state.canvasFlowFrame = requestFrame(render);
|
|
@@ -1449,7 +1466,6 @@ const canvasInternal = {
|
|
|
1449
1466
|
axis.x.scale(scale.x);
|
|
1450
1467
|
state.flowing = true;
|
|
1451
1468
|
state.cancelClick = true;
|
|
1452
|
-
$$.hideTooltip?.();
|
|
1453
1469
|
state.canvasFlowFinish = finish;
|
|
1454
1470
|
state.canvasFlowFrame = requestFrame(render);
|
|
1455
1471
|
|
|
@@ -3137,6 +3153,8 @@ const canvasInternal = {
|
|
|
3137
3153
|
const {state} = $$;
|
|
3138
3154
|
const withMainRedraw = $$.canvasRenderer.hasExpandedShapeFocus?.($$, focusData);
|
|
3139
3155
|
|
|
3156
|
+
state.canvasFocusData = focusData;
|
|
3157
|
+
|
|
3140
3158
|
if (withMainRedraw) {
|
|
3141
3159
|
const drawShape = state.canvasShape || $$.getDrawShape();
|
|
3142
3160
|
|
package/types/options.d.ts
CHANGED
|
@@ -844,6 +844,9 @@ export interface SubchartOptions {
|
|
|
844
844
|
* Set chart type for the subchart.
|
|
845
845
|
* If this option is specified, the type will be applied to every data in the subchart.
|
|
846
846
|
* This setting can be overwritten by subchart.types.
|
|
847
|
+
* When candlestick data is rendered as another type, the subchart takes one value of the data:
|
|
848
|
+
* - `bar`: the volume of the data. Without volume, the close value for a rise and the open value for a fall, from zero.
|
|
849
|
+
* - other types (`line`, `area`, etc.): the close value.
|
|
847
850
|
*/
|
|
848
851
|
type?: ChartTypes;
|
|
849
852
|
|