You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by Yi Shen <sh...@gmail.com> on 2019/12/17 03:13:20 UTC

Re: I made it finally !

Thanks and congrats!

I am thinking to write a function that takes the incoming array and loops
> over it. If a data point is green data it will insert the data into Green
> series object  or else to red Series object. Will that work?
>

Yes that will work.

Sample code snippets

series: [{
  name: 'Red Data',
  type: 'bar',
  data: yourDataArray.filter(item => item.type === 'red')
}, {
  name: 'Green Data',
  type: 'bar',
  data: yourDataArray.filter(item => item.type === 'green')
}]

On Mon, Dec 16, 2019 at 9:37 PM Ayaskant Swain <ay...@gmail.com>
wrote:

> Hi Yi,
>
> After a lot of tries i finally made it. Yes now i am able to plot the
> incoming dynamic data with a moving window (setInterval every 5 seconds) in
> e-chart.
>
> e-chart is awesome :-).
>
> You were correct. e-chart will plot whatever data we feed it. The logic of
> feeding data depends on our javascript code.
>
> I have a question now. I want to use two legends in my graph for toggling.
> One for green bar and the other for red colored bars. What i have
> understood so far from e-chart bar chart examples is I need to define the
> legends under option like this -
>
> legend: {
>         data:['Green Data', 'Red Data']
>     },
>
> And then in Series array i should have two data objects one for 'Green
> Data' and other for 'Red Data'.
>
> But my question is how to supply the data to both these series objects?
> The X-axis will plot time. Depending on an attribute of data i will put a
> data point either to Green or to Red legend on Y-Axis.
>
> I am thinking to write a function that takes the incoming array and loops
> over it. If a data point is green data it will insert the data into Green
> series object  or else to red Series object. Will that work?
>
> Data comes like this to the function -
> [
>  {
>    value: 10,
>     type: 'green',
>     time : '9:00:02'
>   },
>   {
>      value: 20,
>      type : 'green',
>      time : '9:00:05'
>    },
>    {
>      value: 60,
>      type : 'red',
>      time : '9:00:05'
>    },
> ]
>
> Thanks
> Ayaskant
>
>

-- 
Yi Shen
Apache ECharts(incubating) PPMC