Merge pull request #10644 from dataease/pr@dev-v2@chart-stock-line-fix

fix(图表-K线图): 修复关闭提示时k线被隐藏的问题以及横轴无法隐藏的问题
This commit is contained in:
jianneng-fit2cloud 2024-07-01 12:54:49 +08:00 committed by GitHub
commit 5eafcc8a03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -282,6 +282,7 @@ export class StockLine extends G2PlotChartView<MixOptions, Mix> {
xField: xAxisDataeaseName, xField: xAxisDataeaseName,
yField: key, yField: key,
color: colors[index - 1], color: colors[index - 1],
xAxis: null,
yAxis: { yAxis: {
label: false, label: false,
min: minValue, min: minValue,
@ -398,20 +399,26 @@ export class StockLine extends G2PlotChartView<MixOptions, Mix> {
protected configTooltip(chart: Chart, options: MixOptions): MixOptions { protected configTooltip(chart: Chart, options: MixOptions): MixOptions {
const tooltipAttr = parseJson(chart.customAttr).tooltip const tooltipAttr = parseJson(chart.customAttr).tooltip
if (!tooltipAttr.show) {
return {
...options,
tooltip: {
showContent: false
}
}
}
const newPlots = [] const newPlots = []
const linePlotList = options.plots.filter(item => item.type === 'line') const linePlotList = options.plots.filter(item => item.type === 'line')
linePlotList.forEach(item => { linePlotList.forEach(item => {
newPlots.push(item) newPlots.push(item)
}) })
const stockPlot = options.plots.filter(item => item.type === 'stock')[0] const stockPlot = options.plots.filter(item => item.type === 'stock')[0]
if (!tooltipAttr.show) {
const stockOption = {
...stockPlot.options,
tooltip: {
showContent: false
}
}
newPlots.push({ ...stockPlot, options: stockOption })
return {
...options,
plots: newPlots
}
}
const showFiled = chart.data.fields const showFiled = chart.data.fields
const customTooltipItems = originalItems => { const customTooltipItems = originalItems => {
const formattedItems = originalItems const formattedItems = originalItems
@ -510,10 +517,15 @@ export class StockLine extends G2PlotChartView<MixOptions, Mix> {
...stockPlot, ...stockPlot,
options: { options: {
...stockPlot.options, ...stockPlot.options,
xAxis: { xAxis: xAxisOptions['xAxis']
...stockPlot.options['xAxis'], ? {
...xAxisOptions['xAxis'] ...stockPlot.options['xAxis'],
} ...xAxisOptions['xAxis']
}
: {
label: false,
line: null
}
} }
} }
newPlots.push(newStockPlot) newPlots.push(newStockPlot)
@ -548,11 +560,17 @@ export class StockLine extends G2PlotChartView<MixOptions, Mix> {
...stockPlot, ...stockPlot,
options: { options: {
...stockPlot.options, ...stockPlot.options,
yAxis: { yAxis: label
...stockPlot.options['yAxis'], ? {
...yAxisOptions['yAxis'], ...stockPlot.options['yAxis'],
label ...yAxisOptions['yAxis'],
} label
}
: {
label,
grid: null,
line: null
}
} }
} }
newPlots.push(newStockPlot) newPlots.push(newStockPlot)