I have my data in an array of the following form:
[{xCoord: 0, group: 8, value: 1},
{xCoord: 0, group: 24, value: 2},
{xCoord: 0, group: 25, value: 1},
{xCoord: 1, group: 19, value: 1},
{xCoord: 1, group: 23, value: 1},
{xCoord: 2, group: 4, value: 7},...]
I want to make a bar chart where above each xCoord is one stack consisting of blocks with heights from the ‘value’ attribute.
The following example is analogous, just with the bars not stacked. My xCoord corresponds to the products, my groups correspond to the years, and my values correspond to the bar heights.
Example Taken from: https://echarts.apache.org/handbook/en/concepts/dataset
Here is the problem: the example has a value for each year, for each product. My data is not so: xCoord = 0 has only groups 8, 24, 25; xCoord = 1 has only 19, 23;...
The obvious workaround is to find all potential groups and fill in their values with zero in each xCoord where appropriate (not overwriting the nonzeroes). However, it seems like there should be some way through ECharts to just plot the data I have, perhaps using dataset along with visualMap. Is anyone aware of how to do this? It would be much easier than filling in the zeroes for each new dataset...
I tried filling in dataset.source using the array described.
Then I went to set dataset.dimensions: ['xCoord', ...groups] and realized I would have to fill in the zeroes for each group in each xCoord this way anyway.