|
@@ -0,0 +1,62 @@
|
|
|
+import shanxi from '../../assets/map/610000_shaanxi.json';
|
|
|
+import * as echarts from 'echarts/core';
|
|
|
+import {
|
|
|
+ PieChart,
|
|
|
+ BarChart,
|
|
|
+ PictorialBarChart,
|
|
|
+ MapChart,
|
|
|
+ ScatterChart
|
|
|
+} from 'echarts/charts';
|
|
|
+import {
|
|
|
+ TooltipComponent,
|
|
|
+ LegendComponent,
|
|
|
+ GridComponent,
|
|
|
+ TitleComponent,
|
|
|
+ VisualMapComponent
|
|
|
+} from 'echarts/components';
|
|
|
+import { CanvasRenderer } from 'echarts/renderers';
|
|
|
+echarts.use([
|
|
|
+ ScatterChart,
|
|
|
+ PieChart,
|
|
|
+ MapChart,
|
|
|
+ BarChart,
|
|
|
+ PictorialBarChart,
|
|
|
+ TooltipComponent,
|
|
|
+ CanvasRenderer,
|
|
|
+ LegendComponent,
|
|
|
+ GridComponent,
|
|
|
+ TitleComponent,
|
|
|
+ VisualMapComponent
|
|
|
+]);
|
|
|
+// 陕西地图引入
|
|
|
+echarts.registerMap('ShanXi', shanxi);
|
|
|
+
|
|
|
+export const numform = n => {
|
|
|
+ let num = n;
|
|
|
+ if (isNaN(n)) num = '0';
|
|
|
+ else if (n >= 100000000)
|
|
|
+ num =
|
|
|
+ ((n / 100000000).toFixed(2) - 0 + '').replace(
|
|
|
+ /\B(?=(?:\d{3})+\b)/g,
|
|
|
+ ','
|
|
|
+ ) + '亿';
|
|
|
+ else if (n >= 10000)
|
|
|
+ num =
|
|
|
+ ((n / 10000).toFixed(2) - 0 + '').replace(/\B(?=(?:\d{3})+\b)/g, ',') +
|
|
|
+ '万';
|
|
|
+ else num = (num + '').replace(/\B(?=(?:\d{3})+\b)/g, ',');
|
|
|
+ return num;
|
|
|
+};
|
|
|
+
|
|
|
+export const createChart = (el, height, option, obj) => {
|
|
|
+ let chart;
|
|
|
+ if (!obj) {
|
|
|
+ chart = echarts.init(el);
|
|
|
+ chart.resize({ height });
|
|
|
+ chart.setOption(option);
|
|
|
+ return chart;
|
|
|
+ } else {
|
|
|
+ obj.setOption(option);
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+};
|