|
@@ -6,25 +6,84 @@ function Chart({ options }) {
|
|
|
let chartInstance = null;
|
|
let chartInstance = null;
|
|
|
|
|
|
|
|
options = eval('('+options.substring(8)+')');
|
|
options = eval('('+options.substring(8)+')');
|
|
|
- console.log(options)
|
|
|
|
|
-
|
|
|
|
|
- const options1 = {
|
|
|
|
|
- tooltip: {},
|
|
|
|
|
- legend: {
|
|
|
|
|
- data: [""],
|
|
|
|
|
- },
|
|
|
|
|
- xAxis: {
|
|
|
|
|
- data: options.data.map(obj => {return obj.name}),
|
|
|
|
|
|
|
+ options = {
|
|
|
|
|
+ "chartType": "line",
|
|
|
|
|
+ "xData": [
|
|
|
|
|
+ "江苏",
|
|
|
|
|
+ "浙江",
|
|
|
|
|
+ "广东",
|
|
|
|
|
+ "广州",
|
|
|
|
|
+ "北京",
|
|
|
|
|
+ "山西",
|
|
|
|
|
+ "河北"
|
|
|
|
|
+ ],
|
|
|
|
|
+ "data": {
|
|
|
|
|
+ "2023上半年":['120%', '132%', '101%', '134%', '90%', '230%', '210%'],
|
|
|
|
|
+ "2024上半年":['220%', '182%', '191%', '234%', '290%', '330%', '310%']
|
|
|
},
|
|
},
|
|
|
- yAxis: {},
|
|
|
|
|
- series: [
|
|
|
|
|
- {
|
|
|
|
|
- name: "",
|
|
|
|
|
- type: options.chartType,
|
|
|
|
|
- data: options.data.map(obj => {return obj.value}),
|
|
|
|
|
|
|
+ "legend": [],
|
|
|
|
|
+ "pieData": []
|
|
|
|
|
+ }
|
|
|
|
|
+ options.legend = Object.keys(options.data);
|
|
|
|
|
+ options.pieData = [];
|
|
|
|
|
+ options.series = [];
|
|
|
|
|
+
|
|
|
|
|
+ options.xData.map((data,index) =>{
|
|
|
|
|
+ options.pieData.push({'name':data,'value':options.data[options.legend[0]][index].split("%").join("")})
|
|
|
|
|
+ })
|
|
|
|
|
+ options.legend.map((data,index) =>{
|
|
|
|
|
+ let list = [];
|
|
|
|
|
+ options.data[data].map(data1 =>{
|
|
|
|
|
+ list.push(data1.split("%").join(""))
|
|
|
|
|
+ });
|
|
|
|
|
+ options.series.push({
|
|
|
|
|
+ name: data,
|
|
|
|
|
+ type: options.chartType,
|
|
|
|
|
+ data: list,
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(options)
|
|
|
|
|
+ let options1;
|
|
|
|
|
+ if(options.chartType == "pie"){
|
|
|
|
|
+ options1 = {
|
|
|
|
|
+ tooltip: {},
|
|
|
|
|
+ series: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Access From',
|
|
|
|
|
+ type: 'pie',
|
|
|
|
|
+ radius: '50%',
|
|
|
|
|
+ label: {
|
|
|
|
|
+ normal: {
|
|
|
|
|
+
|
|
|
|
|
+ textStyle: { // 提示文字的样式
|
|
|
|
|
+ color: '#fff',
|
|
|
|
|
+ fontSize: 14
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ data: options.pieData,
|
|
|
|
|
+ emphasis: {
|
|
|
|
|
+ itemStyle: {
|
|
|
|
|
+ shadowBlur: 10,
|
|
|
|
|
+ shadowOffsetX: 0,
|
|
|
|
|
+ shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ };
|
|
|
|
|
+ }else{
|
|
|
|
|
+ options1 = {
|
|
|
|
|
+ tooltip: {
|
|
|
|
|
+ trigger: 'axis'
|
|
|
},
|
|
},
|
|
|
- ],
|
|
|
|
|
-};
|
|
|
|
|
|
|
+ xAxis: {
|
|
|
|
|
+ data: options.xData,
|
|
|
|
|
+ },
|
|
|
|
|
+ yAxis: {},
|
|
|
|
|
+ series: options.series,
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
// 定义渲染函数
|
|
// 定义渲染函数
|
|
|
function renderChart() {
|
|
function renderChart() {
|
|
|
try {
|
|
try {
|