echart markline data怎么取传进来的值
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了echart markline data怎么取传进来的值相关的知识,希望对你有一定的参考价值。
参考技术A 你把你的数组返回值中间用个符号分割,比如分号["a1","b1"];["a2"',"b2"],然后用split";"进行分割就可以分开使用了。var t = "['a1','b1'];['a2'','b2']";
var ts = t.split(";");
alert(ts[0]);
alert(ts[1]);
下面这个写法写错了
function initialize(cc)
var html;
$.post("some1.php",value:cc,function(data)var html=data;,"json");
alert(html);
不应该在function(data)里面申明var html,否则html会变成这个方法的体局部变量。你应该改成。
function initialize(cc)
var html;
$.post("some1.php",value:cc,function(data)html=data;,"json");
alert(html);
但是即便这样改了,alert(html)仍然是空。
你还没有搞清楚ajax的逻辑。ajax是异步的。function(data)里的内容是延迟执行,在你最后alert(html)的时候,function(data)还没有执行,所以alert(html)永远是空。
Echarts自定义图表显隐开关
- 插入折线
// 插入折线 function appendLineToChart(name, data, zeroData) { var line = { name: name, type: ‘line‘, xAxisIndex: 0, smooth: false, connectNulls: true, data: data, markLine: { lineStyle: { type: ‘dashed‘ }, data: zeroData } } option.series.push(line); chart.setOption(option); }
- 清除折线
function removeLineFromChart(name) { var index = -1; for (var i = 0; i < option.series.length; i++) { if (option.series[i].name == name) { index = i; break; } } if (index > -1) { option.series.splice(index, 1); chart.setOption(option, true); // 设置option不合并(覆盖) } }
- 对于其中的交互和传值可以动态的去创建对象
function parseSkData(skData, dataInfo) { var skTime = dataInfo.time; var skAgingType = dataInfo.skAgingType; var fileName = getSKFileName(skTime, skAgingType); data = skData["stationDataList"]; var Station = {}; Station[fileName + ‘:tmp‘] = new Array(); Station[fileName + ‘:dp‘] = new Array(); Station[fileName + ‘:tmp_zero‘] = null; if (!(data == null || data == undefined || data == ‘‘)) { /*获取折线折点*/ for (var i = 0; i < data.length; i++) { var line = data[i]; var _dew = line.dew; var _height = line.height; var _hpa = line.hpa; var _tmp = line.tmp; var _winDir = line.winDir; var _winSpeed = line.winSpeed; _dew = _dew == 9999 ? ‘-‘ : _dew; _height = _height == 9999 ? ‘-‘ : _height; _hpa = _hpa == 9999 ? ‘-‘ : _hpa; _tmp = _tmp == 9999 ? ‘-‘ : _tmp; _winDir = _winDir == 9999 ? ‘-‘ : _winDir; _winSpeed = _winSpeed == 9999 ? ‘-‘ : _winSpeed; Station[fileName + ‘:tmp‘][i] = new Array(_tmp, _hpa); Station[fileName + ‘:dp‘][i] = new Array(_dew, _hpa); } Station[fileName + ‘:tmp_area_data‘] = []; Station[fileName + ‘:tmp_zero‘] = calcZero(data, ‘tmp‘, Station[fileName + ‘:tmp_area_data‘]); /*计算冷暖层强度*/ if (Station[fileName + ‘:tmp_zero‘].length > 1) { Station[fileName + ‘:tmp_areas‘] = []; Station[fileName + ‘:tmp_areas‘] = calAreas(Station[fileName + ‘:tmp_area_data‘]); } } return Station; }
以上是关于echart markline data怎么取传进来的值的主要内容,如果未能解决你的问题,请参考以下文章