Merge pull request #10114 from dataease/pr@dev-v2@refactor_area_null_data

refactor(图表): 面积图无数据不渲染
This commit is contained in:
wisonic-s 2024-06-05 16:46:40 +08:00 committed by GitHub
commit b42c06c4df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,24 +86,25 @@ export class Area extends G2PlotChartView<AreaOptions, G2Area> {
drawChart(drawOptions: G2PlotDrawOptions<G2Area>): G2Area {
const { chart, container, action } = drawOptions
if (chart?.data) {
// 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
if (!chart.data.data?.length) {
return
}
// 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 {