mirror of
https://github.com/dataease/dataease.git
synced 2026-06-18 05:18:07 +08:00
refactor(图表): 优化分组柱线组合图展示效果
This commit is contained in:
@@ -598,9 +598,21 @@ export class GroupLineMix extends G2ChartView {
|
||||
return options
|
||||
}
|
||||
|
||||
protected configXAxis(chart: Chart, options: G2Spec): G2Spec {
|
||||
protected configXAxis(chart: Chart, options: G2Spec, context: Record<string, any>): G2Spec {
|
||||
const { xAxis } = parseJson(chart.customStyle)
|
||||
const view = options.children.find(c => c.key === 'chart')
|
||||
// 固定 x 轴顺序
|
||||
const { leftData: xAxisData } = context
|
||||
const xAxisSort = xAxisData.map(d => d.field)
|
||||
defaultsDeep(view, {
|
||||
scale: {
|
||||
x: {
|
||||
compare: (a, b) => {
|
||||
return xAxisSort.indexOf(a) - xAxisSort.indexOf(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
if (!xAxis.show) {
|
||||
const axisHide = {
|
||||
axis: {
|
||||
@@ -645,15 +657,7 @@ export class GroupLineMix extends G2ChartView {
|
||||
gridStrokeOpacity: 1,
|
||||
gridLineWidth: xAxis.splitLine.lineStyle.width,
|
||||
gridLineDash,
|
||||
transform: xAxis.axisLabel.rotate
|
||||
? [
|
||||
{
|
||||
type: 'rotate',
|
||||
optionalAngles: [xAxis.axisLabel.rotate],
|
||||
recoverWhenFailed: false
|
||||
}
|
||||
]
|
||||
: []
|
||||
labelTransform: `rotate(${xAxis.axisLabel.rotate || 0})`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -821,7 +825,9 @@ export class GroupLineMix extends G2ChartView {
|
||||
transform: [{ type: 'overlapHide' }, { type: 'exceedAdjust' }],
|
||||
fontFamily: chart.fontFamily
|
||||
}
|
||||
]
|
||||
],
|
||||
tooltip: false,
|
||||
legend: false
|
||||
}
|
||||
view.children.push(assistLineMark)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user