MCPcopy
hub / github.com/PyQt5/PyQt / __init__

Method __init__

QtChart/HorizontalBarChart.py:33–60  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

31class Window(QChartView):
32
33 def __init__(self, *args, **kwargs):
34 super(Window, self).__init__(*args, **kwargs)
35 self.resize(400, 300)
36 # 抗锯齿
37 self.setRenderHint(QPainter.Antialiasing)
38
39 # 图表
40 chart = QChart()
41 self.setChart(chart)
42 # 设置标题
43 chart.setTitle('Simple horizontal barchart example')
44 # 开启动画效果
45 chart.setAnimationOptions(QChart.SeriesAnimations)
46 # 添加Series
47 series = self.getSeries()
48 chart.addSeries(series)
49 # 分类
50 categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
51 # 分类x轴
52 axis = QBarCategoryAxis()
53 axis.append(categories)
54 # 创建默认轴线
55 chart.createDefaultAxes()
56 # 替换默认y轴
57 chart.setAxisY(axis, series)
58 # 显示图例
59 chart.legend().setVisible(True)
60 chart.legend().setAlignment(Qt.AlignBottom)
61
62 def getSeries(self):
63 # 创建5个柱子

Callers

nothing calls this directly

Calls 3

resizeMethod · 0.95
getSeriesMethod · 0.95
setTitleMethod · 0.45

Tested by

no test coverage detected