数据通过本地 json 文件嵌入
Data is getting embedded via a local json file
我正在尝试绘制一些数据,该数据位于 pandas 数据框中 cdfs
:
alt.Chart(cdfs).mark_line().encode(
x = alt.X('latency:Q', scale=alt.Scale(type='log'), axis=alt.Axis(format="", title='Response_time (ms)')),
y = alt.Y('percentile:Q', axis=alt.Axis(format="", title='Cumulative Fraction')),
color='write_size:N',
)
问题是,当查看结果图的来源时,只有 url 到 json 文件。找不到 json 文件,因此绘图显示为空白(无数据)。
{
"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
"data": {
"url": "altair-data-78b044f23db74f7d4408fba9f31b9ea9.json",
"format": {"type": "json"}
},
"mark": "line",
"encoding": {
"color": {"type": "nominal", "field": "write_size"},
"x": {
"type": "quantitative",
"axis": {"format": "", "title": "Response_time (ms)"},
"field": "latency",
"scale": {"type": "log"}
},
"y": {
"type": "quantitative",
"axis": {"format": "", "title": "Cumulative Fraction"},
"field": "percentile"
}
},
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json"
}
此代码之前可以正常工作(在图表上显示数据)但是我不时地 运行 重新启动了 jupyterlab 服务器。
因此我想知道为什么数据是通过 url 而不是直接突然嵌入的?
在会话的某个时刻,您必须 运行
alt.data_transformers.enable('json')
如果要恢复将数据直接嵌入图表的默认数据转换器,运行
alt.data_transformers.enable('default')
我正在尝试绘制一些数据,该数据位于 pandas 数据框中 cdfs
:
alt.Chart(cdfs).mark_line().encode(
x = alt.X('latency:Q', scale=alt.Scale(type='log'), axis=alt.Axis(format="", title='Response_time (ms)')),
y = alt.Y('percentile:Q', axis=alt.Axis(format="", title='Cumulative Fraction')),
color='write_size:N',
)
问题是,当查看结果图的来源时,只有 url 到 json 文件。找不到 json 文件,因此绘图显示为空白(无数据)。
{
"config": {"view": {"continuousWidth": 400, "continuousHeight": 300}},
"data": {
"url": "altair-data-78b044f23db74f7d4408fba9f31b9ea9.json",
"format": {"type": "json"}
},
"mark": "line",
"encoding": {
"color": {"type": "nominal", "field": "write_size"},
"x": {
"type": "quantitative",
"axis": {"format": "", "title": "Response_time (ms)"},
"field": "latency",
"scale": {"type": "log"}
},
"y": {
"type": "quantitative",
"axis": {"format": "", "title": "Cumulative Fraction"},
"field": "percentile"
}
},
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json"
}
此代码之前可以正常工作(在图表上显示数据)但是我不时地 运行 重新启动了 jupyterlab 服务器。
因此我想知道为什么数据是通过 url 而不是直接突然嵌入的?
在会话的某个时刻,您必须 运行
alt.data_transformers.enable('json')
如果要恢复将数据直接嵌入图表的默认数据转换器,运行
alt.data_transformers.enable('default')