Error concatenating grouped bar charts: Javascript Error: Undefined data set name
See original GitHub issueWhen I tried to concatenate two grouped bar charts, it throws error "Javascript Error: Undefined data set name: “scale_concat_1_child_main”
Example can be reproduced using the grouped bar chart example (https://altair-viz.github.io/gallery/grouped_bar_chart.html)
import altair as alt
from vega_datasets import data
source = data.barley()
test = alt.Chart(source).mark_bar().encode(
x='year:O',
y='sum(yield):Q',
color='year:N',
column='site:N'
)
test & test
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
datasets is undefined when trying to access bars from chart.js
The problem is the library version. In my example and the stack example we use the library: cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/ ...
Read more >Grouped Bar Charts - Salesforce Help
Use a grouped bar chart when you have multiple groupings, and you want to compare values within a secondary grouping, but not the...
Read more >Google Visualization API Reference | Charts
Returns the identifier of a given column specified by the column index in the underlying table. For data tables that are retrieved by...
Read more >Expressions | Vega
In addition, function calls involving nested properties ( foo.bar() ) are not allowed. Instead, the expression language supports a collection of functions ...
Read more >Column State - JavaScript Data Grid
Non-stateful attributes do not change from what is set in the Column Definition (e.g. once the Header Name is set as part of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Details of why this is not working can be found in https://github.com/vega/vega-lite/issues/4680, specifically this comment. It only happens when VegaLite tries to reference the same data set in two concatenated charts. A workaround is to resort the data (e.g.
df.sample(df.shape[0])
), so that VegaLite creates to separate data source references:The obvious caveat is that if you are doing something that depends on the order of your data, this is not a good idea, but for concatenated charts this should be less of an issue as long as the dimensions are shared.
@zhanjiezhu Would you mind closing this issues as it is already tracked upstreams in Vega-Lite in the linked issues and there is no fix needed in Altair?
I found a workaround for that. You need to create each group of bar columns with a graph and then concatenate these graphs, sharing Y scale and hiding/unhiding this axis.