mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
feat:新增全局接口配置,单个图表映射表,抽离柱状图数据格式,
This commit is contained in:
@@ -3,7 +3,7 @@ import { BarCommonConfig } from './index'
|
||||
import { CreateComponentType } from '@/packages/index.d'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
|
||||
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||
export const includes = ['legend', 'xAxis', 'yAxis', 'dataset']
|
||||
|
||||
export const option = {
|
||||
tooltip: {
|
||||
@@ -15,12 +15,11 @@ export const option = {
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: true,
|
||||
show: true
|
||||
},
|
||||
xAxis: {
|
||||
show: true,
|
||||
type: 'category',
|
||||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
type: 'category'
|
||||
},
|
||||
yAxis: {
|
||||
show: true,
|
||||
@@ -28,24 +27,20 @@ export const option = {
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'data1',
|
||||
type: 'bar',
|
||||
barWidth: null,
|
||||
itemStyle: {
|
||||
color: null,
|
||||
borderRadius: 0
|
||||
},
|
||||
data: [120, 200, 150, 80, 70, 110, 130]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'data2',
|
||||
type: 'bar',
|
||||
barWidth: null,
|
||||
itemStyle: {
|
||||
color: null,
|
||||
borderRadius: 0
|
||||
},
|
||||
data: [130, 130, 312, 268, 155, 117, 160]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"dimensions": ["product", "data1", "data2"],
|
||||
"source": [
|
||||
{
|
||||
"product": "Mon",
|
||||
"data1": 120,
|
||||
"data2": 130
|
||||
},
|
||||
{
|
||||
"product": "Tue",
|
||||
"data1": 200,
|
||||
"data2": 130
|
||||
},
|
||||
{
|
||||
"product": "Wed",
|
||||
"data1": 150,
|
||||
"data2": 312
|
||||
},
|
||||
{
|
||||
"product": "Thu",
|
||||
"data1": 80,
|
||||
"data2": 268
|
||||
},
|
||||
{
|
||||
"product": "Fri",
|
||||
"data1": 70,
|
||||
"data2": 155
|
||||
},
|
||||
{
|
||||
"product": "Sat",
|
||||
"data1": 110,
|
||||
"data2": 117
|
||||
},
|
||||
{
|
||||
"product": "Sun",
|
||||
"data1": 130,
|
||||
"data2": 160
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -9,8 +9,10 @@ import { use } from 'echarts/core'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
import { BarChart } from 'echarts/charts'
|
||||
import config, { includes } from './config'
|
||||
import { mergeTheme } from '@/packages/public/chart'
|
||||
import { mergeTheme, setData } from '@/packages/public/chart'
|
||||
import dataJson from './data.json'
|
||||
import {
|
||||
DatasetComponent,
|
||||
GridComponent,
|
||||
TooltipComponent,
|
||||
LegendComponent
|
||||
@@ -32,6 +34,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
use([
|
||||
DatasetComponent,
|
||||
CanvasRenderer,
|
||||
BarChart,
|
||||
GridComponent,
|
||||
@@ -40,6 +43,6 @@ use([
|
||||
])
|
||||
|
||||
const option = computed(() => {
|
||||
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
||||
return setData(mergeTheme(props.chartConfig.option, props.themeSetting, includes), dataJson)
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user