echarts能否用条件语句
1个回答
展开全部
您好:
require([
'echarts',
'echarts/chart/line', //使用线性图,加载line模块
'echarts/chart/map'
], function (ec) {
// 基于已有dom,初始化图表
ecConfig = require('echarts/config');
zrEvent = require('zrender/tool/event');
myChart = ec.init(document.getElementById('main'));
myChart.on(ecConfig.EVENT.MAP_SELECTED, function (param) {
debugger
var len = mapType.length;
var mt = mapType[curIndx % len];
if (mt == 'china') {
// 全国选择时指定到选中的省份
var selected = param.selected;
for (var i in selected) {
if (selected[i]) {
mt = i;
while (len--) {
if (mapType[len] == mt) {
curIndx = len;
}
}
firstSeleted = mt;
break;
}
}
} else {
}
seleted = mt;
a += 1;
timer1 = setTimeout(e2, 300);
});
myChart.setOption(option, true);
});
function e2() {
clearTimeout(timer1);
if (a == 2) {
alert("双击" + seleted);
//双击需要判断在哪个页面双击如,全国页面双击,或者省页面双击
curIndx = 0;
mt = 'china';
option.tooltip.formatter = '点击进入该省<br/>{b}:{c}';
option.series[0].itemStyle.normal.label.formatter = '{a}:{b}';
option.series[0].mapType = seleted;
option.title.subtext = seleted + ' (点击切换)';
option.series[0].data = [];
parent.sendParamData(firstSeleted, a);
}
if (a == 1) {
curIndx = 0;
mt = 'china';
alert("单击" + seleted);
option.tooltip.formatter = '点击返回全国<br/>{b}:{c}';
//调用父页面的javascript 方法传入
option.series[0].mapType = seleted;
option.title.subtext = seleted + ' (点击切换)';
option.series[0].data = [];
//parent.sendParamData(firstSeleted,a);
}
if (a >=2) {
curIndx = 0;
mt = 'china';
}
a = 0;
}
function dataXRand(data) {
// myChart.clear();
var arr = [];
var arrData = data.split(";");
for (var i = 0; i < arrData.length; i++) {
var currentData = arrData[i];
var arrCurrentData = currentData.split(":");
var jsonData = { name: arrCurrentData[0], value: parseInt(arrCurrentData[1]) };
arr.push(jsonData);
}
option.series[0].data = arr;
myChart.setOption(option, true);
}
require([
'echarts',
'echarts/chart/line', //使用线性图,加载line模块
'echarts/chart/map'
], function (ec) {
// 基于已有dom,初始化图表
ecConfig = require('echarts/config');
zrEvent = require('zrender/tool/event');
myChart = ec.init(document.getElementById('main'));
myChart.on(ecConfig.EVENT.MAP_SELECTED, function (param) {
debugger
var len = mapType.length;
var mt = mapType[curIndx % len];
if (mt == 'china') {
// 全国选择时指定到选中的省份
var selected = param.selected;
for (var i in selected) {
if (selected[i]) {
mt = i;
while (len--) {
if (mapType[len] == mt) {
curIndx = len;
}
}
firstSeleted = mt;
break;
}
}
} else {
}
seleted = mt;
a += 1;
timer1 = setTimeout(e2, 300);
});
myChart.setOption(option, true);
});
function e2() {
clearTimeout(timer1);
if (a == 2) {
alert("双击" + seleted);
//双击需要判断在哪个页面双击如,全国页面双击,或者省页面双击
curIndx = 0;
mt = 'china';
option.tooltip.formatter = '点击进入该省<br/>{b}:{c}';
option.series[0].itemStyle.normal.label.formatter = '{a}:{b}';
option.series[0].mapType = seleted;
option.title.subtext = seleted + ' (点击切换)';
option.series[0].data = [];
parent.sendParamData(firstSeleted, a);
}
if (a == 1) {
curIndx = 0;
mt = 'china';
alert("单击" + seleted);
option.tooltip.formatter = '点击返回全国<br/>{b}:{c}';
//调用父页面的javascript 方法传入
option.series[0].mapType = seleted;
option.title.subtext = seleted + ' (点击切换)';
option.series[0].data = [];
//parent.sendParamData(firstSeleted,a);
}
if (a >=2) {
curIndx = 0;
mt = 'china';
}
a = 0;
}
function dataXRand(data) {
// myChart.clear();
var arr = [];
var arrData = data.split(";");
for (var i = 0; i < arrData.length; i++) {
var currentData = arrData[i];
var arrCurrentData = currentData.split(":");
var jsonData = { name: arrCurrentData[0], value: parseInt(arrCurrentData[1]) };
arr.push(jsonData);
}
option.series[0].data = arr;
myChart.setOption(option, true);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询