codeant-ai-for-open-source[bot] commented on code in PR #43863: URL: https://github.com/apache/superset/pull/43863#discussion_r3934406636
########## superset-frontend/plugins/plugin-chart-echarts/src/Candlestick/transformProps.ts: ########## @@ -0,0 +1,512 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { + AxisType, + CurrencyFormatter, + DataRecord, + ensureIsArray, + getColumnLabel, + getMetricLabel, + getNumberFormatter, + getTimeFormatter, + NumberFormatter, + rgbToHex, + tooltipHtml, +} from '@superset-ui/core'; +import { GenericDataType } from '@apache-superset/core/common'; +import type { EChartsCoreOption } from 'echarts/core'; +import type { CandlestickSeriesOption, LineSeriesOption } from 'echarts/charts'; +import type { CallbackDataParams } from 'echarts/types/src/util/types'; +import { + CandlestickChartTransformedProps, + EchartsCandlestickChartProps, +} from './types'; +import { + CANDLESTICK_SERIES_NAME, + DEFAULT_DECREASE_COLOR, + DEFAULT_FORM_DATA, + DEFAULT_INCREASE_COLOR, + DIRECTION_LABELS, + OHLC_LABELS, +} from './constants'; +import { defaultGrid, defaultYAxis } from '../defaults'; +import { getDefaultTooltip } from '../utils/tooltip'; +import { + extractGroupbyLabel, + getChartPadding, + getColtypesMapping, + getLegendProps, +} from '../utils/series'; +import { convertInteger } from '../utils/convertInteger'; +import { mergeCustomEChartOptions } from '../utils/mergeCustomEChartOptions'; +import { safeParseEChartOptions } from '../utils/safeEChartOptionsParser'; +import { NULL_STRING, TIMESERIES_CONSTANTS } from '../constants'; +import { LegendOrientation, LegendType, Refs } from '../types'; +import { resolveLegendLayout } from '../utils/legendLayout'; +import { + calculateMA, + MA_LINE_OPACITY, + movingAverageName, + parseMovingAveragePeriods, +} from './utils'; + +type OhlcValue = [number, number, number, number]; +type CandlestickDatum = NonNullable<CandlestickSeriesOption['data']>[number]; + +function toNumber(value: unknown): number | null { + if (value === null || value === undefined || value === '') { + return null; + } + const numeric = Number(value); + return Number.isFinite(numeric) ? numeric : null; +} + +function getOhlc( + datum: DataRecord, + openLabel: string, + closeLabel: string, + lowLabel: string, + highLabel: string, +): OhlcValue | null { + const open = toNumber(datum[openLabel]); + const close = toNumber(datum[closeLabel]); + const low = toNumber(datum[lowLabel]); + const high = toNumber(datum[highLabel]); + if (open === null || close === null || low === null || high === null) { + return null; + } + return [open, close, low, high]; +} + +function toCandlestickDatum( + datum: DataRecord | undefined, + openLabel: string, + closeLabel: string, + lowLabel: string, + highLabel: string, +): CandlestickDatum { + if (!datum) { + return []; + } + return getOhlc(datum, openLabel, closeLabel, lowLabel, highLabel) ?? []; +} + +function extractOhlc(value: unknown): OhlcValue | null { + if (!Array.isArray(value)) { + return null; + } + const raw = value.length >= 5 ? value.slice(1, 5) : value.slice(0, 4); + if (raw.length !== 4) { + return null; + } + const [open, close, low, high] = raw.map(item => Number(item)); + if ([open, close, low, high].some(item => !Number.isFinite(item))) { + return null; + } + return [open, close, low, high]; +} + +function formatTooltip({ + params, + numberFormatter, + title, + increaseLabel, + decreaseLabel, +}: { + params: CallbackDataParams[]; + numberFormatter: NumberFormatter | CurrencyFormatter; + title: string; + increaseLabel: string; + decreaseLabel: string; +}) { + const rows: string[][] = []; + let heading = title; + const candle = params.find(item => extractOhlc(item.value ?? item.data)); + if (candle) { + const ohlc = extractOhlc(candle.value ?? candle.data); + if (ohlc) { + const [open, close, low, high] = ohlc; + const direction = close >= open ? increaseLabel : decreaseLabel; + heading = title ? `${title} (${direction})` : direction; + rows.push( + [OHLC_LABELS.OPEN, numberFormatter(open)], + [OHLC_LABELS.CLOSE, numberFormatter(close)], + [OHLC_LABELS.LOW, numberFormatter(low)], + [OHLC_LABELS.HIGH, numberFormatter(high)], + ); + } + } + params.forEach(item => { + if (item.seriesType !== 'line') { + return; + } + const value = Number(item.value); + if (!Number.isFinite(value)) { + return; + } + rows.push([String(item.seriesName ?? ''), numberFormatter(value)]); + }); + if (!rows.length) { + return ''; + } + return tooltipHtml(rows, heading); +} + +export default function transformProps( + chartProps: EchartsCandlestickChartProps, +): CandlestickChartTransformedProps { + const { + width, + height, + formData: { echartOptions: customEchartOptionsInput, ...rawFormData }, + hooks, + queriesData, + inContextMenu, + theme, + legendState = {}, + } = chartProps; + const formData = { + ...DEFAULT_FORM_DATA, + ...rawFormData, + }; + const [queryData] = queriesData; + const { data = [] } = queryData; + const { onLegendStateChanged } = hooks; + const refs: Refs = {}; + const coltypeMapping = getColtypesMapping(queryData); + + const { + xAxis, + open, + close, + high, + low, + series: seriesControl, + increaseColor = DEFAULT_INCREASE_COLOR, + decreaseColor = DEFAULT_DECREASE_COLOR, + increaseLabel, + decreaseLabel, + showXAxis, + showYAxis, + xAxisTimeFormat, + xAxisTitle, + xAxisTitleMargin, + xAxisLabelRotation, + xAxisLabelInterval, + yAxisTitle, + yAxisTitleMargin, + yAxisTitlePosition, + yAxisFormat, + currencyFormat, + tooltipTimeFormat, + tooltipValuesFormat, + showLegend, + legendMargin, + legendOrientation = LegendOrientation.Top, + legendType = LegendType.Scroll, + legendSort, + zoomable, + movingAverages, + } = formData; + + const xAxisName = xAxis ? getColumnLabel(xAxis) : ''; + const seriesColumns = ensureIsArray(seriesControl).map(getColumnLabel); + const [seriesName] = seriesColumns; + const openLabel = open ? getMetricLabel(open) : ''; + const closeLabel = close ? getMetricLabel(close) : ''; + const highLabel = high ? getMetricLabel(high) : ''; + const lowLabel = low ? getMetricLabel(low) : ''; + const timeFormatter = getTimeFormatter(tooltipTimeFormat || xAxisTimeFormat); + const axisTimeFormatter = getTimeFormatter(xAxisTimeFormat); + const numberFormatter = currencyFormat?.symbol + ? new CurrencyFormatter({ + d3Format: tooltipValuesFormat || yAxisFormat, + currency: currencyFormat, + }) + : getNumberFormatter(tooltipValuesFormat || yAxisFormat); + const yAxisFormatter = currencyFormat?.symbol + ? new CurrencyFormatter({ + d3Format: yAxisFormat, + currency: currencyFormat, + }) + : getNumberFormatter(yAxisFormat); + + const increaseHex = rgbToHex( + increaseColor.r, + increaseColor.g, + increaseColor.b, + ); + const decreaseHex = rgbToHex( + decreaseColor.r, + decreaseColor.g, + decreaseColor.b, + ); + const upLabel = increaseLabel || DIRECTION_LABELS.INCREASE; + const downLabel = decreaseLabel || DIRECTION_LABELS.DECREASE; + + const xKeys: string[] = []; + const xLabels: string[] = []; + const xKeySet = new Set<string>(); + data.forEach(datum => { + const raw = datum[xAxisName]; + const key = raw == null ? NULL_STRING : String(raw); + if (xKeySet.has(key)) { + return; + } + xKeySet.add(key); + xKeys.push(key); + xLabels.push( + coltypeMapping[xAxisName] === GenericDataType.Temporal + ? extractGroupbyLabel({ + datum, + groupby: [xAxisName], + coltypeMapping, + timeFormatter: axisTimeFormatter, + }) + : extractGroupbyLabel({ + datum, + groupby: [xAxisName], + coltypeMapping, + }), + ); + }); + + const seriesNames = seriesName + ? [ + ...new Set( + data.map(datum => + datum[seriesName] == null ? NULL_STRING : String(datum[seriesName]), + ), + ), + ] + : [CANDLESTICK_SERIES_NAME]; + + const recordsBySeriesAndX = new Map<string, DataRecord>(); + data.forEach(datum => { + const xKey = + datum[xAxisName] == null ? NULL_STRING : String(datum[xAxisName]); + const seriesKey = seriesName + ? datum[seriesName] == null + ? NULL_STRING + : String(datum[seriesName]) + : seriesNames[0]; + recordsBySeriesAndX.set(`${seriesKey}::${xKey}`, datum); Review Comment: **Suggestion:** Joining series and x-axis values with `::` causes distinct values containing that separator to share one key, so one candle silently replaces another. [logic error] **Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f43b8dd417c844ccbdf24ff8541bddde&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f43b8dd417c844ccbdf24ff8541bddde&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/plugins/plugin-chart-echarts/src/Candlestick/transformProps.ts **Line:** 300:309 **Comment:** *Logic Error: Joining series and x-axis values with `::` causes distinct values containing that separator to share one key, so one candle silently replaces another. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43863&comment_hash=683a3828c6e5f8e2a86b9e228999cd58d17a5df3678d62455ede1be33dd78ff3&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43863&comment_hash=683a3828c6e5f8e2a86b9e228999cd58d17a5df3678d62455ede1be33dd78ff3&reaction=dislike'>๐</a> ########## superset-frontend/plugins/plugin-chart-echarts/src/Candlestick/transformProps.ts: ########## @@ -0,0 +1,512 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { + AxisType, + CurrencyFormatter, + DataRecord, + ensureIsArray, + getColumnLabel, + getMetricLabel, + getNumberFormatter, + getTimeFormatter, + NumberFormatter, + rgbToHex, + tooltipHtml, +} from '@superset-ui/core'; +import { GenericDataType } from '@apache-superset/core/common'; +import type { EChartsCoreOption } from 'echarts/core'; +import type { CandlestickSeriesOption, LineSeriesOption } from 'echarts/charts'; +import type { CallbackDataParams } from 'echarts/types/src/util/types'; +import { + CandlestickChartTransformedProps, + EchartsCandlestickChartProps, +} from './types'; +import { + CANDLESTICK_SERIES_NAME, + DEFAULT_DECREASE_COLOR, + DEFAULT_FORM_DATA, + DEFAULT_INCREASE_COLOR, + DIRECTION_LABELS, + OHLC_LABELS, +} from './constants'; +import { defaultGrid, defaultYAxis } from '../defaults'; +import { getDefaultTooltip } from '../utils/tooltip'; +import { + extractGroupbyLabel, + getChartPadding, + getColtypesMapping, + getLegendProps, +} from '../utils/series'; +import { convertInteger } from '../utils/convertInteger'; +import { mergeCustomEChartOptions } from '../utils/mergeCustomEChartOptions'; +import { safeParseEChartOptions } from '../utils/safeEChartOptionsParser'; +import { NULL_STRING, TIMESERIES_CONSTANTS } from '../constants'; +import { LegendOrientation, LegendType, Refs } from '../types'; +import { resolveLegendLayout } from '../utils/legendLayout'; +import { + calculateMA, + MA_LINE_OPACITY, + movingAverageName, + parseMovingAveragePeriods, +} from './utils'; + +type OhlcValue = [number, number, number, number]; +type CandlestickDatum = NonNullable<CandlestickSeriesOption['data']>[number]; + +function toNumber(value: unknown): number | null { + if (value === null || value === undefined || value === '') { + return null; + } + const numeric = Number(value); + return Number.isFinite(numeric) ? numeric : null; +} + +function getOhlc( + datum: DataRecord, + openLabel: string, + closeLabel: string, + lowLabel: string, + highLabel: string, +): OhlcValue | null { + const open = toNumber(datum[openLabel]); + const close = toNumber(datum[closeLabel]); + const low = toNumber(datum[lowLabel]); + const high = toNumber(datum[highLabel]); + if (open === null || close === null || low === null || high === null) { + return null; + } + return [open, close, low, high]; +} + +function toCandlestickDatum( + datum: DataRecord | undefined, + openLabel: string, + closeLabel: string, + lowLabel: string, + highLabel: string, +): CandlestickDatum { + if (!datum) { + return []; + } + return getOhlc(datum, openLabel, closeLabel, lowLabel, highLabel) ?? []; +} + +function extractOhlc(value: unknown): OhlcValue | null { + if (!Array.isArray(value)) { + return null; + } + const raw = value.length >= 5 ? value.slice(1, 5) : value.slice(0, 4); + if (raw.length !== 4) { + return null; + } + const [open, close, low, high] = raw.map(item => Number(item)); + if ([open, close, low, high].some(item => !Number.isFinite(item))) { + return null; + } + return [open, close, low, high]; +} + +function formatTooltip({ + params, + numberFormatter, + title, + increaseLabel, + decreaseLabel, +}: { + params: CallbackDataParams[]; + numberFormatter: NumberFormatter | CurrencyFormatter; + title: string; + increaseLabel: string; + decreaseLabel: string; +}) { + const rows: string[][] = []; + let heading = title; + const candle = params.find(item => extractOhlc(item.value ?? item.data)); + if (candle) { + const ohlc = extractOhlc(candle.value ?? candle.data); + if (ohlc) { + const [open, close, low, high] = ohlc; + const direction = close >= open ? increaseLabel : decreaseLabel; + heading = title ? `${title} (${direction})` : direction; + rows.push( + [OHLC_LABELS.OPEN, numberFormatter(open)], + [OHLC_LABELS.CLOSE, numberFormatter(close)], + [OHLC_LABELS.LOW, numberFormatter(low)], + [OHLC_LABELS.HIGH, numberFormatter(high)], + ); + } + } + params.forEach(item => { + if (item.seriesType !== 'line') { + return; + } + const value = Number(item.value); + if (!Number.isFinite(value)) { + return; + } + rows.push([String(item.seriesName ?? ''), numberFormatter(value)]); + }); + if (!rows.length) { + return ''; + } + return tooltipHtml(rows, heading); +} + +export default function transformProps( + chartProps: EchartsCandlestickChartProps, +): CandlestickChartTransformedProps { + const { + width, + height, + formData: { echartOptions: customEchartOptionsInput, ...rawFormData }, + hooks, + queriesData, + inContextMenu, + theme, + legendState = {}, + } = chartProps; + const formData = { + ...DEFAULT_FORM_DATA, + ...rawFormData, + }; + const [queryData] = queriesData; + const { data = [] } = queryData; + const { onLegendStateChanged } = hooks; + const refs: Refs = {}; + const coltypeMapping = getColtypesMapping(queryData); + + const { + xAxis, + open, + close, + high, + low, + series: seriesControl, + increaseColor = DEFAULT_INCREASE_COLOR, + decreaseColor = DEFAULT_DECREASE_COLOR, + increaseLabel, + decreaseLabel, + showXAxis, + showYAxis, + xAxisTimeFormat, + xAxisTitle, + xAxisTitleMargin, + xAxisLabelRotation, + xAxisLabelInterval, + yAxisTitle, + yAxisTitleMargin, + yAxisTitlePosition, + yAxisFormat, + currencyFormat, + tooltipTimeFormat, + tooltipValuesFormat, + showLegend, + legendMargin, + legendOrientation = LegendOrientation.Top, + legendType = LegendType.Scroll, + legendSort, + zoomable, + movingAverages, + } = formData; + + const xAxisName = xAxis ? getColumnLabel(xAxis) : ''; + const seriesColumns = ensureIsArray(seriesControl).map(getColumnLabel); + const [seriesName] = seriesColumns; + const openLabel = open ? getMetricLabel(open) : ''; + const closeLabel = close ? getMetricLabel(close) : ''; + const highLabel = high ? getMetricLabel(high) : ''; + const lowLabel = low ? getMetricLabel(low) : ''; + const timeFormatter = getTimeFormatter(tooltipTimeFormat || xAxisTimeFormat); + const axisTimeFormatter = getTimeFormatter(xAxisTimeFormat); + const numberFormatter = currencyFormat?.symbol + ? new CurrencyFormatter({ + d3Format: tooltipValuesFormat || yAxisFormat, + currency: currencyFormat, + }) + : getNumberFormatter(tooltipValuesFormat || yAxisFormat); + const yAxisFormatter = currencyFormat?.symbol + ? new CurrencyFormatter({ + d3Format: yAxisFormat, + currency: currencyFormat, + }) + : getNumberFormatter(yAxisFormat); + + const increaseHex = rgbToHex( + increaseColor.r, + increaseColor.g, + increaseColor.b, + ); + const decreaseHex = rgbToHex( + decreaseColor.r, + decreaseColor.g, + decreaseColor.b, + ); + const upLabel = increaseLabel || DIRECTION_LABELS.INCREASE; + const downLabel = decreaseLabel || DIRECTION_LABELS.DECREASE; + + const xKeys: string[] = []; + const xLabels: string[] = []; + const xKeySet = new Set<string>(); + data.forEach(datum => { + const raw = datum[xAxisName]; + const key = raw == null ? NULL_STRING : String(raw); + if (xKeySet.has(key)) { + return; + } + xKeySet.add(key); + xKeys.push(key); + xLabels.push( + coltypeMapping[xAxisName] === GenericDataType.Temporal + ? extractGroupbyLabel({ + datum, + groupby: [xAxisName], + coltypeMapping, + timeFormatter: axisTimeFormatter, + }) + : extractGroupbyLabel({ + datum, + groupby: [xAxisName], + coltypeMapping, + }), + ); + }); + + const seriesNames = seriesName + ? [ + ...new Set( + data.map(datum => + datum[seriesName] == null ? NULL_STRING : String(datum[seriesName]), + ), + ), + ] + : [CANDLESTICK_SERIES_NAME]; + + const recordsBySeriesAndX = new Map<string, DataRecord>(); + data.forEach(datum => { + const xKey = + datum[xAxisName] == null ? NULL_STRING : String(datum[xAxisName]); + const seriesKey = seriesName + ? datum[seriesName] == null + ? NULL_STRING + : String(datum[seriesName]) + : seriesNames[0]; + recordsBySeriesAndX.set(`${seriesKey}::${xKey}`, datum); + }); + + const candlestickSeries: CandlestickSeriesOption[] = seriesNames.map( + name => ({ + name, + type: 'candlestick', + data: xKeys.map(xKey => + toCandlestickDatum( + recordsBySeriesAndX.get(`${name}::${xKey}`), + openLabel, + closeLabel, + lowLabel, + highLabel, + ), + ), + itemStyle: { + color: increaseHex, + color0: decreaseHex, + borderColor: increaseHex, + borderColor0: decreaseHex, + }, + }), + ); + + const periods = parseMovingAveragePeriods(movingAverages); + const qualifyMaNames = seriesNames.length > 1; + const movingAverageSeries: LineSeriesOption[] = candlestickSeries.flatMap( + candle => { + const closes = (candle.data ?? []).map(item => + Array.isArray(item) && Number.isFinite(Number(item[1])) + ? Number(item[1]) + : null, + ); + const seriesLabel = qualifyMaNames ? String(candle.name) : undefined; + return periods.map(period => ({ + name: movingAverageName(period, seriesLabel), + type: 'line' as const, + data: calculateMA(closes, period), + smooth: true, + showSymbol: false, + lineStyle: { + opacity: MA_LINE_OPACITY, + }, + })); + }, + ); + + const legendData = [ + ...seriesNames, + ...movingAverageSeries.map(series => String(series.name)), + ].sort((a, b) => { + if (!legendSort) { + return 0; + } + return legendSort === 'asc' ? a.localeCompare(b) : b.localeCompare(a); + }); + + const { effectiveLegendMargin, effectiveLegendType } = resolveLegendLayout({ + chartHeight: height, + chartWidth: width, + legendItems: legendData, + legendMargin, + orientation: legendOrientation, + show: showLegend, + theme, + type: legendType, + }); + const legendPadding = getChartPadding( + showLegend, + legendOrientation, + effectiveLegendMargin, + undefined, + true, + ); + + const dataZoom = zoomable + ? [ + { + type: 'inside', + xAxisIndex: 0, + filterMode: 'none', + }, + { + type: 'slider', + xAxisIndex: 0, + filterMode: 'none', + bottom: TIMESERIES_CONSTANTS.zoomBottom, + }, + ] + : []; + + const echartOptions: EChartsCoreOption = { + grid: { + ...defaultGrid, + top: theme.sizeUnit * 5 + legendPadding.top, + bottom: + theme.sizeUnit * (showXAxis ? 5 : 3) + + legendPadding.bottom + + convertInteger(xAxisTitleMargin) + + (zoomable ? TIMESERIES_CONSTANTS.gridOffsetBottomZoomable : 0), + left: + theme.sizeUnit * (showYAxis ? 5 : 2) + + legendPadding.left + + convertInteger(yAxisTitleMargin), + right: theme.sizeUnit * 5 + legendPadding.right, + }, + legend: { + ...getLegendProps( + effectiveLegendType, + legendOrientation, + showLegend, + theme, + zoomable, + legendState, + ), + data: legendData, + }, + xAxis: { + show: showXAxis, + type: AxisType.Category, + data: xLabels, + name: xAxisTitle, + nameGap: convertInteger(xAxisTitleMargin), + nameLocation: 'middle', + axisLabel: { + rotate: xAxisLabelRotation, + interval: xAxisLabelInterval === 'auto' ? 'auto' : 0, + hideOverlap: true, + }, + }, + yAxis: { + ...defaultYAxis, + show: showYAxis, + type: AxisType.Value, + name: yAxisTitle, + nameGap: convertInteger(yAxisTitleMargin), + nameLocation: yAxisTitlePosition === 'Left' ? 'middle' : 'end', + axisLabel: { formatter: yAxisFormatter }, + }, + tooltip: { + ...getDefaultTooltip(refs), + trigger: 'axis', + axisPointer: { type: 'shadow' }, + show: !inContextMenu, + formatter: (params: CallbackDataParams | CallbackDataParams[]) => { + const [item] = ensureIsArray(params); + if (!item) { + return ''; + } + const title = + coltypeMapping[xAxisName] === GenericDataType.Temporal + ? extractGroupbyLabel({ + datum: data[item.dataIndex] ?? {}, + groupby: [xAxisName], + coltypeMapping, + timeFormatter, + }) Review Comment: **Suggestion:** Temporal tooltip dates use `dataIndex` against raw rows, but categories are deduplicated by x value; with multiple series, the tooltip can show another row's date. [incorrect variable usage] **Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=527cc68516b8457e802b0753b02f0595&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=527cc68516b8457e802b0753b02f0595&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/plugins/plugin-chart-echarts/src/Candlestick/transformProps.ts **Line:** 459:466 **Comment:** *Incorrect Variable Usage: Temporal tooltip dates use `dataIndex` against raw rows, but categories are deduplicated by x value; with multiple series, the tooltip can show another row's date. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43863&comment_hash=7673412942ffa57e5ab60828c98416a1b56416a50e6b2deff7d11d645412c4a7&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43863&comment_hash=7673412942ffa57e5ab60828c98416a1b56416a50e6b2deff7d11d645412c4a7&reaction=dislike'>๐</a> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
