echarts
echarts copied to clipboard
Error when using array of Options (componentType.split is not a function)
问题简述 (One-line summary)
Uncaught TypeError: componentType.split is not a function
版本及环境 (Version & Environment)
- ECharts 版本 (ECharts version): 3.3.1
- 浏览器类型和版本 (Browser version): Version 54.0.2840.71 m (64-bit)
- 操作系统类型和版本 (OS Version): Windows 10
期望结果 (Expected behaviour)
I am trying to test this in my program http://gallery.echartsjs.com/editor.html?c=xHJkfwxiZx .
可能哪里有问题 (What went wrong)
When trying to add array of options it shows the "Uncaught TypeError: componentType.split is not a function" error.
I tried to trace the error, it occurred in "echarts.js:5317:44" . The value of the variable "componentType" became 1 which is no a string.
Thanks, Fadhil
ECharts配置项 (ECharts option)
var myChart = echarts.init(document.getElementById('main'));
// specify chart configuration item and data
options =
[
{
backgroundColor: "#ffffff",
color: ['#ffd285', '#ff733f'],
title: {
text: 'Min & Max Temp ',
x: '5%',
top: '6%',
textStyle: {
color: '#ffd285'
}
},
tooltip: {
trigger: 'axis'
},
legend: {
x: 200,
top: '6%',
textStyle: {
color: '#ffd285',
},
data: ['Min', 'Max']
},
grid: {
left: '6%',
right: '2%',
top: '16%',
bottom: '6%',
containLabel: true
},
toolbox: {
"show": false,
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'category',
"axisLine": {
lineStyle: {
color: '#c0576d'
}
},
"axisTick": {
"show": false
},
axisLabel: {
textStyle: {
color: '#ffd285'
}
},
boundaryGap: false,
data: ["2016111306", "2016111406", "2016111506", "2016111606", "2016111706", "2016111806", "2016111906"]
},
yAxis: {
"axisLine": {
lineStyle: {
color: '#c0576d'
}
},
splitLine: {
show: true,
lineStyle: {
color: '#c0576d'
}
},
"axisTick": {
"show": false
},
axisLabel: {
textStyle: {
color: '#ffd285'
}
},
type: 'value'
},
series: [{
name: 'Min',
smooth: true,
type: 'line',
symbolSize: 8,
stack: 'Total',
areaStyle: {
normal: {}
},
data: [18.5, 17, 18, 20, 22, 21, 23]
}, {
name: 'Max',
smooth: true,
type: 'line',
symbolSize: 8,
stack: 'Total',
areaStyle: {
normal: {}
},
data: [33, 30.5, 35, 34, 35.5, 32, 31]
}]
},
{
backgroundColor: "#ffffff",
color: ['#ffd285', '#ff733f'],
title: {
text: 'Over All Error',
x: 'center',
top: '6%',
textStyle: {
color: '#ffd285'
}
},
series: [
{
type: 'pie',
center: ['50%', '33%'],
radius: ['45%', '60%'],
label: {
normal: {
position: 'center'
}
},
data: [{
value: 335,
name: 'Over All Error',
itemStyle: {
normal: {
color: '#ffd285'
}
},
label: {
normal: {
formatter: '{d} %',
textStyle: {
color: '#ffd285',
fontSize: 20
}
}
}
}, {
value: 310,
name: 'Placeholder',
tooltip: {
show: false
},
itemStyle: {
normal: {
color: '#b04459'
}
},
label: {
normal: {
textStyle: {
color: '#ffd285',
},
formatter: '\nMin'
}
}
}]
},
{
type: 'pie',
center: ['50%', '72%'],
radius: ['45%', '60%'],
label: {
normal: {
position: 'center'
}
},
data: [{
value: 335,
name: 'Over All Error',
itemStyle: {
normal: {
color: '#ff733f'
}
},
label: {
normal: {
formatter: '{d} %',
textStyle: {
color: '#ff733f',
fontSize: 20
}
}
}
}, {
value: 210,
name: 'Placeholder',
tooltip: {
show: false
},
itemStyle: {
normal: {
color: '#b04459'
}
},
label: {
normal: {
textStyle: {
color: '#ff733f',
},
formatter: '\nMax'
}
}
}]
}
]
},];
// use configuration item and data specified to show chart
myChart.setOption(options);
}
其他信息 (Other comments)
when you add array of options, it will merge options and will iterative the option properties. There shows an error becauseof iterativing an array not an object. Change the options to an object and try again