Adding text to bar chart throws 'data is a required property' error
See original GitHub issueWhen I run this code, I get a ‘data is a required property’ error (pasted below the code). When I just try to run the bar graph with data specified within Chart() it works.
bars = alt.Chart().mark_bar(stroke='transparent').encode(
alt.X('model', scale=alt.Scale(rangeStep=12), axis=alt.Axis(title='')),
alt.Y('ratio:Q', axis=alt.Axis(title='ratio', grid=False)),
color=alt.Color('model:N', scale=alt.Scale(range=["#EA98D2", "#659CCA", '#5bb3a4'])),
column='time:O',
)
text = alt.Chart().mark_text(
align='left',
baseline='middle'
).encode(
y = alt.Y('ratio'),
x = 'model',
text='ratio')
alt.layer(bars, text, data=df_concat).configure(
legend=LegendConfig(labelFontSize=16, titleFontSize=16, symbolSize=100, labelFont='Lato'), axis=AxisConfig(labelFontSize=16, tickSize=16, labels=True, titleFontSize=16))
Error Message:
SchemaValidationError: Invalid specification
altair.vegalite.v2.api.Chart, validating 'required'
'data' is a required property
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Altair SchemaValidation Error When Faceting - Stack Overflow
SchemaValidationError: Invalid specification altair.vegalite.v4.api.Chart, validating 'required' 'data' is a required property alt.FacetChart(..
Read more >Required Property Value Error - OutSystems 11 Documentation
Required Property Value: A valid expression must be set for parameter 'SourceDataPointList'. Cause. You added an Area Chart, Bar Chart, ...
Read more >Add, change, or remove error bars in a chart - Microsoft Support
On 2-D area, bar, column, line, xy (scatter), or bubble chart, do one of the following: To add error bars to all data...
Read more >Create Bar Chart using D3 - TutorialsTeacher
Learn how to create SVG bar chart with scales and axes in D3. ... + "," + 100 + ")"); d3.csv("XYZ.csv", function(error, data)...
Read more >Bar Charts | Google Developers
Like all Google charts, bar charts display tooltips when the user hovers over the data. For a vertical version of this chart, see...
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
@lcyraphael Off the top of my head I think you want to configure the header if I understand correctly.
Ah, I see now. The error is unfortunately not particularly informative here, but the core issue is that you cannot use a faceted chart within a layer (from the perspective of the renderer, it’s ill-defined what the user intends in that case).
The alternative is to create a layered chart first, and then facet it. For example: