mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-10 02:07:12 +08:00
feat: column, bar and line charts support series
This commit is contained in:
@@ -8,8 +8,10 @@ export class Bar extends BaseG2Chart {
|
||||
|
||||
init(axis: Array<ChartAxis>, data: Array<ChartData>) {
|
||||
super.init(axis, data)
|
||||
|
||||
const x = this.axis.filter((item) => item.type === 'x')
|
||||
const y = this.axis.filter((item) => item.type === 'y')
|
||||
const series = this.axis.filter((item) => item.type === 'series')
|
||||
|
||||
if (x.length == 0 || y.length == 0) {
|
||||
return
|
||||
@@ -28,5 +30,9 @@ export class Bar extends BaseG2Chart {
|
||||
nice: true,
|
||||
})
|
||||
.interaction('elementHighlight', { background: true })
|
||||
|
||||
if (series.length > 0) {
|
||||
this.chart?.encode('color', series[0].value).transform({ type: 'stackY' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export class Column extends BaseG2Chart {
|
||||
|
||||
const x = this.axis.filter((item) => item.type === 'x')
|
||||
const y = this.axis.filter((item) => item.type === 'y')
|
||||
const series = this.axis.filter((item) => item.type === 'series')
|
||||
|
||||
if (x.length == 0 || y.length == 0) {
|
||||
return
|
||||
@@ -28,5 +29,9 @@ export class Column extends BaseG2Chart {
|
||||
nice: true,
|
||||
})
|
||||
.interaction('elementHighlight', { background: true })
|
||||
|
||||
if (series.length > 0) {
|
||||
this.chart?.encode('color', series[0].value).transform({ type: 'stackY' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export class Line extends BaseG2Chart {
|
||||
|
||||
const x = this.axis.filter((item) => item.type === 'x')
|
||||
const y = this.axis.filter((item) => item.type === 'y')
|
||||
const series = this.axis.filter((item) => item.type === 'series')
|
||||
|
||||
if (x.length == 0 || y.length == 0) {
|
||||
return
|
||||
@@ -27,6 +28,10 @@ export class Line extends BaseG2Chart {
|
||||
nice: true,
|
||||
})
|
||||
|
||||
if (series.length > 0) {
|
||||
this.chart?.encode('color', series[0].value)
|
||||
}
|
||||
|
||||
this.chart?.line().label({
|
||||
text: y[0].value,
|
||||
style: {
|
||||
|
||||
Reference in New Issue
Block a user