Echart:控制区颜色
Echart: Control area color
是否有可能像在 Google 图表中那样使用电子图表更改每个数据点的区域颜色:
我需要类似于 列角色 样式的内容参数:
data2.addRows([['2011-04-04', 7175, 'area { color: green }']...
这可以通过 Visual Map and Pieces 实现。您可以使用 min max 参数为具有特定颜色的多个元素范围着色:
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts.min.js"></script>
</head>
<body>
<div id="main_chart" style="width: 1200px;height:600px;"></div>
<script type="text/javascript">
// based on prepared DOM, initialize echarts instance
var myChart = echarts.init(document.getElementById('main_chart'));
var app = {};
option = null;
option = {
xAxis: {
type: 'category',
data: ['2012-03-01 05:06', '2012-03-01 05:07', '2012-03-01 05:08', '2012-03-01 05:09', '2012-03-01 05:10', '2012-03-01 05:11']
},
yAxis: {
type: 'value'
},
dataZoom: [
{
type: 'slider',
xAxisIndex: 0,
filterMode: 'filter'
},
{
type: 'slider',
yAxisIndex: 0,
filterMode: 'empty'
},
{
type: 'inside',
xAxisIndex: 0,
filterMode: 'filter'
},
{
type: 'inside',
yAxisIndex: 0,
filterMode: 'empty'
}
],
visualMap: {
show: false,
dimension: 0,
pieces: [
{min: 0, max: 2, color: 'red'},
{min: 2, max: 4, color: 'green'},
{min: 4, max: 6, color: 'yellow'}
]
},
series: [{
data: [20,
{
value: 22,
itemStyle: {
normal: {
color: 'green',
lineStyle: {
color: 'green'
},
areaStyle: {
color: 'green'
},
}
}
},
{
value: 26,
itemStyle: {
normal: {
color: 'green'
}
}
},
25, 27, 30, 25],
type: 'line',
areaStyle: {}
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
</script>
</body>
</html>
是否有可能像在 Google 图表中那样使用电子图表更改每个数据点的区域颜色:
我需要类似于 列角色 样式的内容参数:
data2.addRows([['2011-04-04', 7175, 'area { color: green }']...
这可以通过 Visual Map and Pieces 实现。您可以使用 min max 参数为具有特定颜色的多个元素范围着色:
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts.min.js"></script>
</head>
<body>
<div id="main_chart" style="width: 1200px;height:600px;"></div>
<script type="text/javascript">
// based on prepared DOM, initialize echarts instance
var myChart = echarts.init(document.getElementById('main_chart'));
var app = {};
option = null;
option = {
xAxis: {
type: 'category',
data: ['2012-03-01 05:06', '2012-03-01 05:07', '2012-03-01 05:08', '2012-03-01 05:09', '2012-03-01 05:10', '2012-03-01 05:11']
},
yAxis: {
type: 'value'
},
dataZoom: [
{
type: 'slider',
xAxisIndex: 0,
filterMode: 'filter'
},
{
type: 'slider',
yAxisIndex: 0,
filterMode: 'empty'
},
{
type: 'inside',
xAxisIndex: 0,
filterMode: 'filter'
},
{
type: 'inside',
yAxisIndex: 0,
filterMode: 'empty'
}
],
visualMap: {
show: false,
dimension: 0,
pieces: [
{min: 0, max: 2, color: 'red'},
{min: 2, max: 4, color: 'green'},
{min: 4, max: 6, color: 'yellow'}
]
},
series: [{
data: [20,
{
value: 22,
itemStyle: {
normal: {
color: 'green',
lineStyle: {
color: 'green'
},
areaStyle: {
color: 'green'
},
}
}
},
{
value: 26,
itemStyle: {
normal: {
color: 'green'
}
}
},
25, 27, 30, 25],
type: 'line',
areaStyle: {}
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
</script>
</body>
</html>