Pyecharts Tree Chart Rotation: How to Rotate a Tree Chart
To rotate a Pyecharts tree chart, you can use the 'rotate' parameter in the 'Tree' class constructor. The 'rotate' parameter takes an angle value in degrees and rotates the tree chart by that angle.
Here's an example code snippet that shows how to rotate a Pyecharts tree chart by 90 degrees clockwise:
from pyecharts import options as opts
from pyecharts.charts import Tree
data = [
{
'name': 'Root',
'children': [
{'name': 'Node1', 'value': 10},
{'name': 'Node2', 'value': 20},
{'name': 'Node3', 'value': 30},
{'name': 'Node4', 'value': 40},
],
}
]
tree_chart = Tree()
tree_chart.add('', data, orient='TB', rotate=90)
tree_chart.set_global_opts(title_opts=opts.TitleOpts(title='Tree Chart'))
tree_chart.render('tree_chart.html')
In this example, the 'rotate' parameter is set to 90, which rotates the tree chart by 90 degrees clockwise. The 'orient' parameter is also set to 'TB' to specify the top-to-bottom orientation of the chart.
Note that the 'rotate' parameter only works with Pyecharts version 1.7.0 or higher. If you're using an older version of Pyecharts, you may need to upgrade to use this feature.
原文地址: https://www.cveoy.top/t/topic/oASu 著作权归作者所有。请勿转载和采集!