当我绘制由两组线组成的分层图表时,某一层中的工具提示不显示。这也发生在 VL 编辑器中。任何有关为什么会发生这种情况的见解都将不胜感激。
这是一个可重现的示例来演示该问题(实际上我在第一层有更多行):
牛郎星版本 4.0.0
df=pd.DataFrame({'school_code': ['AQUI', 'Board'] * 5, 'y4_rate': [.1, .2, .3, .4, .5, .1, .2, .3, .4, .5],
'cohort_year': ['1', '1', '2', '2','3', '3', '4', '4', '5', '5']})
sch=alt.Chart(df).mark_line(point=True).encode(
x=alt.X('cohort_year', axis=alt.Axis(labels=False)),
y=alt.Y('y4_rate', axis=alt.Axis(format='.0%'), title='Percentage of Students'),
color=alt.Color('school_code', title=None, legend=alt.Legend(labelFontSize=15, titleFontSize=20)),
tooltip=[alt.Tooltip('y4_rate', title='percentage of students', format='.0%')]
).transform_filter(alt.datum.school_code != 'Board')
brd=alt.Chart(df).mark_line(point=True).encode(
x=alt.X('cohort_year', axis=alt.Axis(labels=False)),
y=alt.Y('y4_rate', axis=alt.Axis(format='.0%'), title='Percentage of Students'),
color=alt.Color('school_code', title=None, legend=alt.Legend(labelFontSize=15, titleFontSize=20),scale=alt.Scale(range=['black'])),
tooltip=[alt.Tooltip('y4_rate', title='percentage of students', format='.0%')]
).transform_filter(alt.datum.school_code == 'Board')
alt.layer(sch, brd).resolve_scale(color='independent').properties(width=700, height=400).interactive()