What problem does this feature solve?
Currently, while Echarts supports providing the data via a dataset, the dataset needs to be in pivot table format: that is two dimensions (x and y) with a value where they meet.
Let's take the World population example data from this demo.
While in that demo the data is not provided by a dataset, we can define a dataset to create the same result like so (reducing to 3 countries for brevity):
dataset: {
dimensions: [
'Country', '2011', '2012'
],
source: [
['Brazil', 18203, 19325],
['Indonesia', 23489, 23438],
['USA', 29034, 31000],
]
},
Result here.
However, this format only works for certain types of data. For example, how would you now draw a chart that further breaks down population by Male population and Female population (as stacked bars)?
It also has other, more minor, problems:
- This format assumes you have exactly one data point per year per country, which may not be the case (though you can just specify
undefined)
- This format is clumsy if the data from 2011 and 2012 come from different collections: we first need to iterate over both arrays and combine them.
- The header is a weird mix of the name of one dimension ("Country") with the values of the other. There is no way to say what these values actually are (Year).
In the database world, it's more common to represent data as records, i.e.:
dataset: {
dimensions: [
'Country', 'Year', 'Population'
],
source: [
['Brazil', 2011, 18203],
['Brazil', 2012, 19325],
['Indonesia', 2011, 23489],
['Indonesia', 2012, 23438],
['USA', 2011, 29034],
['USA', 2012, 31000]
]
},
However, there doesn't seem to be a simple way to draw the same chart with this kind of dataset (failed demo here). I've literally tried every combination of encode, name on series, etc since yesterday and it simply does not seem possible.
I know there is a way involving data transform, with one filter per year, but that's inefficient in the general case (O(N) per filter means O(N^2) worst case).
Apologies if I’m missing something and that's already possible (without one filter per year!).
(Note that this World population demo is just example data to illustrate the problem, I'm not actually drawing world population charts!)
What does the proposed API look like?
I'm not yet familiar enough with the Echarts API to propose changes to it. Perhaps a way to declare that data is in record format? Or a data transform to essentially do group by?
What problem does this feature solve?
Currently, while Echarts supports providing the data via a dataset, the dataset needs to be in pivot table format: that is two dimensions (x and y) with a value where they meet.
Let's take the World population example data from this demo.
While in that demo the data is not provided by a dataset, we can define a dataset to create the same result like so (reducing to 3 countries for brevity):
Result here.
However, this format only works for certain types of data. For example, how would you now draw a chart that further breaks down population by Male population and Female population (as stacked bars)?
It also has other, more minor, problems:
undefined)In the database world, it's more common to represent data as records, i.e.:
However, there doesn't seem to be a simple way to draw the same chart with this kind of dataset (failed demo here). I've literally tried every combination of
encode,nameon series, etc since yesterday and it simply does not seem possible.I know there is a way involving data transform, with one filter per year, but that's inefficient in the general case (O(N) per filter means O(N^2) worst case).
Apologies if I’m missing something and that's already possible (without one filter per year!).
(Note that this World population demo is just example data to illustrate the problem, I'm not actually drawing world population charts!)
What does the proposed API look like?
I'm not yet familiar enough with the Echarts API to propose changes to it. Perhaps a way to declare that data is in record format? Or a data transform to essentially do group by?