refactor(图表): 面积图无数据不渲染

This commit is contained in:
wisonic-s 2024-06-05 16:44:54 +08:00
parent d3a79af605
commit f955cb3e0b

View File

@ -86,24 +86,25 @@ export class Area extends G2PlotChartView<AreaOptions, G2Area> {
drawChart(drawOptions: G2PlotDrawOptions<G2Area>): G2Area { drawChart(drawOptions: G2PlotDrawOptions<G2Area>): G2Area {
const { chart, container, action } = drawOptions const { chart, container, action } = drawOptions
if (chart?.data) { if (!chart.data.data?.length) {
// data return
const data = cloneDeep(chart.data.data)
const initOptions: AreaOptions = {
...this.baseOptions,
data,
appendPadding: getPadding(chart)
}
// options
const options = this.setupOptions(chart, initOptions)
// 开始渲染
const newChart = new G2Area(container, options)
newChart.on('point:click', action)
return newChart
} }
// data
const data = cloneDeep(chart.data.data)
const initOptions: AreaOptions = {
...this.baseOptions,
data,
appendPadding: getPadding(chart)
}
// options
const options = this.setupOptions(chart, initOptions)
// 开始渲染
const newChart = new G2Area(container, options)
newChart.on('point:click', action)
return newChart
} }
protected configLabel(chart: Chart, options: AreaOptions): AreaOptions { protected configLabel(chart: Chart, options: AreaOptions): AreaOptions {