You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by Maël Naccache <ma...@manty.eu> on 2023/06/05 08:52:43 UTC

Using the values from a dataset column as a serie declaration.

Hi !

I would like to know if it is possible to use the values of a column as
series in a dataset.
For example, if I have the following dataset:
```
let dataset {
dimensions: ["amount", "year", "status"],
source: [
{ amount: 100, year: 2000, status: "A" },
{ amount: 150, year: 2001, status: "B" },
{ amount: 200, year: 2002, status: "C" }
]
};
```
Is it possible to "tell" eChart that I want to create series "A", "B" and
"C" ? And that each serie should use row with the same value (e.g the serie
"A" only use row from the dataset that have the value of "status" as "A").

I know it is possible by filtering the dataset and passing the data for
each serie manually. That is what we use to do, like so:
```
let series = [
{ type: 'bar', name: 'A', data: [ { amount: 100, year: 2000 } ]},
{ type: 'bar', name: 'B', data: [ { amount: 150, year: 2001 } ]},
{ type: 'bar', name: 'C', data: [ { amount: 200, year: 2002 } ]},
]
```
But doing this makes it hard to use Data Transform.

So do you know of any way of achieving this while keep using the dataset
format ?

Faithfully yours,
-- 
Cordialement,
Maël Naccache Tüfekçi, /maɛl nakaʃ tyfekʧi/
Ingénieur en Génie Logiciel, Manty
mael.naccache@manty.eu, +33 6 58 89 84 09

Re: Using the values from a dataset column as a serie declaration.

Posted by Maël Naccache <ma...@manty.eu>.
Hello again !
Sorry to answer my own email. I have been thinking about it and I figured
out that I can use the 'filter' Data Transform to generate one dataset per
serie/category  just like in the 'data transform filter' example.
It works perfectly so it is solved :) .
Faithfully yours,

Le lun. 5 juin 2023 à 10:52, Maël Naccache <ma...@manty.eu> a
écrit :

> Hi !
>
> I would like to know if it is possible to use the values of a column as
> series in a dataset.
> For example, if I have the following dataset:
> ```
> let dataset {
> dimensions: ["amount", "year", "status"],
> source: [
> { amount: 100, year: 2000, status: "A" },
> { amount: 150, year: 2001, status: "B" },
> { amount: 200, year: 2002, status: "C" }
> ]
> };
> ```
> Is it possible to "tell" eChart that I want to create series "A", "B" and
> "C" ? And that each serie should use row with the same value (e.g the serie
> "A" only use row from the dataset that have the value of "status" as "A").
>
> I know it is possible by filtering the dataset and passing the data for
> each serie manually. That is what we use to do, like so:
> ```
> let series = [
> { type: 'bar', name: 'A', data: [ { amount: 100, year: 2000 } ]},
> { type: 'bar', name: 'B', data: [ { amount: 150, year: 2001 } ]},
> { type: 'bar', name: 'C', data: [ { amount: 200, year: 2002 } ]},
> ]
> ```
> But doing this makes it hard to use Data Transform.
>
> So do you know of any way of achieving this while keep using the dataset
> format ?
>
> Faithfully yours,
> --
> Cordialement,
> Maël Naccache Tüfekçi, /maɛl nakaʃ tyfekʧi/
> Ingénieur en Génie Logiciel, Manty
> mael.naccache@manty.eu, +33 6 58 89 84 09
>


-- 
Cordialement,
Maël Naccache Tüfekçi, /maɛl nakaʃ tyfekʧi/
Ingénieur en Génie Logiciel, Manty
mael.naccache@manty.eu, +33 6 58 89 84 09