After creating three different charts with altair graph API and then merging them as per altair documentation.
(underlay+base+overlay).save("layeredChart.html")
An html file is generated with name layeredChart.html
On opening the html file error comes:
JavaScript Error: Duplicate signal name: "selector002_tuple" This usually means there's a typo in your chart specification. See the javascript console for the full traceback.
What can be the reason for error in html file generation with altair though works fine with jupyter notebook??
Code:
import altair as alt
#altair plot
alt.data_transformers.disable_max_rows()
#Selection tool
selection = alt.selection_single(fields = ['Country/Region'])
#Underlay
base = alt.Chart(de_long).mark_line(strokeWidth=4,opacity=0.7).encode(
x = alt.X('Day'),
y = alt.Y('De',scale=alt.Scale(type='log')),
color = alt.Color('Country/Region',legend=None)
).properties(
width=800,
height=650
).interactive()
print(alt.renderers.names())
#Chart
chart1 = base.encode(
color=alt.condition(selection,'Country/Region:N',alt.value('lightgray'))).add_selection(selection)
#Overlay
overlay = base.encode(
color = 'Country/Region',
opacity = alt.value(0.5),
tooltip = ['Country/Region:N','Name:N']
).transform_filter(selection)
finalChart = (base+chart1+overlay)
finalChart.save("final.html")