UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

1,169 lines (1,157 loc) • 43 kB
/** * DevExtreme (esm/__internal/viz/series/base_series.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { noop as _noop } from "../../core/utils/m_common"; import { extend as _extend } from "../../core/utils/m_extend"; import { each as _each } from "../../core/utils/m_iterator"; import { isDefined as _isDefined, isEmptyObject as _isEmptyObject, isFunction } from "../../core/utils/m_type"; import consts from "../../viz/components/consts"; import { normalizeEnum as _normalizeEnum } from "../../viz/core/utils"; import * as areaSeries from "./area_series"; import * as barSeries from "./bar_series"; import { chart as bubbleSeriesChart } from "./bubble_series"; import * as financialSeries from "./financial_series"; import rangeCalculator from "./helpers/range_data_calculator"; import * as lineSeries from "./line_series"; import * as pieSeries from "./pie_series"; import { Point } from "./points/base_point"; import { chart as rangeSeriesChart } from "./range_series"; import * as scatterSeries from "./scatter_series"; import * as stackedSeries from "./stacked_series"; const seriesNS = {}; const states = consts.states; const DISCRETE = "discrete"; const SELECTED_STATE = states.selectedMark; const HOVER_STATE = states.hoverMark; const HOVER = states.hover; const NORMAL = states.normal; const SELECTION = states.selection; const APPLY_SELECTED = states.applySelected; const APPLY_HOVER = states.applyHover; const RESET_ITEM = states.resetItem; const NONE_MODE = "none"; const INCLUDE_POINTS = "includepoints"; const NEAREST_POINT = "nearestpoint"; const SERIES_SELECTION_CHANGED = "seriesSelectionChanged"; const POINT_SELECTION_CHANGED = "pointSelectionChanged"; const SERIES_HOVER_CHANGED = "seriesHoverChanged"; const POINT_HOVER_CHANGED = "pointHoverChanged"; const ALL_SERIES_POINTS = "allseriespoints"; const ALL_ARGUMENT_POINTS = "allargumentpoints"; const POINT_HOVER = "pointHover"; const CLEAR_POINT_HOVER = "clearPointHover"; const SERIES_SELECT = "seriesSelect"; const POINT_SELECT = "pointSelect"; const POINT_DESELECT = "pointDeselect"; const getEmptyBusinessRange = function() { return { arg: {}, val: {} } }; function triggerEvent(element, event, point) { element && element.trigger(event, point) } seriesNS.mixins = { chart: {}, pie: {}, polar: {} }; seriesNS.mixins.chart.scatter = scatterSeries.chart; seriesNS.mixins.polar.scatter = scatterSeries.polar; _extend(seriesNS.mixins.pie, pieSeries); _extend(seriesNS.mixins.chart, lineSeries.chart, areaSeries.chart, barSeries.chart, rangeSeriesChart, bubbleSeriesChart, financialSeries, stackedSeries.chart); _extend(seriesNS.mixins.polar, lineSeries.polar, areaSeries.polar, barSeries.polar, stackedSeries.polar); function includePointsMode(mode) { mode = _normalizeEnum(mode); return mode === INCLUDE_POINTS || "allseriespoints" === mode } function getLabelOptions(labelOptions, defaultColor) { const opt = labelOptions || {}; const labelFont = _extend({}, opt.font) || {}; const labelBorder = opt.border || {}; const labelConnector = opt.connector || {}; const backgroundAttr = { fill: opt.backgroundColor || defaultColor, "stroke-width": labelBorder.visible ? labelBorder.width || 0 : 0, stroke: labelBorder.visible && labelBorder.width ? labelBorder.color : "none", dashStyle: labelBorder.dashStyle }; const connectorAttr = { stroke: labelConnector.visible && labelConnector.width ? labelConnector.color || defaultColor : "none", "stroke-width": labelConnector.visible ? labelConnector.width || 0 : 0 }; labelFont.color = "none" === opt.backgroundColor && "#ffffff" === _normalizeEnum(labelFont.color) && "inside" !== opt.position ? defaultColor : labelFont.color; return { alignment: opt.alignment, format: opt.format, argumentFormat: opt.argumentFormat, customizeText: isFunction(opt.customizeText) ? opt.customizeText : void 0, attributes: { font: labelFont }, visible: 0 !== labelFont.size ? opt.visible : false, showForZeroValues: opt.showForZeroValues, horizontalOffset: opt.horizontalOffset, verticalOffset: opt.verticalOffset, radialOffset: opt.radialOffset, background: backgroundAttr, position: opt.position, connector: connectorAttr, rotationAngle: opt.rotationAngle, wordWrap: opt.wordWrap, textOverflow: opt.textOverflow, cssClass: opt.cssClass, displayFormat: opt.displayFormat } } function setPointHoverState(point, legendCallback) { point.fullState |= HOVER_STATE; point.applyView(legendCallback) } function releasePointHoverState(point, legendCallback) { point.fullState &= ~HOVER_STATE; point.applyView(legendCallback); point.releaseHoverState() } function setPointSelectedState(point, legendCallback) { point.fullState |= SELECTED_STATE; point.applyView(legendCallback) } function releasePointSelectedState(point, legendCallback) { point.fullState &= ~SELECTED_STATE; point.applyView(legendCallback) } function mergePointOptionsCore(base, extra) { const options = _extend({}, base, extra); options.border = _extend({}, base && base.border, extra && extra.border); return options } function mergePointOptions(base, extra) { const options = mergePointOptionsCore(base, extra); options.image = _extend(true, {}, base.image, extra.image); options.selectionStyle = mergePointOptionsCore(base.selectionStyle, extra.selectionStyle); options.hoverStyle = mergePointOptionsCore(base.hoverStyle, extra.hoverStyle); return options } function getData(pointData) { return pointData.data } function getValueChecker(axisType, axis) { if (!axis || "logarithmic" !== axisType || false !== axis.getOptions().allowNegatives) { return () => true } else { return value => value > 0 } } export let Series = class { constructor(settings, options) { this.fullState = 0; this._extGroups = settings; this._renderer = settings.renderer; this._group = settings.renderer.g().attr({ class: "dxc-series" }); this._eventTrigger = settings.eventTrigger; this._eventPipe = settings.eventPipe; this._incidentOccurred = settings.incidentOccurred; this._legendCallback = _noop; this.updateOptions(options, settings) } getLegendStyles() { return this._styles.legendStyles } _createStyles(options) { const mainSeriesColor = options.mainSeriesColor; const colorId = this._getColorId(options); const hoverStyle = options.hoverStyle || {}; const selectionStyle = options.selectionStyle || {}; if (colorId) { this._turnOffHatching(hoverStyle, selectionStyle) } this._styles = { labelColor: mainSeriesColor, normal: this._parseStyle(options, mainSeriesColor, mainSeriesColor), hover: this._parseStyle(hoverStyle, colorId || mainSeriesColor, mainSeriesColor), selection: this._parseStyle(selectionStyle, colorId || mainSeriesColor, mainSeriesColor), legendStyles: { normal: this._createLegendState(options, colorId || mainSeriesColor), hover: this._createLegendState(hoverStyle, colorId || mainSeriesColor), selection: this._createLegendState(selectionStyle, colorId || mainSeriesColor) } } } setClippingParams(baseId, wideId, forceClipping) { let clipLabels = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : true; this._paneClipRectID = baseId; this._widePaneClipRectID = wideId; this._forceClipping = forceClipping; this._clipLabels = clipLabels } applyClip() { this._group.attr({ "clip-path": this._paneClipRectID }) } resetClip() { this._group.attr({ "clip-path": null }) } getTagField() { return this._options.tagField || "tag" } getPoints() { return this._points } getPointsInViewPort() { return rangeCalculator.getPointsInViewPort(this) } _createPoint(data, index, oldPoint) { data.index = index; const pointsByArgument = this.pointsByArgument; const options = this._getCreatingPointOptions(data); const arg = data.argument.valueOf(); let point = oldPoint; if (point) { point.update(data, options) } else { point = new Point(this, data, options); if (this.isSelected() && includePointsMode(this.lastSelectionMode)) { point.setView(SELECTION) } } const pointByArgument = pointsByArgument[arg]; if (pointByArgument) { pointByArgument.push(point) } else { pointsByArgument[arg] = [point] } if (point.hasValue()) { this.customizePoint(point, data) } return point } getRangeData() { return this._visible ? this._getRangeData() : getEmptyBusinessRange() } getArgumentRange() { return this._visible ? rangeCalculator.getArgumentRange(this) : getEmptyBusinessRange() } getViewport() { return rangeCalculator.getViewport(this) } _deleteGroup(groupName) { const group = this[groupName]; if (group) { group.dispose(); this[groupName] = null } } updateOptions(newOptions, settings) { const widgetType = newOptions.widgetType; const oldType = this.type; const newType = newOptions.type; this.type = newType && _normalizeEnum(newType.toString()); if (!this._checkType(widgetType) || this._checkPolarBarType(widgetType, newOptions)) { this.dispose(); this.isUpdated = false; return } if (oldType !== this.type) { this._firstDrawing = true; this._resetType(oldType, widgetType); this._setType(this.type, widgetType) } else { this._defineDrawingState() } this._options = newOptions; this._pointOptions = null; this.name = newOptions.name; this.pane = newOptions.pane; this.tag = newOptions.tag; if (settings) { this._seriesModes = settings.commonSeriesModes || this._seriesModes; this._valueAxis = settings.valueAxis || this._valueAxis; this.axis = this._valueAxis && this._valueAxis.name; this._argumentAxis = settings.argumentAxis || this._argumentAxis } this._createStyles(newOptions); this._stackName = null; this._updateOptions(newOptions); this._visible = newOptions.visible; this.isUpdated = true; this.stack = newOptions.stack; this.barOverlapGroup = newOptions.barOverlapGroup; this._createGroups(); this._processEmptyValue = newOptions.ignoreEmptyPoints ? x => null === x ? void 0 : x : x => x } _defineDrawingState() { this._firstDrawing = true } _disposePoints(points) { _each(points || [], (_, p) => { p.dispose() }) } updateDataType(settings) { this.argumentType = settings.argumentType; this.valueType = settings.valueType; this.argumentAxisType = settings.argumentAxisType; this.valueAxisType = settings.valueAxisType; this.showZero = settings.showZero; this._argumentChecker = getValueChecker(settings.argumentAxisType, this.getArgumentAxis()); this._valueChecker = getValueChecker(settings.valueAxisType, this.getValueAxis()); return this } _argumentChecker() { return true } _valueChecker() { return true } getOptions() { return this._options } _getOldPoint(data, oldPointsByArgument, index) { const arg = data.argument && data.argument.valueOf(); const point = (oldPointsByArgument[arg] || [])[0]; if (point) { oldPointsByArgument[arg].splice(0, 1) } return point } updateData(data) { const options = this._options; const nameField = options.nameField; data = data || []; if (data.length) { this._canRenderCompleteHandle = true } const dataSelector = this._getPointDataSelector(); let itemsWithoutArgument = 0; this._data = data.reduce((data, dataItem, index) => { const pointDataItem = dataSelector(dataItem); if (_isDefined(pointDataItem.argument)) { if (!nameField || dataItem[nameField] === options.nameFieldValue) { pointDataItem.index = index; data.push(pointDataItem) } } else { itemsWithoutArgument++ } return data }, []); if (itemsWithoutArgument && itemsWithoutArgument === data.length) { this._incidentOccurred("W2002", [this.name, this.getArgumentField()]) } this._endUpdateData() } _getData() { let data = this._data || []; if (this.useAggregation()) { const aggregateByCategory = this.argumentAxisType === DISCRETE; const argumentRange = aggregateByCategory ? {} : this.getArgumentRange(); const aggregationInfo = aggregateByCategory ? {} : this.getArgumentAxis().getAggregationInfo(this._useAllAggregatedPoints, argumentRange); data = this._resample(aggregationInfo, data) } return data } useAggregation() { const aggregation = this.getOptions().aggregation; return aggregation && aggregation.enabled } createPoints(useAllAggregatedPoints) { this._normalizeUsingAllAggregatedPoints(useAllAggregatedPoints); this._createPoints() } _normalizeUsingAllAggregatedPoints(useAllAggregatedPoints) { this._useAllAggregatedPoints = this.useAggregation() && (this.argumentAxisType === DISCRETE || (this._data || []).length > 1 && !!useAllAggregatedPoints) } _createPoints() { const oldPointsByArgument = this.pointsByArgument || {}; const data = this._getData(); this.pointsByArgument = {}; this._calculateErrorBars(data); const skippedFields = {}; const points = data.reduce((points, pointDataItem) => { if (this._checkData(pointDataItem, skippedFields)) { const pointIndex = points.length; const oldPoint = this._getOldPoint(pointDataItem, oldPointsByArgument, pointIndex); const point = this._createPoint(pointDataItem, pointIndex, oldPoint); points.push(point) } return points }, []); for (const field in skippedFields) { if (skippedFields[field] === data.length) { this._incidentOccurred("W2002", [this.name, field]) } } Object.keys(oldPointsByArgument).forEach(key => this._disposePoints(oldPointsByArgument[key])); this._points = points } _removeOldSegments() { const startIndex = this._segments.length; _each(this._graphics.splice(startIndex, this._graphics.length) || [], (_, elem) => { this._removeElement(elem) }); if (this._trackers) { _each(this._trackers.splice(startIndex, this._trackers.length) || [], (_, elem) => { elem.remove() }) } } _prepareSegmentsPosition() { const points = this._points || []; const isCloseSegment = points[0] && points[0].hasValue() && this._options.closed; const segments = points.reduce((segments, p) => { const segment = segments.at(-1); if (!p.translated) { p.setDefaultCoords() } if (p.hasValue() && p.hasCoords()) { segment.push(p) } else if (!p.hasValue() && segment.length) { segments.push([]) } return segments }, [ [] ]); this._drawSegments(segments, isCloseSegment, false) } _drawElements(animationEnabled, firstDrawing) { const points = this._points || []; const isCloseSegment = points[0] && points[0].hasValue() && this._options.closed; const groupForPoint = { markers: this._markersGroup, errorBars: this._errorBarGroup }; this._drawnPoints = []; this._graphics = this._graphics || []; this._segments = []; const segments = points.reduce((segments, p) => { const segment = segments.at(-1); if (p.hasValue() && p.hasCoords()) { this._drawPoint({ point: p, groups: groupForPoint, hasAnimation: animationEnabled, firstDrawing: firstDrawing }); segment.push(p) } else if (!p.hasValue()) { segment.length && segments.push([]) } else { p.setInvisibility() } return segments }, [ [] ]); this._drawSegments(segments, isCloseSegment, animationEnabled); this._firstDrawing = !points.length; this._removeOldSegments(); animationEnabled && this._animate(firstDrawing) } _drawSegments(segments, closeSegment, animationEnabled) { segments.forEach((segment, index) => { if (segment.length) { const lastSegment = closeSegment && index === segments.length - 1; this._drawSegment(segment, animationEnabled, index, lastSegment) } }) } draw(animationEnabled, hideLayoutLabels, legendCallback) { const firstDrawing = this._firstDrawing; this._legendCallback = legendCallback || this._legendCallback; if (!this._visible) { this._group.remove(); return } this._appendInGroup(); if (!this._isAllPointsTranslated) { this.prepareCoordinatesForPoints() } this._setGroupsSettings(animationEnabled, firstDrawing); !firstDrawing && !this._resetApplyingAnimation && this._prepareSegmentsPosition(); this._drawElements(animationEnabled, firstDrawing); hideLayoutLabels && this.hideLabels(); if (this.isSelected()) { this._changeStyle(this.lastSelectionMode, void 0, true) } else if (this.isHovered()) { this._changeStyle(this.lastHoverMode, void 0, true) } else { this._applyStyle(this._styles.normal) } this._isAllPointsTranslated = false; this._resetApplyingAnimation = false } _translatePoints() { const points = this._points ?? []; points.forEach(p => { p.translate() }) } prepareCoordinatesForPoints() { this._applyVisibleArea(); this._translatePoints(); this._isAllPointsTranslated = true } _setLabelGroupSettings(animationEnabled) { const settings = { class: "dxc-labels", "pointer-events": "none" }; this._clipLabels && this._applyElementsClipRect(settings); this._applyClearingSettings(settings); animationEnabled && (settings.opacity = .001); this._labelsGroup.attr(settings).append(this._extGroups.labelsGroup) } _checkType(widgetType) { return !!seriesNS.mixins[widgetType][this.type] } _checkPolarBarType(widgetType, options) { return "polar" === widgetType && options.spiderWidget && -1 !== this.type.indexOf("bar") } _resetType(seriesType, widgetType) { let methodName; let methods; if (seriesType) { methods = seriesNS.mixins[widgetType][seriesType]; for (methodName in methods) { delete this[methodName] } } } _setType(seriesType, widgetType) { let methodName; const methods = seriesNS.mixins[widgetType][seriesType]; for (methodName in methods) { this[methodName] = methods[methodName] } } _setPointsView(view, target) { this.getPoints().forEach(point => { if (target !== point) { point.setView(view) } }) } _resetPointsView(view, target) { this.getPoints().forEach(point => { if (target !== point) { point.resetView(view) } }) } _resetNearestPoint() { this._nearestPoint && null !== this._nearestPoint.series && this._nearestPoint.resetView(HOVER); this._nearestPoint = null } _setSelectedState(mode) { this.lastSelectionMode = _normalizeEnum(mode || this._options.selectionMode); this.fullState |= SELECTED_STATE; this._resetNearestPoint(); this._changeStyle(this.lastSelectionMode); if ("none" !== this.lastSelectionMode && this.isHovered() && includePointsMode(this.lastHoverMode)) { this._resetPointsView(HOVER) } } _releaseSelectedState() { this.fullState &= ~SELECTED_STATE; this._changeStyle(this.lastSelectionMode, SELECTION); if ("none" !== this.lastSelectionMode && this.isHovered() && includePointsMode(this.lastHoverMode)) { this._setPointsView(HOVER) } } isFullStackedSeries() { return 0 === this.type.indexOf("fullstacked") } isStackedSeries() { return 0 === this.type.indexOf("stacked") } resetApplyingAnimation(isFirstDrawing) { this._resetApplyingAnimation = true; if (isFirstDrawing) { this._firstDrawing = true } } isFinancialSeries() { return "stock" === this.type || "candlestick" === this.type } _canChangeView() { return !this.isSelected() && "none" !== _normalizeEnum(this._options.hoverMode) } _changeStyle(mode, resetView, skipPoints) { let state = this.fullState; const styles = [NORMAL, HOVER, SELECTION, SELECTION]; if ("none" === this.lastHoverMode) { state &= ~HOVER_STATE } if ("none" === this.lastSelectionMode) { state &= ~SELECTED_STATE } if (includePointsMode(mode) && !skipPoints) { if (!resetView) { this._setPointsView(styles[state]) } else { this._resetPointsView(resetView) } } this._legendCallback([RESET_ITEM, APPLY_HOVER, APPLY_SELECTED, APPLY_SELECTED][state]); this._applyStyle(this._styles[styles[state]]) } updateHover(x, y) { const currentNearestPoint = this._nearestPoint; const point = this.isHovered() && this.lastHoverMode === NEAREST_POINT && this.getNeighborPoint(x, y); if (point !== currentNearestPoint && !(this.isSelected() && "none" !== this.lastSelectionMode)) { this._resetNearestPoint(); if (point) { point.setView(HOVER); this._nearestPoint = point } } } _getMainAxisName() { return this._options.rotated ? "X" : "Y" } areLabelsVisible() { return !_isDefined(this._options.maxLabelCount) || this._points.length <= this._options.maxLabelCount } getLabelVisibility() { return this.areLabelsVisible() && this._options.label && this._options.label.visible } customizePoint(point, pointData) { const options = this._options; const customizePoint = options.customizePoint; let customizeObject; let pointOptions; let customLabelOptions; let customOptions; const customizeLabel = options.customizeLabel; let useLabelCustomOptions; let usePointCustomOptions; if (customizeLabel && customizeLabel.call) { customizeObject = _extend({ seriesName: this.name }, pointData); customizeObject.series = this; customLabelOptions = customizeLabel.call(customizeObject, customizeObject); useLabelCustomOptions = customLabelOptions && !_isEmptyObject(customLabelOptions); customLabelOptions = useLabelCustomOptions ? _extend(true, {}, options.label, customLabelOptions) : null } if (customizePoint && customizePoint.call) { customizeObject = customizeObject || _extend({ seriesName: this.name }, pointData); customizeObject.series = this; customOptions = customizePoint.call(customizeObject, customizeObject); usePointCustomOptions = customOptions && !_isEmptyObject(customOptions) } if (useLabelCustomOptions || usePointCustomOptions) { pointOptions = this._parsePointOptions(this._preparePointOptions(customOptions), customLabelOptions || options.label, pointData, point); pointOptions.styles.useLabelCustomOptions = useLabelCustomOptions; pointOptions.styles.usePointCustomOptions = usePointCustomOptions; point.updateOptions(pointOptions) } } show() { if (!this._visible) { this._changeVisibility(true) } } hide() { if (this._visible) { this._changeVisibility(false) } } _changeVisibility(visibility) { this._visible = this._options.visible = visibility; this._updatePointsVisibility(); this.hidePointTooltip(); this._options.visibilityChanged(this) } hideLabels() { _each(this._points, (_, point) => { point._label.draw(false) }) } _turnOffHatching(hoverStyle, selectionStyle) { if (hoverStyle.hatching) { hoverStyle.hatching.direction = "none" } if (selectionStyle.hatching) { selectionStyle.hatching.direction = "none" } } _parsePointOptions(pointOptions, labelOptions, data, point) { const options = this._options; const styles = this._createPointStyles(pointOptions, data, point); const parsedOptions = _extend({}, pointOptions, { type: options.type, rotated: options.rotated, styles: styles, widgetType: options.widgetType, visibilityChanged: options.visibilityChanged }); parsedOptions.label = getLabelOptions(labelOptions, styles.labelColor); if (this.areErrorBarsVisible()) { parsedOptions.errorBars = options.valueErrorBar } return parsedOptions } _preparePointOptions(customOptions) { const pointOptions = this._getOptionsForPoint(); return customOptions ? mergePointOptions(pointOptions, customOptions) : pointOptions } _getMarkerGroupOptions() { return _extend(false, {}, this._getOptionsForPoint(), { hoverStyle: {}, selectionStyle: {} }) } _getAggregationMethod(isValueAxisDiscrete) { const options = this.getOptions().aggregation; const method = _normalizeEnum(options.method); const customAggregator = "custom" === method && options.calculate; if (customAggregator) { return customAggregator } if (isValueAxisDiscrete) { return _ref => { let { data: data } = _ref; return data[0] } } return this._aggregators[method] || this._aggregators[this._defaultAggregator] } _resample(_ref2, data) { let { interval: interval, ticks: ticks } = _ref2; const options = this.getOptions(); const dataSelector = this._getPointDataSelector(); const addAggregatedData = (target, data, aggregationInfo) => { if (!data) { return } const processData = d => { const pointData = d && dataSelector(d, options); if (pointData && this._checkData(pointData)) { pointData.aggregationInfo = aggregationInfo; target.push(pointData) } }; if (Array.isArray(data)) { data.forEach(processData) } else { processData(data) } }; const isValueAxisDiscrete = this.valueAxisType === DISCRETE; const aggregateByCategory = this.argumentAxisType === DISCRETE; const aggregationMethod = this._getAggregationMethod(isValueAxisDiscrete); if (aggregateByCategory) { const categories = this.getArgumentAxis().getTranslator().getBusinessRange().categories; const groups = categories.reduce((g, category) => { g[category.valueOf()] = []; return g }, {}); data.forEach(dataItem => { groups[dataItem.argument.valueOf()].push(dataItem) }); return categories.reduce((result, c) => { addAggregatedData(result, aggregationMethod({ aggregationInterval: null, intervalStart: c, intervalEnd: c, data: groups[c.valueOf()].map(getData) }, this)); return result }, []) } if (isValueAxisDiscrete) { return data.reduce((result, dataItem, index, data) => { result[1].push(dataItem); if (index === data.length - 1 || (index + 1) % interval === 0) { const dataInInterval = result[1]; const aggregationInfo = { aggregationInterval: interval, data: dataInInterval.map(getData) }; addAggregatedData(result[0], aggregationMethod(aggregationInfo, this)); result[1] = [] } return result }, [ [], [] ])[0] } const aggregatedData = []; if (1 === ticks.length) { const aggregationInfo = { intervalStart: ticks[0], intervalEnd: ticks[0], aggregationInterval: null, data: data.map(getData) }; addAggregatedData(aggregatedData, aggregationMethod(aggregationInfo, this), aggregationInfo) } else { let dataIndex = 0; for (let i = 1; i < ticks.length; i++) { const intervalEnd = ticks[i]; const intervalStart = ticks[i - 1]; const dataInInterval = []; while (data[dataIndex] && data[dataIndex].argument < intervalEnd) { if (data[dataIndex].argument >= intervalStart) { dataInInterval.push(data[dataIndex]) } dataIndex++ } const aggregationInfo = { intervalStart: intervalStart, intervalEnd: intervalEnd, aggregationInterval: interval, data: dataInInterval.map(getData) }; addAggregatedData(aggregatedData, aggregationMethod(aggregationInfo, this), aggregationInfo) } } this._endUpdateData(); return aggregatedData } canRenderCompleteHandle() { const result = this._canRenderCompleteHandle; delete this._canRenderCompleteHandle; return !!result } isHovered() { return !!(1 & this.fullState) } isSelected() { return !!(2 & this.fullState) } isVisible() { return this._visible } getAllPoints() { this._createAllAggregatedPoints(); return (this._points || []).slice() } getPointByPos(pos) { this._createAllAggregatedPoints(); return (this._points || [])[pos] } getVisiblePoints() { return (this._drawnPoints || []).slice() } selectPoint(point) { if (!point.isSelected()) { setPointSelectedState(point, this._legendCallback); this._eventPipe({ action: POINT_SELECT, target: point }); this._eventTrigger("pointSelectionChanged", { target: point }) } } deselectPoint(point) { if (point.isSelected()) { releasePointSelectedState(point, this._legendCallback); this._eventPipe({ action: POINT_DESELECT, target: point }); this._eventTrigger("pointSelectionChanged", { target: point }) } } hover(mode) { const eventTrigger = this._eventTrigger; if (this.isHovered()) { return } this.lastHoverMode = _normalizeEnum(mode || this._options.hoverMode); this.fullState |= HOVER_STATE; this._changeStyle(this.lastHoverMode, void 0, this.isSelected() && "none" !== this.lastSelectionMode); eventTrigger("seriesHoverChanged", { target: this }) } clearHover() { const eventTrigger = this._eventTrigger; if (!this.isHovered()) { return } this._resetNearestPoint(); this.fullState &= ~HOVER_STATE; this._changeStyle(this.lastHoverMode, HOVER, this.isSelected() && "none" !== this.lastSelectionMode); eventTrigger("seriesHoverChanged", { target: this }) } hoverPoint(point) { if (!point.isHovered()) { point.clearHover(); setPointHoverState(point, this._legendCallback); this._canChangeView() && this._applyStyle(this._styles.hover); this._eventPipe({ action: POINT_HOVER, target: point }); this._eventTrigger("pointHoverChanged", { target: point }) } } clearPointHover() { this.getPoints().some(currentPoint => { if (currentPoint.isHovered()) { releasePointHoverState(currentPoint, this._legendCallback); this._canChangeView() && this._applyStyle(this._styles.normal); this._eventPipe({ action: "clearPointHover", target: currentPoint }); this._eventTrigger("pointHoverChanged", { target: currentPoint }); return true } return false }) } showPointTooltip(point) { triggerEvent(this._extGroups.seriesGroup, "showpointtooltip", point) } hidePointTooltip(point) { triggerEvent(this._extGroups.seriesGroup, "hidepointtooltip", point) } select() { if (!this.isSelected()) { this._setSelectedState(this._options.selectionMode); this._eventPipe({ action: SERIES_SELECT, target: this }); this._group.toForeground(); this._eventTrigger("seriesSelectionChanged", { target: this }) } } clearSelection() { if (this.isSelected()) { this._releaseSelectedState(); this._eventTrigger("seriesSelectionChanged", { target: this }) } } getPointsByArg(arg, skipPointsCreation) { const argValue = arg.valueOf(); let points = this.pointsByArgument[argValue]; if (!points && !skipPointsCreation && this._createAllAggregatedPoints()) { points = this.pointsByArgument[argValue] } return points || [] } _createAllAggregatedPoints() { if (this.useAggregation() && !this._useAllAggregatedPoints) { this.createPoints(true); return true } return false } getPointsByKeys(arg) { return this.getPointsByArg(arg) } notify(data) { const action = data.action; const seriesModes = this._seriesModes; const target = data.target; const targetOptions = target.getOptions(); const pointHoverMode = _normalizeEnum(targetOptions.hoverMode); const selectionModeOfPoint = _normalizeEnum(targetOptions.selectionMode); if (action === POINT_HOVER) { this._hoverPointHandler(target, pointHoverMode, data.notifyLegend) } else if ("clearPointHover" === action) { this._clearPointHoverHandler(target, pointHoverMode, data.notifyLegend) } else if (action === SERIES_SELECT) { target !== this && "single" === seriesModes.seriesSelectionMode && this.clearSelection() } else if (action === POINT_SELECT) { if ("single" === seriesModes.pointSelectionMode) { this.getPoints().some(currentPoint => { if (currentPoint !== target && currentPoint.isSelected()) { this.deselectPoint(currentPoint); return true } return false }) } this._selectPointHandler(target, selectionModeOfPoint) } else if (action === POINT_DESELECT) { this._deselectPointHandler(target, selectionModeOfPoint) } } _selectPointHandler(target, mode) { if ("allseriespoints" === mode) { target.series === this && this._setPointsView(SELECTION, target) } else if ("allargumentpoints" === mode) { this.getPointsByKeys(target.argument, target.argumentIndex).forEach(currentPoint => { currentPoint !== target && currentPoint.setView(SELECTION) }) } } _deselectPointHandler(target, mode) { if ("allseriespoints" === mode) { target.series === this && this._resetPointsView(SELECTION, target) } else if ("allargumentpoints" === mode) { this.getPointsByKeys(target.argument, target.argumentIndex).forEach(currentPoint => { currentPoint !== target && currentPoint.resetView(SELECTION) }) } } _hoverPointHandler(target, mode, notifyLegend) { if (target.series !== this && "allargumentpoints" === mode) { this.getPointsByKeys(target.argument, target.argumentIndex).forEach(currentPoint => { currentPoint.setView(HOVER) }); notifyLegend && this._legendCallback(target) } else if ("allseriespoints" === mode && target.series === this) { this._setPointsView(HOVER, target) } } _clearPointHoverHandler(target, mode, notifyLegend) { if ("allargumentpoints" === mode) { target.series !== this && this.getPointsByKeys(target.argument, target.argumentIndex).forEach(currentPoint => { currentPoint.resetView(HOVER) }); notifyLegend && this._legendCallback(target) } else if ("allseriespoints" === mode && target.series === this) { this._resetPointsView(HOVER, target) } } _deletePoints() { this._disposePoints(this._points); this._points = this._drawnPoints = null } _deleteTrackers() { _each(this._trackers || [], (_, tracker) => { tracker.remove() }); this._trackersGroup && this._trackersGroup.dispose(); this._trackers = this._trackersGroup = null } dispose() { this._deletePoints(); this._group.dispose(); this._labelsGroup && this._labelsGroup.dispose(); this._errorBarGroup && this._errorBarGroup.dispose(); this._deleteTrackers(); this._group = this._extGroups = this._markersGroup = this._elementsGroup = this._bordersGroup = this._labelsGroup = this._errorBarGroup = this._graphics = this._rangeData = this._renderer = this._styles = this._options = this._pointOptions = this._drawnPoints = this.pointsByArgument = this._segments = this._prevSeries = null } getMarginOptions() { return this._patchMarginOptions({ percentStick: this.isFullStackedSeries() }) } getColor() { return this.getLegendStyles().normal.fill } getOpacity() { return this._options.opacity } getStackName() { return this._stackName } getBarOverlapGroup() { return this._options.barOverlapGroup } getPointByCoord(x, y) { const point = this.getNeighborPoint(x, y); return null !== point && void 0 !== point && point.coordsIn(x, y) ? point : null } getValueAxis() { return this._valueAxis } getArgumentAxis() { return this._argumentAxis } getMarkersGroup() { return this._markersGroup } getRenderer() { return this._renderer } removePointElements() { if (this._markersGroup) { _each(this._points, (_, p) => p.deleteMarker()); this._markersGroup.dispose(); this._markersGroup = null } } removeGraphicElements() { if (this._elementsGroup) { this._elementsGroup.dispose(); this._elementsGroup = null } _each(this._graphics || [], (_, elem) => { this._removeElement(elem) }); this._graphics = null } removeBordersGroup() { if (this._bordersGroup) { this._bordersGroup.dispose(); this._bordersGroup = null } } }; Object.assign(Series.prototype, { _createLegendState: _noop, getValueFields: _noop, getSizeField: _noop, getArgumentField: _noop, autoHidePointMarkersEnabled: _noop, usePointsToDefineAutoHiding: _noop, _updatePointsVisibility: _noop, correctPosition: _noop, drawTrackers: _noop, getNeighborPoint: _noop, areErrorBarsVisible: _noop, _getColorId: _noop }); export const mixins = seriesNS.mixins;