我想知道如何在 Echarts 上导入模块化包?我已在此链接中阅读了他们的文档,
但我仍然不知道该怎么做,我必须把那个代码放在哪里?
require.config({
packages: [
{
name: 'echarts',
location: '../../src',
main: 'echarts'
},
{
name: 'zrender',
location: '../../../zrender/src',
main: 'zrender'
}
]
});
这是我图表的代码:
var option = {
tooltip : {
trigger: 'axis'
},
legend: {
data:['a','b']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {readOnly:false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {show: true}
}
},
calculable : true,
dataZoom : {
show : true,
realtime : true,
start : 40,
end : 60
},
xAxis : [
{
type : 'category',
boundaryGap : true,
data : ['sorong','papua','banjarmasin']
}
],
yAxis : [
{
type : 'value'
}
],
series : [
{
name:'b',
type:'bar',
data:[23,34,56]
}
]
};
var ecConfig = require('echarts/config');
function eConsole(param) {
var mes = '';
if (typeof param.seriesIndex != 'undefined') {
window.open("/"+param.name, '_blank');
win.focus();
}
if (param.type == 'hover') {
document.getElementById('hover-console').innerHTML = 'Event Console : ' + mes;
}
else {
document.getElementById('console').innerHTML = mes;
}
console.log(param);
}
return myChart.setOption(option).on(ecConfig.EVENT.CLICK, eConsole);