示例#1
0
    def _draw_powerline_arrow(self, pos_or_x, pos_or_y, pos_ex_x, pos_ex_y,
                              watts_value, line_name, line_color):
        cx, cy = pltu.middle_from_points(pos_or_x, pos_or_y, pos_ex_x,
                                         pos_ex_y)
        dx, dy = pltu.norm_from_points(pos_or_x, pos_or_y, pos_ex_x, pos_ex_y)
        sym = self._plotly_tri_from_line_dir_and_sign(dx, dy, watts_value)
        marker_dict = dict(size=self._line_arrow_radius,
                           color=line_color,
                           showscale=False,
                           symbol=sym)

        sub_offx = dx * self._sub_radius
        sub_offy = dy * self._sub_radius
        or_offx = dx * self._line_arrow_len
        or_offy = dy * self._line_arrow_len
        arrx_or = pos_or_x + sub_offx + or_offx
        arrx_ex = pos_or_x + sub_offx
        arry_or = pos_or_y + sub_offy + or_offy
        arry_ex = pos_or_y + sub_offy
        trace_name = self._line_prefix + self._arrow_prefix + line_name
        return go.Scatter(x=[arrx_or, arrx_ex],
                          y=[arry_or, arry_ex],
                          hoverinfo='skip',
                          showlegend=False,
                          marker=marker_dict,
                          name=trace_name)
示例#2
0
 def _draw_powerline_txt(self, pos_or_x, pos_or_y, pos_ex_x, pos_ex_y,
                         text):
     pos_x, pos_y = pltu.middle_from_points(pos_or_x, pos_or_y, pos_ex_x,
                                            pos_ex_y)
     off_x, off_y = pltu.orth_norm_from_points(pos_or_x, pos_or_y, pos_ex_x,
                                               pos_ex_y)
     txt_x = pos_x + off_x * (self._load_radius / 2)
     txt_y = pos_y + off_y * (self._load_radius / 2)
     ha = self._h_textpos_from_dir(off_x, off_y)
     va = self._v_textpos_from_dir(off_x, off_y)
     self.ax.text(txt_x,
                  txt_y,
                  text,
                  color=self._gen_txt_color,
                  fontsize='small',
                  horizontalalignment=ha,
                  verticalalignment=va)