diff --git a/src/ChartInternal/data/data.ts b/src/ChartInternal/data/data.ts index f24c83f9c..b0f8d0171 100644 --- a/src/ChartInternal/data/data.ts +++ b/src/ChartInternal/data/data.ts @@ -46,7 +46,13 @@ export default { return !!(config.data_stack_normalize && config.data_groups.length); }, - isGrouped(id) { + /** + * Check if given id is grouped data or has grouped data + * @param {string} id Data id value + * @returns {boolean} is grouped data or has grouped data + * @private + */ + isGrouped(id?: string): boolean { const groups = this.config.data_groups; return id ? diff --git a/src/ChartInternal/internals/redraw.ts b/src/ChartInternal/internals/redraw.ts index 77fa34fca..3d3a6aa05 100644 --- a/src/ChartInternal/internals/redraw.ts +++ b/src/ChartInternal/internals/redraw.ts @@ -35,11 +35,6 @@ export default { $$.updateDimension(true); } - // update circleY based on updated parameters - if (!treemap && (!$$.hasArcType() || state.hasRadar)) { - $$.updateCircleY && ($$.circleY = $$.updateCircleY()); - } - // Data empty label positioning and text. config.data_empty_label_text && main.select(`text.${$TEXT.text}.${$COMMON.empty}`) .attr("x", state.width / 2) diff --git a/src/ChartInternal/shape/shape.ts b/src/ChartInternal/shape/shape.ts index 96aa9cce2..b1c37bb2f 100644 --- a/src/ChartInternal/shape/shape.ts +++ b/src/ChartInternal/shape/shape.ts @@ -28,6 +28,26 @@ import CLASS from "../../config/classes"; import {capitalize, getPointer, getRectSegList, getUnique, isObjectType, isNumber, isValue, isUndefined, notEmpty} from "../../module/util"; import type {IDataRow, IDataIndice, TIndices} from "../data/IData"; +/** + * Get grouped data point function for y coordinate + * - Note: Grouped(stacking) works only for line and bar types + * @param {object} d data vlaue + * @returns {Function|undefined} + * @private + */ +function getGroupedDataPointsFn(d) { + const $$ = this; + let fn; + + if ($$.isLineType(d)) { + fn = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType)); + } else if ($$.isBarType(d)) { + fn = $$.generateGetBarPoints($$.getShapeIndices($$.isBarType)); + } + + return fn; +} + export interface IOffset { _$width: number; _$total: number[] @@ -376,6 +396,27 @@ export default { }; }, + /** + * Get data's y coordinate + * @param {object} d Target data + * @param {number} i Index number + * @returns {number} y coordinate + * @private + */ + circleY(d: IDataRow, i: number): number { + const $$ = this; + const id = d.id; + let points; + + if ($$.isGrouped(id)) { + points = getGroupedDataPointsFn.bind($$)(d); + } + + return points ? + points(d, i)[0][1] : + $$.getYScaleById(id)($$.getBaseValue(d)); + }, + getBarW(type, axis, targetsNum: number): number | IOffset { const $$ = this; const {config, org, scale} = $$; diff --git a/test/internals/tooltip-spec.ts b/test/internals/tooltip-spec.ts index 9374c088d..3a933add4 100644 --- a/test/internals/tooltip-spec.ts +++ b/test/internals/tooltip-spec.ts @@ -1763,7 +1763,7 @@ describe("TOOLTIP", function() { x: { type: "timeseries", tick: { - format: "%Y-%m-%d", + format: "%Y-%m-%d", } } }