pref: null data in charts

This commit is contained in:
ulleo
2025-07-25 17:57:42 +08:00
parent 247792b991
commit 5c48efa023
3 changed files with 21 additions and 3 deletions
@@ -106,7 +106,13 @@ export class Bar extends BaseG2Chart {
},
labels: [
{
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
text: (data: any) => {
const value = data[y[0].value]
if (value === undefined || value === null) {
return ''
}
return `${value}${_data.isPercent ? '%' : ''}`
},
transform: [
{ type: 'contrastReverse' },
{ type: 'exceedAdjust' },
@@ -95,7 +95,13 @@ export class Column extends BaseG2Chart {
},
labels: [
{
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
text: (data: any) => {
const value = data[y[0].value]
if (value === undefined || value === null) {
return ''
}
return `${value}${_data.isPercent ? '%' : ''}`
},
position: 'top',
transform: [
{ type: 'contrastReverse' },
@@ -61,7 +61,13 @@ export class Line extends BaseG2Chart {
},
labels: [
{
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
text: (data: any) => {
const value = data[y[0].value]
if (value === undefined || value === null) {
return ''
}
return `${value}${_data.isPercent ? '%' : ''}`
},
style: {
dx: -10,
dy: -12,