feat: 新增折线图,修改legend位置
This commit is contained in:
parent
1b7ee5cb2e
commit
3923b49c9e
@ -14,7 +14,6 @@ import {
|
|||||||
GridComponent,
|
GridComponent,
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
LegendComponent,
|
LegendComponent,
|
||||||
TitleComponent
|
|
||||||
} from 'echarts/components'
|
} from 'echarts/components'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -38,7 +37,6 @@ use([
|
|||||||
GridComponent,
|
GridComponent,
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
LegendComponent,
|
LegendComponent,
|
||||||
TitleComponent
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const option = computed(() => {
|
const option = computed(() => {
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
|
||||||
|
import { LineGradientSingleConfig } from './index'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import omit from 'lodash/omit'
|
||||||
|
|
||||||
|
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
|
const options = echartOptionProfixHandle({
|
||||||
|
legend: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
show: true,
|
||||||
|
type: 'category',
|
||||||
|
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
show: true,
|
||||||
|
type: 'value'
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: 'data1',
|
||||||
|
type: 'line',
|
||||||
|
data: [120, 200, 150, 80, 70, 110, 130]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, includes)
|
||||||
|
|
||||||
|
export default class Config extends publicConfig implements CreateComponentType {
|
||||||
|
public key: string = LineGradientSingleConfig.key
|
||||||
|
public chartConfig = omit(LineGradientSingleConfig, ['node'])
|
||||||
|
// 图表配置项
|
||||||
|
public option = options
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div>配置项目</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
@ -1,13 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<VChart :theme="themeColor" :option="option" autoresize />
|
||||||
line组件渲染
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, PropType } from 'vue'
|
||||||
|
import VChart from 'vue-echarts'
|
||||||
|
import { use, graphic } from 'echarts/core'
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
|
import { LineChart } from 'echarts/charts'
|
||||||
|
import config, { includes } from './config'
|
||||||
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
|
import {
|
||||||
|
GridComponent,
|
||||||
|
TooltipComponent,
|
||||||
|
LegendComponent,
|
||||||
|
} from 'echarts/components'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
themeSetting: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
themeColor: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
chartConfig: {
|
||||||
|
type: Object as PropType<config>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
use([
|
||||||
|
CanvasRenderer,
|
||||||
|
LineChart,
|
||||||
|
GridComponent,
|
||||||
|
TooltipComponent,
|
||||||
|
LegendComponent,
|
||||||
|
])
|
||||||
|
|
||||||
|
const option = computed(() => {
|
||||||
|
return mergeTheme( props.chartConfig.option, props.themeSetting, includes)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
40
src/packages/components/Charts/Lines/LineGradients/config.ts
Normal file
40
src/packages/components/Charts/Lines/LineGradients/config.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { echartOptionProfixHandle, publicConfig } from '@/packages/public'
|
||||||
|
import { LineGradientsConfig } from './index'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import omit from 'lodash/omit'
|
||||||
|
|
||||||
|
export const includes = ['legend', 'xAxis', 'yAxis']
|
||||||
|
|
||||||
|
const options = echartOptionProfixHandle({
|
||||||
|
legend: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
show: true,
|
||||||
|
type: 'category',
|
||||||
|
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
show: true,
|
||||||
|
type: 'value'
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: 'data1',
|
||||||
|
type: 'line',
|
||||||
|
data: [120, 200, 150, 80, 70, 110, 130]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'data2',
|
||||||
|
type: 'line',
|
||||||
|
data: [130, 130, 312, 268, 155, 117, 160]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, includes)
|
||||||
|
|
||||||
|
export default class Config extends publicConfig implements CreateComponentType {
|
||||||
|
public key: string = LineGradientsConfig.key
|
||||||
|
public chartConfig = omit(LineGradientsConfig, ['node'])
|
||||||
|
// 图表配置项
|
||||||
|
public option = options
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div>配置项目</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
@ -4,7 +4,7 @@ import { ConfigType, PackagesCategoryEnum } from '@/packages/index.d'
|
|||||||
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
import { ChatCategoryEnum, ChatCategoryEnumName } from '../../index.d'
|
||||||
|
|
||||||
export const LineGradientsConfig: ConfigType = {
|
export const LineGradientsConfig: ConfigType = {
|
||||||
key: 'VLineGradientSingle',
|
key: 'VLineGradients',
|
||||||
title: '折线面积图',
|
title: '折线面积图',
|
||||||
category: ChatCategoryEnum.LINE,
|
category: ChatCategoryEnum.LINE,
|
||||||
categoryName: ChatCategoryEnumName.LINE,
|
categoryName: ChatCategoryEnumName.LINE,
|
||||||
|
@ -1,13 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<VChart :theme="themeColor" :option="option" autoresize />
|
||||||
line组件渲染
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, PropType } from 'vue'
|
||||||
|
import VChart from 'vue-echarts'
|
||||||
|
import { use, graphic } from 'echarts/core'
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers'
|
||||||
|
import { LineChart } from 'echarts/charts'
|
||||||
|
import config, { includes } from './config'
|
||||||
|
import { mergeTheme } from '@/packages/public/chart'
|
||||||
|
import {
|
||||||
|
GridComponent,
|
||||||
|
TooltipComponent,
|
||||||
|
LegendComponent,
|
||||||
|
} from 'echarts/components'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
themeSetting: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
themeColor: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
chartConfig: {
|
||||||
|
type: Object as PropType<config>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
use([
|
||||||
|
CanvasRenderer,
|
||||||
|
LineChart,
|
||||||
|
GridComponent,
|
||||||
|
TooltipComponent,
|
||||||
|
LegendComponent,
|
||||||
|
])
|
||||||
|
|
||||||
|
const option = computed(() => {
|
||||||
|
return mergeTheme( props.chartConfig.option, props.themeSetting, includes)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
@ -12,14 +12,13 @@ const option = echartOptionProfixHandle({
|
|||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
show: true,
|
show: true,
|
||||||
top: '5%',
|
|
||||||
left: 'center'
|
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: 'Access From',
|
name: 'Access From',
|
||||||
type: 'pie',
|
type: 'pie',
|
||||||
radius: ['40%', '70%'],
|
radius: ['40%', '70%'],
|
||||||
|
center: ['50%', '60%'],
|
||||||
avoidLabelOverlap: false,
|
avoidLabelOverlap: false,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -32,6 +32,7 @@ const packagesInstall = (app: App): void => {
|
|||||||
* @param dropData
|
* @param dropData
|
||||||
*/
|
*/
|
||||||
const createComponent = async (dropData: ConfigType) => {
|
const createComponent = async (dropData: ConfigType) => {
|
||||||
|
console.log(dropData)
|
||||||
const { category } = dropData
|
const { category } = dropData
|
||||||
const key = dropData.key.substring(1)
|
const key = dropData.key.substring(1)
|
||||||
const chart = await import(`./components/${dropData.package}/${category}/${key}/config.ts`)
|
const chart = await import(`./components/${dropData.package}/${category}/${key}/config.ts`)
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"legend": {
|
"legend": {
|
||||||
|
"top": "5%",
|
||||||
"textStyle": {
|
"textStyle": {
|
||||||
"color": "#B9B8CE"
|
"color": "#B9B8CE"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user