通过使用plotly,我正在创建我的分析仪表板,其中包含饼图,条形图和不同类型的图表。我有一个饼图,其中有大量的数据和传说,差不多有60个。它在浏览器(更大的屏幕)中正确呈现的问题在于移动屏幕。图表图例与实际图表重叠。我希望在移动屏幕中显示如下图表。任何人都可以帮助我。
我的Json看起来如下。
{
"data": [{
"values": [1058,177,75,53,28,23,15,8,7,6,5,5,2,2,1,1,1,1,1,1,0],
"labels": ["Vision Corporation","Corporate Human Resources","Human Resources-West","Human Resources-East","Human Resources-Central","Recruiting-East","Human Resources","Recruiting-South","Payroll","Recruiting-West","Human Resources-South","Recruiting-Central","200-Human Resources","Direction des Ressources Humaines","Accounts Payable","Commercial Sales","Commercial Sales-West","Services-East","Vision Australia","Vision Industries","Others"],
"type": "pie",
"textposition":"inside"
}],
"linked": {
"layout": {
"legend":{
"orientation": "h",
"x": 1.02,
"xanchor": "center",
"y": 1.0,
"yanchor": "bottom"
},
"margin":{
"l": 0
}
}
}
}
答案 0 :(得分:0)
免责声明:尚未在手机上尝试过。但是,我在浏览器上遇到了类似的问题(巨大的图例)-以下确实解决了该问题:
您可以控制图表的大小。通过增加height属性,您将为图例留出更多空间。
在“布局”对象下添加一个“高度”属性,并根据需要调整大小以适应您的数据-
"layout": {
"height": 1000, ...
如果需要,还可以添加width属性。请参见示例here(不是JSON,但是属性很清楚)。