How to use echarts visualMap to color Line depending on Y-Axis Value or category
See original GitHub issueHow can I use the visualMap correctly to higlight a Line or AreaChart depending on a certain Y Axis VAlue. How can I set up ranges?
Another question, how can I use the visualMap to change the behaviour (color) of certain data depending on the catergory. How could I give my dataseries a parameter like “red” or “green” and use that with the visualMap?
With the follwoing code I can change the color of the data points via a certain category:
<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: 'value'
},
yAxis: {
type: 'value'
},
visualMap: {
show: true,
dimension: 2,
categories: ['Test'],
inRange: {
color: 'red'
},
outOfRange: {
color: 'green'
}
},
series: [{
data: [[1,37,'Test'],[2,36,'Hallo'],[3,36,'Hallo']],
type: 'line',
areaStyle: {}
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
</script>
</body>
</html>
How can I use this to change the color of the connecting lines?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to use echarts visualMap to color Line depending on X ...
I want to divide single line into 2 parts based on x axis value. Example, when x-value is greater than "2016-8" show dashed...
Read more >Visual Mapping - Concepts - Handbook - Apache ECharts
Every type of charts in Apache EChartsTM has this built-in mapping procedure. For example, line chart map data into lines, bar chart map...
Read more >Documentation - Apache ECharts
Apache ECharts, a powerful, interactive charting and visualization library for browser.
Read more >ECharts Document
initialize ECharts instance based on prepared dom var myChart ... dataType: string, // input data value value: number|Array // color of component (useful ......
Read more >Charts configure - pyecharts
xyAxis:x, y axis in cartesian coordinate system(Line, Bar, Scatter, ... visualMap:It is a type of component for visual encoding, which maps the data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://echarts.apache.org/examples/en/editor.html?c=line-aqi
currently visualMap over Y-axis seems buggy to me, see https://codesandbox.io/s/dreamy-neumann-b8iz9?file=/src/App.js
I wish there exists a lower level API to draw different line segment based on individual data item, instead of the current linear gradient solution.