Вы можете использовать волшебное событие с изменением .
option = {
color: ['#3398DB'],
legend: {},
toolbox: {
feature: {
magicType: {
type: ['line', 'bar', 'stack']
}
},
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: 100,
right: 100,
bottom: 100,
top: 100,
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisTick: {
alignWithLabel: true
}
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: 'test',
type: 'bar',
barWidth: '60%',
data: [10, 52, 200, 334, 390, 330, 220]
}
]
};
myChart.on('magictypechanged', function(e) {
if (e.currentType === "line")
{
myChart.setOption({
legend: {
textStyle: {
color: "#0f0"
}
}
});
}
else {
myChart.setOption({
legend: {
textStyle: {
color: "#000"
}
}
});
}
});
Приведенный выше код является модификацией в этом примере