question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add the ability to add different colors in different segments to a single specific series

See original GitHub issue

What problem does this feature solve?

There is no way to give multiple colors to a single series, The expected behavior is something similar to VisualMap, but for a single series instead of the whole chart.

What does the proposed API look like?

Add an object inside the series options to add a visualMap option on it something like

{
  visualMap: {
    ...
  }
}

Or some other way to provide the same functionality such as adding colors per series data points.

We can achieve the same functionality by splitting a single series into multiple series per colored segments, and adding a lineStyle per segment, but unfortunately this leads to a really laggy chart as it significantly increases the number of series.

Output example

We would like to generate a performant version of a graph like this, where a single line can have multiple colors per segments.

image

This is generated by splitting a single line series into multiple line series, each with a different lineStyle

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pissangcommented, Nov 12, 2021

Thanks for the explain. Perhaps you can try using the custom series to render these line segments.

option = {
  xAxis: {
  },
  yAxis: {},
  series: [
    {
      type: 'custom',
      renderItem: function (params, api) {
        var start = api.coord([api.value(0), api.value(1)]);
        var end = api.coord([api.value(2), api.value(3)]);

        return {
          type: 'line',
          shape: {
            x1: start[0],
            y1: start[1],
            x2: end[0],
            y2: end[1]
          },
          style: {
            lineWidth: 2,
            stroke: api.visual('color')
          }
        };
      },
      dimensions: ['x1', 'y1', 'x2', 'y2'],
      encode: {
        x: [0, 1],
        y: [2, 3]
      },
      data: [
        { value: [1, 1, 2, 3], itemStyle: { color: 'red'} },
        { value: [2, 3, 4, 5], itemStyle: { color: 'green'} },
        { value: [4, 5, 5, 10] }
      ]
    }
  ]
};

But you need to process your data a bit to give the start and end point for each segment.

0reactions
pissangcommented, Nov 12, 2021

Custom series can display thousands of data in realtime. But for more data, like more than ten thousands. It may turn on progressive rendering automatically to avoid long rendering time freeze the page.

Here is an example rendering 65k line segments in the custom series with progressive rendering. https://echarts.apache.org/examples/en/editor.html?c=custom-wind

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vary the colors of same-series data markers in a chart
Vary individual data marker colors manually​​ On a chart, select the individual data marker that you want to change. On the Format tab,...
Read more >
how to use different color for different segment of same graph?
Hi all,. I have a figure like this which was obtained by numerical solution. I want to use different color for different segments....
Read more >
Segments · Aircoookie/WLED Wiki - GitHub
This feature allows you to set different zones on the LED strip, each running a different effect or color. A segment is selected...
Read more >
Two lines in ggplot: change colors for segments - Stack Overflow
Basically, for the segment from date 2017-10-22 until 2018-01-28 I would like the Popularity line to be a different color (say, yellow )...
Read more >
Vary Colors by Point Option for Charts in PowerPoint 2010 for ...
When a chart in PowerPoint contains only one series and several categories, then by default individual chart segments may use the same fill ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found