| 56 | # print(point, state) |
| 57 | |
| 58 | def mouseMoveEvent(self, event): |
| 59 | super(ChartView, self).mouseMoveEvent(event) |
| 60 | # 获取x和y轴的最小最大值 |
| 61 | axisX, axisY = self._chart.axisX(), self._chart.axisY() |
| 62 | min_x, max_x = axisX.min(), axisX.max() |
| 63 | min_y, max_y = axisY.min(), axisY.max() |
| 64 | # 把鼠标位置所在点转换为对应的xy值 |
| 65 | x = self._chart.mapToValue(event.pos()).x() |
| 66 | y = self._chart.mapToValue(event.pos()).y() |
| 67 | index = round(x) # 四舍五入 |
| 68 | print(x, y, index) |
| 69 | # 得到在坐标系中的所有series的类型和点 |
| 70 | points = [(s.type(), s.at(index)) |
| 71 | for s in self._chart.series() if min_x <= x <= max_x and min_y <= y <= max_y] |
| 72 | print(points) |
| 73 | |
| 74 | def __getColor(self, color=None, default=Qt.white): |
| 75 | ''' |