fix: 修改线条的 dataset 问题

This commit is contained in:
mtruning
2022-03-20 18:11:26 +08:00
parent bdf7527824
commit 3d72d58e87
16 changed files with 277 additions and 90 deletions
@@ -2,6 +2,7 @@ import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
import { BarCrossrangeConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'
export const includes = ['legend', 'xAxis', 'yAxis']
@@ -26,33 +27,30 @@ export const option = {
show: true,
type: 'category',
},
dataset: { ...dataJson },
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],
},
],
}
export default class Config extends publicConfig
implements CreateComponentType {
public key: string = BarCrossrangeConfig.key
public key = BarCrossrangeConfig.key
public chartConfig = cloneDeep(BarCrossrangeConfig)
// 图表配置项
public option = echartOptionProfixHandle(option, includes)
@@ -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
}
]
}
@@ -5,12 +5,13 @@
<script setup lang="ts">
import { computed, PropType } from 'vue'
import VChart from 'vue-echarts'
import { use, graphic } from 'echarts/core'
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { BarChart } from 'echarts/charts'
import { mergeTheme } from '@/packages/public/chart'
import config, { includes } from './config'
import {
DatasetComponent,
GridComponent,
TooltipComponent,
LegendComponent,
@@ -32,6 +33,7 @@ const props = defineProps({
})
use([
DatasetComponent,
CanvasRenderer,
BarChart,
GridComponent,
@@ -43,5 +45,3 @@ const option = computed(() => {
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
})
</script>
<style lang="scss" scoped></style>