feat: echarts add china geo
parent
51bd200ad8
commit
3f304cdb76
|
@ -3,13 +3,16 @@ import type {
|
||||||
BarSeriesOption,
|
BarSeriesOption,
|
||||||
GaugeSeriesOption,
|
GaugeSeriesOption,
|
||||||
LineSeriesOption,
|
LineSeriesOption,
|
||||||
|
MapSeriesOption,
|
||||||
} from 'echarts/charts';
|
} from 'echarts/charts';
|
||||||
import type {
|
import type {
|
||||||
DatasetComponentOption,
|
DatasetComponentOption,
|
||||||
|
GeoComponentOption,
|
||||||
GridComponentOption,
|
GridComponentOption,
|
||||||
// 组件类型的定义后缀都为 ComponentOption
|
// 组件类型的定义后缀都为 ComponentOption
|
||||||
TitleComponentOption,
|
TitleComponentOption,
|
||||||
TooltipComponentOption,
|
TooltipComponentOption,
|
||||||
|
VisualMapComponentOption,
|
||||||
} from 'echarts/components';
|
} from 'echarts/components';
|
||||||
import type { ComposeOption } from 'echarts/core';
|
import type { ComposeOption } from 'echarts/core';
|
||||||
|
|
||||||
|
@ -17,12 +20,14 @@ import {
|
||||||
BarChart,
|
BarChart,
|
||||||
GaugeChart,
|
GaugeChart,
|
||||||
LineChart,
|
LineChart,
|
||||||
|
MapChart,
|
||||||
PieChart,
|
PieChart,
|
||||||
RadarChart,
|
RadarChart,
|
||||||
} from 'echarts/charts';
|
} from 'echarts/charts';
|
||||||
import {
|
import {
|
||||||
// 数据集组件
|
// 数据集组件
|
||||||
DatasetComponent,
|
DatasetComponent,
|
||||||
|
GeoComponent,
|
||||||
GridComponent,
|
GridComponent,
|
||||||
LegendComponent,
|
LegendComponent,
|
||||||
TitleComponent,
|
TitleComponent,
|
||||||
|
@ -30,6 +35,7 @@ import {
|
||||||
TooltipComponent,
|
TooltipComponent,
|
||||||
// 内置数据转换器组件 (filter, sort)
|
// 内置数据转换器组件 (filter, sort)
|
||||||
TransformComponent,
|
TransformComponent,
|
||||||
|
VisualMapComponent,
|
||||||
} from 'echarts/components';
|
} from 'echarts/components';
|
||||||
import * as echarts from 'echarts/core';
|
import * as echarts from 'echarts/core';
|
||||||
import { LabelLayout, UniversalTransition } from 'echarts/features';
|
import { LabelLayout, UniversalTransition } from 'echarts/features';
|
||||||
|
@ -40,10 +46,13 @@ export type ECOption = ComposeOption<
|
||||||
| BarSeriesOption
|
| BarSeriesOption
|
||||||
| DatasetComponentOption
|
| DatasetComponentOption
|
||||||
| GaugeSeriesOption
|
| GaugeSeriesOption
|
||||||
|
| GeoComponentOption
|
||||||
| GridComponentOption
|
| GridComponentOption
|
||||||
| LineSeriesOption
|
| LineSeriesOption
|
||||||
|
| MapSeriesOption
|
||||||
| TitleComponentOption
|
| TitleComponentOption
|
||||||
| TooltipComponentOption
|
| TooltipComponentOption
|
||||||
|
| VisualMapComponentOption
|
||||||
>;
|
>;
|
||||||
|
|
||||||
// 注册必须的组件
|
// 注册必须的组件
|
||||||
|
@ -63,6 +72,9 @@ echarts.use([
|
||||||
CanvasRenderer,
|
CanvasRenderer,
|
||||||
LegendComponent,
|
LegendComponent,
|
||||||
ToolboxComponent,
|
ToolboxComponent,
|
||||||
|
VisualMapComponent,
|
||||||
|
MapChart,
|
||||||
|
GeoComponent,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export default echarts;
|
export default echarts;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -19,6 +19,7 @@ import {
|
||||||
} from '@vueuse/core';
|
} from '@vueuse/core';
|
||||||
|
|
||||||
import echarts from './echarts';
|
import echarts from './echarts';
|
||||||
|
import chinaMap from './map/china.json';
|
||||||
|
|
||||||
type EchartsUIType = typeof EchartsUI | undefined;
|
type EchartsUIType = typeof EchartsUI | undefined;
|
||||||
|
|
||||||
|
@ -32,6 +33,18 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
|
||||||
const { height, width } = useWindowSize();
|
const { height, width } = useWindowSize();
|
||||||
const resizeHandler: () => void = useDebounceFn(resize, 200);
|
const resizeHandler: () => void = useDebounceFn(resize, 200);
|
||||||
|
|
||||||
|
echarts.registerMap('china', {
|
||||||
|
geoJSON: chinaMap as any,
|
||||||
|
specialAreas: {
|
||||||
|
china: {
|
||||||
|
left: 500,
|
||||||
|
top: 500,
|
||||||
|
width: 1000,
|
||||||
|
height: 1000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const getOptions = computed((): EChartsOption => {
|
const getOptions = computed((): EChartsOption => {
|
||||||
if (!isDark.value) {
|
if (!isDark.value) {
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Reference in New Issue