vnpy学习笔记:Chart绘图功能相关
Widget对象在鼠标移动时更新相关信息
Widget类的update_info方法在Cursor对象发生moved事件时被调用。第一天个for循环遍历_item_plot_map字典,这个字典是widget类的属性,为plot name和其对应的plot对象的映射。
get_info_text为具体plot对象的方法。比如CandleItem的get_info_text方法。入参为_x,即通过Cursor对象moved方法下得到的鼠标当前x坐标值。
def update_info(self) -> None:
""""""
buf = {
}
for item, plot in self._item_plot_map.items():
item_info_text = item.get_info_text(self._x)
if plot not in buf:
buf[plot] = item_info_text
else:
if item_info_text:
buf[plot] += (