After reading the ECharts documentation and looking at examples, I haven't found anything that would allow coloring scatter plot markers automatically according to a continuous data dimension.
Basically, I'm trying to plot something like this:
What would be the right approach to that problem in ECharts?
For example modifying the basic scatter plot example to use a scalar color
for all data points is possible as follows:
option = {
xAxis: {},
yAxis: {},
series: [{
symbolSize: 20,
data: [
[10.0, 8.04],
[8.0, 6.95],
[13.0, 7.58],
[9.0, 8.81],
[11.0, 8.33],
[14.0, 9.96],
[6.0, 7.24],
[4.0, 4.26],
[12.0, 10.84],
[7.0, 4.82],
[5.0, 5.68]
],
color: '#F00',
type: 'scatter'
}]
};
What I would like to achieve is to pass in a data vector like this for the color
, which doesn't work:
option = {
xAxis: {},
yAxis: {},
series: [{
symbolSize: 20,
data: [
[10.0, 8.04],
[8.0, 6.95],
[13.0, 7.58],
[9.0, 8.81],
[11.0, 8.33],
[14.0, 9.96],
[6.0, 7.24],
[4.0, 4.26],
[12.0, 10.84],
[7.0, 4.82],
[5.0, 5.68]
],
color: [
0.11,
0.53,
0.76,
0.01,
0.53,
0.19,
0.64,
0.65,
0.34,
0.23,
0.81
],
type: 'scatter'
}]
};
The only solution I see is:
Is there a mechanism in ECharts that simplifies this process?
To edit the colours, select the chart -> Format -> Select Series A from the drop down on top left. In the format pane, select the fill and border colours for the marker.
Along the top ribbon, click the Insert tab and then click Insert Scatter (X, Y) within the Charts group to produce the following scatterplot: What is this? The (X, Y) coordinates for each group are shown, with each group possessing a unique color.
A scatter plot is a type of data visualization that shows the relationship between different variables. This data is shown by placing various data points between an x- and y-axis. Essentially, each of these data points looks “scattered” around the graph, giving this type of data visualization its name.
You can draw different color for different point like this in Echarts
const scatterData = data.map((p) => ({
name: 'point',
value: [p.xPos, p.yPos],
itemStyle: p.color
}));
Then in option:
option = {
series:[
{
symbolSize: 20,
data:scatterData,
type: 'scatter',
...
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With