python - 如何隐藏 Django Chartit 图表的 xAxis 和 yAxis 标题?
问题描述
我想在一个小图表中隐藏 x/y 轴标题。我尝试从中删除xAxis
和yAxis
字段chart_options
,但结果相同。有人可以帮忙吗?
return Chart(
datasource=blockpivotdata,
series_options=[{
'options': {
'type': 'line',
'stacking': False
},
'terms': {
'date': [
'num',
]
}
}],
chart_options={
'title': {
'text': 'Block Count Chart'},
'xAxis': {
'title': {
'text': 'Date'}}, <<<< this one
'yAxis': {
'title': {
'text': 'Blocks'}}, <<<< and this one
'legend': {
'enabled': False},
'credits': {
'enabled': False}},
)
顺便说一句,我正在使用Django version 2.0
,django-chartit 0.2.9
和Python 3.7.0
.
解决方案
后来,我找到了一个解决方案,只想在这里粘贴以防万一有人需要。
chart_options={
'title': {
'text': 'Your Title'
},
'xAxis': [
{
'title': {
'text': 'Date',
'style': {
'display': 'none'
}
},
'labels': {
'enabled': True
}
},
{
'title': {
'text': 'Date',
'style': { <<<<
'display': 'none' <<<< use this to hide axis title
}
},
'labels': {
'enabled': False
},
'lineColor': 'transparent',
'tickLength': 0,
}
],
'yAxis': [
{
'title': {
'text': 'Blocks',
'style': {
'color': '#70b3ef'
}
},
'labels': {
'enabled': False
},
},
{
'title': {
'text': 'Total Diff'
},
'labels': {
'enabled': False
}
}
],
'legend': {
'enabled': False
},
}
你可以在这里看到一个活生生的例子:https ://grinexplorer.net
推荐阅读
- c# - 更改 DateTime 月份 -> " list[i].date.Month = Int32.Parse(Console.ReadLine()); "
- amazon-ecs - 为 ECS 服务创建负载均衡器,无需一个
- javascript - 如何从 Node JS 中的 url 下载文件?
- composer-php - 为什么 composer create-project 在请求 dev 依赖项时失败,但使用 --no-plugins 标志成功?
- c++ - 如何修复'glGenVertexArrays'没有依赖于模板参数的参数......'c ++中的错误
- c# - 在 Xamarin 上将 android 更改为 x64 时在 sqlite 中创建表时出错
- python - 如何在 Windows 中拆分长 Linux 命令
- python - 熊猫变量的两步正则表达式
- python - Apache Airflow DAG 不调用 on_success_callback 和 on_failure_callback
- laravel - 方法 update() 的日期检查