//路径配置
require.config({
paths: {
echarts:'http://echarts.baidu.com/build/dist'}
});//使用
require(
['echarts','echarts/chart/line','echarts/chart/bar' //使用柱状图就加载bar模块,按需加载
],function(ec) {//基于准备好的dom,初始化echarts图表
var myChart = ec.init(document.getElementById('main'));var option ={
tooltip: {
show:true},
legend: {
data:['Bugs2']
},
toolbox: {
show :true,
feature : {
mark : {show:true},
dataView : {show:true, readOnly: false},
magicType : {show:true, type: ['line', 'bar']},
restore : {show:true},//saveAsImage : {show: true}
}
},
xAxis : [
{
type :'category',
data : []
}
],
yAxis : [
{
type :'value'}
],
series : [{name:'',type:'bar',data:[]}]
};//有bug,不能动弹刷新
$(function() {
$('tr td a').bind('click', function() {//alert($(this).closest('tr').find('td:eq(1)').text());
$.getJSON("/productdatas", {
product: $(this).closest('tr').find('td:eq(1)').text(),
},function(data) {//alert(data.date);
option.xAxis[0].data =data.date;
option.series[0].name =data.name;
option.series[0].data =data.data;
alert(option.series[0].data)
myChart.setOption(option);//myChart.setSeries(data.data);
});
});
});
}
);