mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 13:32:18 +08:00
fix(图表): 修复部分图表图例无法修改文字大小的问题
This commit is contained in:
@@ -318,15 +318,13 @@ export class BidirectionalHorizontalBar extends G2PlotChartView<
|
||||
protected configLegend(chart: Chart, options: BidirectionalBarOptions): BidirectionalBarOptions {
|
||||
const o = super.configLegend(chart, options)
|
||||
if (o.legend) {
|
||||
o.legend.itemName = {
|
||||
formatter: (_text: string, _item: any, index: number) => {
|
||||
const yaxis = chart.yAxis[0]
|
||||
const yaxisExt = chart.yAxisExt[0]
|
||||
if (index === 0) {
|
||||
return yaxis.chartShowName ? yaxis.chartShowName : yaxis.name
|
||||
}
|
||||
return yaxisExt.chartShowName ? yaxisExt.chartShowName : yaxisExt.name
|
||||
o.legend.itemName.formatter = (_text: string, _item: any, index: number) => {
|
||||
const yaxis = chart.yAxis[0]
|
||||
const yaxisExt = chart.yAxisExt[0]
|
||||
if (index === 0) {
|
||||
return yaxis.chartShowName ? yaxis.chartShowName : yaxis.name
|
||||
}
|
||||
return yaxisExt.chartShowName ? yaxisExt.chartShowName : yaxisExt.name
|
||||
}
|
||||
}
|
||||
return o
|
||||
|
||||
@@ -573,20 +573,18 @@ export class ColumnLineMix extends G2PlotChartView<DualAxesOptions, DualAxes> {
|
||||
const left = cloneDeep(chart.data?.left?.data)
|
||||
const right = cloneDeep(chart.data?.right?.data)
|
||||
|
||||
o.legend.itemName = {
|
||||
formatter: (text: string, item: any, index: number) => {
|
||||
let name = undefined
|
||||
if (item.viewId === 'left-axes-view' && text === 'value') {
|
||||
name = left[0]?.categories[0]
|
||||
} else if (item.viewId === 'right-axes-view' && text === 'valueExt') {
|
||||
name = right[0]?.categories[0]
|
||||
}
|
||||
item.id = item.id + '__' + index //防止重复的图例出现问题,但是左右轴如果有相同的怎么办
|
||||
if (name === undefined) {
|
||||
return text
|
||||
} else {
|
||||
return name
|
||||
}
|
||||
o.legend.itemName.formatter = (text: string, item: any, index: number) => {
|
||||
let name = undefined
|
||||
if (item.viewId === 'left-axes-view' && text === 'value') {
|
||||
name = left[0]?.categories[0]
|
||||
} else if (item.viewId === 'right-axes-view' && text === 'valueExt') {
|
||||
name = right[0]?.categories[0]
|
||||
}
|
||||
item.id = item.id + '__' + index //防止重复的图例出现问题,但是左右轴如果有相同的怎么办
|
||||
if (name === undefined) {
|
||||
return text
|
||||
} else {
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -360,6 +360,12 @@ export function getLegend(chart: Chart) {
|
||||
r: l.size
|
||||
}
|
||||
},
|
||||
itemName: {
|
||||
style: {
|
||||
fill: l.color,
|
||||
fontSize: l.fontSize
|
||||
}
|
||||
},
|
||||
itemHeight: (l.fontSize > l.size * 2 ? l.fontSize : l.size * 2) + 4,
|
||||
radio: false,
|
||||
pageNavigator: {
|
||||
|
||||
Reference in New Issue
Block a user