├── src ├── store │ ├── getters.js │ ├── state.js │ ├── actions_type.js │ ├── mutations_type.js │ ├── index.js │ ├── mutations.js │ └── actions.js ├── assets │ ├── rowBar.png │ ├── areaPie.png │ ├── circlePie.png │ ├── columnBar.png │ ├── doubleLine.png │ └── singleLine.png ├── nets │ ├── api.js │ └── index.js ├── main.js ├── App.vue ├── router.js ├── utils │ ├── index.js │ ├── dataInfor.js │ └── chartview.js ├── components │ ├── editChart.vue │ ├── selectColor.vue │ ├── LineSimple.vue │ └── NavMenu.vue ├── views │ └── Home.vue └── mock │ └── index.js ├── babel.config.js ├── public ├── favicon.ico └── index.html ├── vue.config.js ├── README.md └── package.json /src/store/getters.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | } -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/app"] 3 | }; 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/assets/rowBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/src/assets/rowBar.png -------------------------------------------------------------------------------- /src/assets/areaPie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/src/assets/areaPie.png -------------------------------------------------------------------------------- /src/assets/circlePie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/src/assets/circlePie.png -------------------------------------------------------------------------------- /src/assets/columnBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/src/assets/columnBar.png -------------------------------------------------------------------------------- /src/assets/doubleLine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/src/assets/doubleLine.png -------------------------------------------------------------------------------- /src/assets/singleLine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzhewd/datavisualization/HEAD/src/assets/singleLine.png -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | // vue.config.js 2 | module.exports = { 3 | publicPath: process.env.NODE_ENV === 'production' 4 | ? './' 5 | : '/' 6 | 7 | }; 8 | -------------------------------------------------------------------------------- /src/store/state.js: -------------------------------------------------------------------------------- 1 | export const initVal = { 2 | firCharInfo: [], 3 | delText: -1, 4 | lineChart: [], 5 | editChartInfo: {} 6 | }; 7 | 8 | export default { 9 | ...initVal 10 | }; -------------------------------------------------------------------------------- /src/nets/api.js: -------------------------------------------------------------------------------- 1 | const PREFIX = 2 | process.env.NODE_ENV === "production" 3 | ? "" 4 | : ""; 5 | export const FIRSTCHART = `${PREFIX}/data/firstchart`; 6 | export const GETLINECHART = `${PREFIX}/data/lineChart`; 7 | -------------------------------------------------------------------------------- /src/store/actions_type.js: -------------------------------------------------------------------------------- 1 | export const GET_ALL_CHART_INFO = "GET_ALL_CHART_INFO"; 2 | export const PUSH_DEL_WHICH_ONE = "PUSH_DEL_WHICH_ONE"; 3 | export const GET_LINE_CHART_INFO = 'GET_LINE_CHART_INFO'; 4 | export const SET_EIDT_CHART_INFO = 'SET_EIDT_CHART_INFO'; -------------------------------------------------------------------------------- /src/store/mutations_type.js: -------------------------------------------------------------------------------- 1 | export const MUTATE_FIRST_CHART_INFO = "MUTATE_FIRST_CHART_INFO"; 2 | export const MUTATE_DEL_WHICH_ONE = " MUTATE_DEL_WHICH_ONE"; 3 | export const MUTATE_LINE_CHART = 'MUTATE_LINE_CHART'; 4 | export const MUTATE_EDIT_CHART = 'MUTATE_EDIT_CHART'; -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import Vuex from "vuex"; 3 | import state from "./state"; 4 | import actions from "./actions"; 5 | import mutations from "./mutations"; 6 | import getters from "./getters"; 7 | 8 | Vue.use(Vuex); 9 | 10 | export default new Vuex.Store({ 11 | state, 12 | mutations, 13 | actions, 14 | getters 15 | }); -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import router from "./router"; 4 | import store from "./store"; 5 | import ElementUI from "element-ui"; 6 | import "element-ui/lib/theme-chalk/index.css"; 7 | require('./mock') 8 | Vue.config.productionTip = false; 9 | Vue.use(ElementUI); 10 | 11 | new Vue({ 12 | router, 13 | store, 14 | render: h => h(App) 15 | }).$mount("#app"); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # datavisualization 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Run your tests 19 | ``` 20 | npm run test 21 | ``` 22 | 23 | ### Lints and fixes files 24 | ``` 25 | npm run lint 26 | ``` 27 | 28 | ### Customize configuration 29 | See [Configuration Reference](https://cli.vuejs.org/config/). 30 | -------------------------------------------------------------------------------- /src/nets/index.js: -------------------------------------------------------------------------------- 1 | import * as api from './api'; 2 | import http from 'axios'; 3 | import qs from 'qs'; 4 | 5 | import { 6 | ajaxToPromise 7 | } from '../utils'; 8 | 9 | const axios = http.create({ 10 | timeout: 15000, 11 | // withCredentials: true //跨域请求携带cookie 12 | }); 13 | 14 | export function getchartlist (payload) { 15 | return ajaxToPromise(axios.get(api.FIRSTCHART)); 16 | } 17 | export function getlinechart (payload) { 18 | return ajaxToPromise(axios.post(api.GETLINECHART, payload)); 19 | } 20 | -------------------------------------------------------------------------------- /src/store/mutations.js: -------------------------------------------------------------------------------- 1 | import * as types from "./mutations_type"; 2 | 3 | export default { 4 | [types.MUTATE_FIRST_CHART_INFO](state, payLoad) { 5 | state.firCharInfo.push(payLoad); 6 | }, 7 | [types.MUTATE_DEL_WHICH_ONE](state, payLoad) { 8 | state.delText = payLoad; 9 | }, 10 | [types.MUTATE_LINE_CHART](state, payLoad) { 11 | state.lineChart.push(payLoad) 12 | }, 13 | [types.MUTATE_EDIT_CHART](state, payLoad) { 14 | state.editChartInfo = payLoad 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 16 | 41 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | datavisualization 10 | 11 | 12 | 13 | 16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import Router from "vue-router"; 3 | import Home from "./views/Home.vue"; 4 | 5 | Vue.use(Router); 6 | 7 | export default new Router({ 8 | routes: [{ 9 | path: "/", 10 | name: "home", 11 | component: Home 12 | } 13 | // { 14 | // path: "/about", 15 | // name: "about", 16 | // // route level code-splitting 17 | // // this generates a separate chunk (about.[hash].js) for this route 18 | // // which is lazy-loaded when the route is visited. 19 | // component: () => 20 | // import(/* webpackChunkName: "about" */ "./views/About.vue") 21 | // } 22 | ] 23 | }); -------------------------------------------------------------------------------- /src/utils/index.js: -------------------------------------------------------------------------------- 1 | export function ajaxToPromise(p) { 2 | return p.then((response) => { 3 | if (response.status == 200) { 4 | return { 5 | success: true, 6 | data: response.data 7 | }; 8 | } 9 | return { 10 | success: false, 11 | data: response.data.message, 12 | message: response.data.message 13 | }; 14 | }, (err) => { 15 | console.log(err); 16 | return { 17 | success: false, 18 | data: '网络异常' 19 | }; 20 | }); 21 | } 22 | 23 | export function transBodyParams(body) { 24 | var obj = JSON.parse(body) 25 | return obj.params ? obj.params : obj 26 | } 27 | 28 | export function countNumber(num) { 29 | if (num % 100 === 0) { 30 | return num 31 | } else { 32 | var y = 100 - num % 100 33 | return num + y 34 | } 35 | } -------------------------------------------------------------------------------- /src/store/actions.js: -------------------------------------------------------------------------------- 1 | import * as types from "./actions_type"; 2 | import * as mutationTypes from "./mutations_type"; 3 | import * as nets from '../nets'; 4 | 5 | export default { 6 | async [types.GET_ALL_CHART_INFO]({ commit }, payLoad) { 7 | let result = await nets.getchartlist(payLoad) 8 | if (result.success) { 9 | commit(mutationTypes.MUTATE_FIRST_CHART_INFO, result.data); 10 | } 11 | return result; 12 | }, 13 | [types.PUSH_DEL_WHICH_ONE]({ commit }, payLoad) { 14 | commit(mutationTypes.MUTATE_DEL_WHICH_ONE, payLoad); 15 | }, 16 | async [types.GET_LINE_CHART_INFO]({ commit }, payLoad) { 17 | let result = await nets.getlinechart(payLoad) 18 | if (result.success) { 19 | commit(mutationTypes.MUTATE_LINE_CHART, result.data); 20 | } 21 | return result; 22 | }, 23 | [types.SET_EIDT_CHART_INFO]({ commit }, payLoad) { 24 | commit(mutationTypes.MUTATE_EDIT_CHART, payLoad) 25 | } 26 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "datavisualization", 3 | "author": "Created by zhangzhe<544785380@qq.com> on 2019/6/5", 4 | "version": "0.1.0", 5 | "private": true, 6 | "scripts": { 7 | "serve": "vue-cli-service serve", 8 | "build": "cross-env NODE_ENV=production vue-cli-service build", 9 | "lint": "vue-cli-service lint" 10 | }, 11 | "dependencies": { 12 | "awe-dnd": "^0.3.4", 13 | "axios": "^0.19.0", 14 | "core-js": "^2.6.5", 15 | "echarts": "^4.2.1", 16 | "echarts-gl": "^1.1.1", 17 | "element-ui": "^2.8.2", 18 | "mockjs": "^1.0.1-beta3", 19 | "qs": "^6.7.0", 20 | "sortablejs": "^1.9.0", 21 | "vue": "^2.6.10", 22 | "vue-router": "^3.0.3", 23 | "vuedraggable": "^2.21.0", 24 | "vuex": "^3.0.1" 25 | }, 26 | "devDependencies": { 27 | "@vue/cli-plugin-babel": "^3.8.0", 28 | "@vue/cli-plugin-eslint": "^3.8.0", 29 | "@vue/cli-service": "^3.8.0", 30 | "@vue/eslint-config-prettier": "^4.0.1", 31 | "babel-eslint": "^10.0.1", 32 | "cross-env": "^5.2.0", 33 | "eslint": "^5.16.0", 34 | "eslint-plugin-vue": "^5.0.0", 35 | "node-sass": "^4.9.0", 36 | "sass-loader": "^7.1.0", 37 | "vue-template-compiler": "^2.6.10" 38 | }, 39 | "eslintConfig": { 40 | "root": true, 41 | "env": { 42 | "node": true 43 | }, 44 | "extends": [ 45 | "plugin:vue/essential", 46 | "@vue/prettier" 47 | ], 48 | "rules": {}, 49 | "parserOptions": { 50 | "parser": "babel-eslint" 51 | } 52 | }, 53 | "postcss": { 54 | "plugins": { 55 | "autoprefixer": {} 56 | } 57 | }, 58 | "browserslist": [ 59 | "> 1%", 60 | "last 2 versions" 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /src/components/editChart.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 57 | 66 | -------------------------------------------------------------------------------- /src/utils/dataInfor.js: -------------------------------------------------------------------------------- 1 | import singleLine from "../assets/singleLine.png"; 2 | import doubleLine from "../assets/doubleLine.png"; 3 | import areaPie from "../assets/areaPie.png"; 4 | import circlePie from "../assets/circlePie.png"; 5 | import rowBar from "../assets/rowBar.png"; 6 | import columnBar from "../assets/columnBar.png"; 7 | 8 | export default { 9 | choseCharts: [{ 10 | value: "line", 11 | label: "折线图", 12 | chartType: [{ 13 | imgSrc: singleLine, 14 | type: "singleLine" 15 | }, 16 | { 17 | imgSrc: doubleLine, 18 | type: "doubleLine" 19 | } 20 | ] 21 | }, 22 | { 23 | value: "pie", 24 | label: "饼图", 25 | chartType: [{ 26 | imgSrc: areaPie, 27 | type: "areaPie" 28 | }, 29 | { 30 | imgSrc: circlePie, 31 | type: "circlePie" 32 | } 33 | ] 34 | }, 35 | { 36 | value: "bar", 37 | label: "柱状图", 38 | chartType: [{ 39 | imgSrc: rowBar, 40 | type: "rowBar" 41 | }, 42 | { 43 | imgSrc: columnBar, 44 | type: "columnBar" 45 | } 46 | ] 47 | } 48 | ], 49 | chartChoseW: [{ 50 | value: "w24", 51 | label: "24vw" 52 | }, 53 | { 54 | value: "w32", 55 | label: "32vw" 56 | }, 57 | { 58 | value: "w49", 59 | label: "49vw" 60 | } 61 | ], 62 | chartChoseH: [{ 63 | value: "h15", 64 | label: "15vh" 65 | }, 66 | { 67 | value: "h20", 68 | label: "20vh" 69 | }, 70 | { 71 | value: "h30", 72 | label: "30vh" 73 | } 74 | ] 75 | }; -------------------------------------------------------------------------------- /src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 63 | 124 | -------------------------------------------------------------------------------- /src/components/selectColor.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 124 | 127 | -------------------------------------------------------------------------------- /src/mock/index.js: -------------------------------------------------------------------------------- 1 | import Mock from "mockjs"; // 引入mockjs 2 | import { transBodyParams } from "../utils"; 3 | 4 | const Random = Mock.Random; // Mock.Random 用于生成各种随机数据 5 | 6 | var getFirstChartInfo = [{ 7 | chartClass: "h20 w32 chartMain1", 8 | chartMainClass: ".chartMain1", 9 | chartType: "line", 10 | chartTit: "证券类产品净值", 11 | chartDetailType: "singleLine", 12 | text: 1, 13 | chartColor: ["#EB3841", "#FEB4B4"], 14 | xData: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 15 | seriesData: [{ 16 | data: [820, 932, 901, 934, 1290, 1330, 1320] 17 | }] 18 | }, 19 | { 20 | chartClass: "h20 w49 chartMain2", 21 | text: 2, 22 | chartDetailType: "doubleLine", 23 | chartTit: "证券类产品净值", 24 | chartType: "line", 25 | chartColor: ["#EB3841", "#6086FF"], 26 | chartMainClass: ".chartMain2", 27 | xData: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 28 | seriesData: [{ 29 | data: [120, 132, 101, 134, 90, 230, 210], 30 | color: "#EB3841" 31 | }, 32 | { 33 | data: [220, 182, 191, 234, 290, 330, 310], 34 | color: "#6086FF" 35 | } 36 | ] 37 | }, 38 | { 39 | chartClass: "h15 w24 chartMain3", 40 | text: 3, 41 | chartDetailType: "singleLine", 42 | chartTit: "证券类产品净值", 43 | chartType: "line", 44 | chartColor: ["#6086FF", "#6086FF"], 45 | chartMainClass: ".chartMain3", 46 | xData: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 47 | seriesData: [{ 48 | data: [1, 2, 3, 4, 5, 6, 7] 49 | }] 50 | }, 51 | { 52 | chartClass: "h15 w24 chartMain4", 53 | text: 4, 54 | chartDetailType: "circlePie", 55 | chartTit: "产品投资者人数", 56 | chartType: "pie", 57 | chartColor: ["#67A8FF", "#D0F6FF", "#FFE059", "#FB764A"], 58 | chartMainClass: ".chartMain4", 59 | xData: ["直接访问", "邮件营销", "联盟广告", "视频广告"], 60 | seriesData: [{ 61 | value: 335, 62 | name: "直接访问" 63 | }, 64 | { 65 | value: 310, 66 | name: "邮件营销" 67 | }, 68 | { 69 | value: 234, 70 | name: "联盟广告" 71 | }, 72 | { 73 | value: 135, 74 | name: "视频广告" 75 | } 76 | ] 77 | }, 78 | { 79 | chartClass: "h15 w24 chartMain5", 80 | text: 5, 81 | chartDetailType: "areaPie", 82 | chartTit: "产品投资者人数", 83 | chartType: "pie", 84 | chartColor: ["#67A8FF", "#D0F6FF", "#FFE059", "#FB764A"], 85 | chartMainClass: ".chartMain5", 86 | xData: [ 87 | "rose1", 88 | "rose2", 89 | "rose3", 90 | "rose4", 91 | ], 92 | seriesData: [{ 93 | value: 10, 94 | name: "rose1" 95 | }, 96 | { 97 | value: 5, 98 | name: "rose2" 99 | }, 100 | { 101 | value: 15, 102 | name: "rose3" 103 | }, 104 | { 105 | value: 25, 106 | name: "rose4" 107 | } 108 | ] 109 | }, 110 | { 111 | chartClass: "h15 w24 chartMain6", 112 | text: 6, 113 | chartDetailType: "rowBar", 114 | chartTit: "盈亏能力展示", 115 | chartColor: ['#6086FF', '#98D1FF', '#FEA145', '#FB764A'], 116 | chartType: "bar", 117 | chartMainClass: ".chartMain6", 118 | xData: ["-20%以下", "-20~0%", "0~20%", "20%以上"], 119 | seriesData: [{ 120 | data: [66, 23, 90, 101] 121 | }] 122 | }, 123 | { 124 | chartClass: "h15 w24 chartMain7", 125 | text: 7, 126 | chartDetailType: "columnBar", 127 | chartTit: "持有期限", 128 | chartType: "bar", 129 | chartColor: ['rgba(152,209,255,0.2)', '#83bff6', '#188df0', '#188df0'], 130 | chartMainClass: ".chartMain7", 131 | xData: ["1年", "1-2年", "2年以上"], 132 | seriesData: [{ 133 | data: [249, 301, 162] 134 | }] 135 | } 136 | ]; 137 | 138 | Mock.mock("/data/firstchart", "get", getFirstChartInfo); 139 | 140 | Mock.mock("/data/lineChart", "post", options => { 141 | var { chartType, chartDetailType } = transBodyParams(options.body); 142 | if (chartType === "line" && chartDetailType === "singleLine") { 143 | return { 144 | xData: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 145 | seriesData: [{ 146 | data: [32, 43, 76, 321, 9756, 32, 99] 147 | }] 148 | }; 149 | } 150 | if (chartType === "line" && chartDetailType === "doubleLine") { 151 | return { 152 | xData: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 153 | seriesData: [{ 154 | data: [120, 132, 101, 134, 90, 230, 210] 155 | }, 156 | { 157 | data: [220, 182, 191, 234, 290, 330, 310] 158 | } 159 | ] 160 | }; 161 | } 162 | if (chartType === "pie") { 163 | return { 164 | xData: ["直接访问", "联盟广告", "视频广告", "搜索引擎"], 165 | seriesData: [{ 166 | value: 335, 167 | name: "直接访问" 168 | }, 169 | { 170 | value: 234, 171 | name: "联盟广告" 172 | }, 173 | { 174 | value: 135, 175 | name: "视频广告" 176 | }, 177 | { 178 | value: 99, 179 | name: "搜索引擎" 180 | } 181 | ] 182 | }; 183 | } 184 | if (chartType === "bar" && chartDetailType === "rowBar") { 185 | return { 186 | xData: ["Mon", "Tue", "Wed", "Thu"], 187 | seriesData: [{ 188 | data: [10, 52, 200, 334] 189 | }] 190 | }; 191 | } 192 | if (chartType === "bar" && chartDetailType === "columnBar") { 193 | return { 194 | xData: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 195 | seriesData: [{ 196 | data: [10, 52, 200, 334, 390, 330, 220] 197 | }] 198 | }; 199 | } 200 | }); -------------------------------------------------------------------------------- /src/components/LineSimple.vue: -------------------------------------------------------------------------------- 1 | 16 | 155 | 214 | -------------------------------------------------------------------------------- /src/components/NavMenu.vue: -------------------------------------------------------------------------------- 1 | 46 | 171 | 228 | -------------------------------------------------------------------------------- /src/utils/chartview.js: -------------------------------------------------------------------------------- 1 | import echarts from "echarts"; 2 | import { 3 | countNumber 4 | } from './index'; 5 | 6 | var linchartResize = [], 7 | piechartResize = [], 8 | barchartResize = [] 9 | 10 | const lineChart = params => { 11 | return new line(params); 12 | }; 13 | 14 | function line(params) { 15 | this.init(params); 16 | } 17 | line.prototype = { 18 | init: function(params) { 19 | var options = []; 20 | this.lineChartArr = params; 21 | for (var i = 0; i < params.length; i++) { 22 | options.push({ 23 | tooltip: { 24 | trigger: 'axis' 25 | }, 26 | grid: { 27 | top: '20%', 28 | bottom: '15%' 29 | }, 30 | xAxis: { 31 | type: "category", 32 | data: params[i].xData, 33 | axisTick: { 34 | show: false 35 | } 36 | }, 37 | yAxis: { 38 | type: "value", 39 | axisTick: { 40 | show: false 41 | }, 42 | axisLine: { 43 | show: false 44 | } 45 | }, 46 | series: (function() { 47 | var series = []; 48 | for (var j = 0; j < params[i].seriesData.length; j++) { 49 | if (params[i].chartDetailType === "singleLine") { 50 | var item = { 51 | data: params[i].seriesData[j].data, 52 | type: "line", 53 | itemStyle: { 54 | color: params[i].chartColor[0] 55 | }, 56 | areaStyle: { 57 | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ 58 | offset: 0, 59 | color: params[i].chartColor[0] 60 | }, 61 | { 62 | offset: 0.4, 63 | color: params[i].chartColor[1] 64 | }, 65 | { 66 | offset: 1, 67 | color: "#fff" 68 | } 69 | ]) 70 | }, 71 | symbol: null, 72 | symbolSize: 0 73 | }; 74 | series.push(item); 75 | } 76 | if (params[i].chartDetailType === "doubleLine") { 77 | var item = { 78 | data: params[i].seriesData[j].data, 79 | type: "line", 80 | itemStyle: { 81 | color: params[i].seriesData[j].color 82 | }, 83 | symbol: null, 84 | symbolSize: 0 85 | }; 86 | series.push(item); 87 | } 88 | } 89 | return series; 90 | })() 91 | }); 92 | } 93 | this.setLinechart(options); 94 | }, 95 | setLinechart: function(options) { 96 | linchartResize = []; 97 | for (var i = 0; i < this.lineChartArr.length; i++) { 98 | for (var j = 0; j < options.length; j++) { 99 | if (i === j) { 100 | this.lineChart = echarts.init( 101 | document.querySelector( 102 | this.lineChartArr[i].chartMainClass + " .charShow" 103 | ) 104 | ); 105 | linchartResize.push(this.lineChart); 106 | this.lineChart.setOption(options[j]); 107 | } 108 | } 109 | } 110 | window.addEventListener( 111 | "resize", 112 | function() { 113 | for (var x = 0; x < linchartResize.length; x++) { 114 | linchartResize[x].resize(); 115 | } 116 | }.bind(this) 117 | ); 118 | } 119 | }; 120 | 121 | const pieChart = params => { 122 | return new pie(params); 123 | }; 124 | 125 | function pie(params) { 126 | this.init(params); 127 | } 128 | pie.prototype = { 129 | init: function(params) { 130 | var options = []; 131 | this.pieChartArr = params; 132 | for (var i = 0; i < params.length; i++) { 133 | options.push({ 134 | tooltip: { 135 | trigger: "item", 136 | formatter: "{a}
{b}: {c} ({d}%)" 137 | }, 138 | legend: { 139 | orient: "vertical", 140 | x: "right", 141 | y: "center" 142 | }, 143 | series: function() { 144 | var series = []; 145 | if (params[i].chartDetailType === "circlePie") { 146 | var circlePieColor = params[i].chartColor 147 | var item = { 148 | type: "pie", 149 | radius: ["50%", "70%"], 150 | center: ["25%", "60%"], 151 | avoidLabelOverlap: false, 152 | label: { 153 | normal: { 154 | show: false, 155 | position: "center" 156 | }, 157 | emphasis: { 158 | show: true, 159 | textStyle: { 160 | fontSize: "18", 161 | fontWeight: "bold" 162 | } 163 | } 164 | }, 165 | labelLine: { 166 | normal: { 167 | show: false 168 | } 169 | }, 170 | data: params[i].seriesData, 171 | itemStyle: { 172 | color: function(param) { 173 | return circlePieColor[param.dataIndex] 174 | } 175 | } 176 | }; 177 | series.push(item); 178 | } 179 | if (params[i].chartDetailType === "areaPie") { 180 | var areaPieColor = params[i].chartColor 181 | var item = { 182 | type: "pie", 183 | radius: ["10%", "60%"], 184 | center: ["30%", "50%"], 185 | roseType: "radius", 186 | label: { 187 | normal: { 188 | show: false 189 | }, 190 | emphasis: { 191 | show: true 192 | } 193 | }, 194 | lableLine: { 195 | normal: { 196 | show: false 197 | }, 198 | emphasis: { 199 | show: true 200 | } 201 | }, 202 | data: params[i].seriesData, 203 | itemStyle: { 204 | color: function(param) { 205 | return areaPieColor[param.dataIndex] 206 | } 207 | } 208 | }; 209 | series.push(item); 210 | } 211 | return series; 212 | }.bind(this)() 213 | }); 214 | } 215 | this.setPieChart(options); 216 | }, 217 | setPieChart: function(options) { 218 | piechartResize = []; 219 | for (var i = 0; i < this.pieChartArr.length; i++) { 220 | for (var j = 0; j < options.length; j++) { 221 | if (i === j) { 222 | this.lineChart = echarts.init( 223 | document.querySelector( 224 | this.pieChartArr[i].chartMainClass + " .charShow" 225 | ) 226 | ); 227 | piechartResize.push(this.lineChart); 228 | this.lineChart.setOption(options[j]); 229 | } 230 | } 231 | } 232 | window.addEventListener( 233 | "resize", 234 | function() { 235 | for (var x = 0; x < piechartResize.length; x++) { 236 | piechartResize[x].resize(); 237 | } 238 | }); 239 | } 240 | }; 241 | 242 | const barChart = params => { 243 | return new bar(params); 244 | }; 245 | 246 | function bar(params) { 247 | this.init(params); 248 | } 249 | bar.prototype = { 250 | init: function(params) { 251 | var options = [] 252 | this.barChartArr = params 253 | for (var i = 0; i < params.length; i++) { 254 | if (params[i].chartDetailType === "rowBar") { 255 | options.push({ 256 | xAxis: { 257 | axisTick: { 258 | show: false 259 | }, 260 | axisLine: { 261 | show: true, 262 | lineStyle: { 263 | type: 'solid', 264 | color: '#e7e7e7', 265 | width: '2' 266 | } 267 | }, 268 | splitLine: { show: false }, 269 | type: 'value', 270 | boundaryGap: [0, 0], 271 | axisLabel: { interval: 0 } 272 | }, 273 | grid: { 274 | left: '23%', 275 | top: '20%', 276 | bottom: '3%' 277 | }, 278 | yAxis: { 279 | type: 'category', 280 | data: params[i].xData, 281 | axisTick: [{ 282 | show: false 283 | }], 284 | axisLine: { 285 | show: true, 286 | lineStyle: { 287 | type: 'solid', 288 | color: '#e7e7e7', 289 | width: '2' 290 | } 291 | }, 292 | axisLabel: { 293 | textStyle: { 294 | fontSize: '14', 295 | fontFamily: 'PingFang SC Medium', 296 | color: '#666' 297 | } 298 | } 299 | }, 300 | series: function() { 301 | var rowBarColor = params[i].chartColor 302 | var series = []; 303 | for (var j = 0; j < params[i].seriesData.length; j++) { 304 | var item = { 305 | type: 'bar', 306 | tooltip: { show: false }, 307 | barWidth: 16, 308 | data: params[i].seriesData[j].data, 309 | itemStyle: { 310 | normal: { 311 | color: (params) => { 312 | return rowBarColor[params.dataIndex] 313 | } 314 | } 315 | } 316 | }; 317 | series.push(item); 318 | } 319 | return series; 320 | }() 321 | }) 322 | } 323 | if (params[i].chartDetailType === "columnBar") { 324 | options.push({ 325 | tooltip: { 326 | trigger: 'axis', 327 | axisPointer: { 328 | type: 'shadow' 329 | } 330 | }, 331 | xAxis: { 332 | data: params[i].xData, 333 | axisLabel: { 334 | textStyle: { 335 | color: '#AAAAAA' 336 | } 337 | }, 338 | axisTick: { 339 | show: false 340 | }, 341 | axisLine: { 342 | show: false 343 | }, 344 | z: 10 345 | }, 346 | grid: { 347 | left: '15%', 348 | top: '20%', 349 | bottom: '15%' 350 | }, 351 | yAxis: { 352 | axisLine: { 353 | show: false 354 | }, 355 | axisTick: { 356 | show: false 357 | }, 358 | axisLabel: { 359 | textStyle: { 360 | color: '#AAAAAA' 361 | } 362 | } 363 | }, 364 | dataZoom: [{ 365 | type: 'inside' 366 | }], 367 | series: function() { 368 | var series = [] 369 | for (var j = 0; j < params[i].seriesData.length; j++) { 370 | this.dataShadow = [] 371 | this.yMax = Math.max.apply(null, params[i].seriesData[j].data) 372 | var countNum = countNumber(this.yMax) 373 | for (var m = 0; m < params[i].seriesData[j].data.length; m++) { 374 | this.dataShadow.push(countNum); 375 | } 376 | var item = { 377 | type: 'bar', 378 | itemStyle: { 379 | normal: { color: params[i].chartColor[0] } 380 | }, 381 | barGap: '-100%', 382 | barCategoryGap: '40%', 383 | data: this.dataShadow, 384 | animation: false 385 | } 386 | var item1 = { 387 | type: 'bar', 388 | itemStyle: { 389 | normal: { 390 | color: new echarts.graphic.LinearGradient( 391 | 0, 0, 0, 1, [ 392 | { offset: 0, color: params[i].chartColor[1] }, 393 | { offset: 0.5, color: params[i].chartColor[2] }, 394 | { offset: 1, color: params[i].chartColor[3] } 395 | ] 396 | ) 397 | }, 398 | emphasis: { 399 | color: new echarts.graphic.LinearGradient( 400 | 0, 0, 0, 1, [ 401 | { offset: 0, color: params[i].chartColor[3] }, 402 | { offset: 0.7, color: params[i].chartColor[2] }, 403 | { offset: 1, color: params[i].chartColor[1] } 404 | ] 405 | ) 406 | } 407 | }, 408 | data: params[i].seriesData[j].data 409 | } 410 | series.push(item, item1) 411 | } 412 | return series; 413 | }.bind(this)() 414 | }) 415 | } 416 | this.setBarChart(options) 417 | } 418 | }, 419 | setBarChart: function(options) { 420 | barchartResize = []; 421 | for (var i = 0; i < this.barChartArr.length; i++) { 422 | for (var j = 0; j < options.length; j++) { 423 | if (i === j) { 424 | this.lineChart = echarts.init( 425 | document.querySelector( 426 | this.barChartArr[i].chartMainClass + " .charShow" 427 | ) 428 | ); 429 | barchartResize.push(this.lineChart); 430 | this.lineChart.setOption(options[j]); 431 | } 432 | } 433 | } 434 | window.addEventListener( 435 | "resize", 436 | function() { 437 | for (var x = 0; x < barchartResize.length; x++) { 438 | barchartResize[x].resize(); 439 | } 440 | }); 441 | } 442 | }; 443 | export { lineChart, pieChart, barChart }; --------------------------------------------------------------------------------