MCPcopy Index your code
hub / github.com/bqplot/bqplot / get_legend_coords

Method get_legend_coords

js/src/Figure.ts:1110–1162  ·  view source on GitHub ↗
(
    legend_location:
      | 'top'
      | 'top-right'
      | 'right'
      | 'bottom-right'
      | 'bottom'
      | 'bottom-left'
      | 'left',
    width: number,
    height: number,
    disp: number
  )

Source from the content-addressed store, hash-verified

1108 }
1109
1110 get_legend_coords(
1111 legend_location:
1112 | 'top'
1113 | 'top-right'
1114 | 'right'
1115 | 'bottom-right'
1116 | 'bottom'
1117 | 'bottom-left'
1118 | 'left',
1119 width: number,
1120 height: number,
1121 disp: number
1122 ) {
1123 let x_start = 0;
1124 let y_start = 0;
1125 const fig_width = this.plotareaWidth;
1126 const fig_height = this.plotareaHeight;
1127
1128 switch (legend_location) {
1129 case 'top':
1130 x_start = fig_width * 0.5 - width;
1131 y_start = 0;
1132 break;
1133 case 'top-right':
1134 x_start = fig_width - disp;
1135 y_start = 0;
1136 break;
1137 case 'right':
1138 x_start = fig_width - disp;
1139 y_start = fig_height * 0.5 - height;
1140 break;
1141 case 'bottom-right':
1142 x_start = fig_width - disp;
1143 y_start = fig_height - height;
1144 break;
1145 case 'bottom':
1146 x_start = fig_width * 0.5 - width;
1147 y_start = fig_height - height;
1148 break;
1149 case 'bottom-left':
1150 x_start = 0;
1151 y_start = fig_height - height;
1152 break;
1153 case 'left':
1154 x_start = 0;
1155 y_start = fig_height * 0.5 - height;
1156 break;
1157 default:
1158 x_start = 0;
1159 y_start = 0;
1160 }
1161 return [x_start, y_start];
1162 }
1163
1164 async set_interaction(model: WidgetModel | null): Promise<WidgetView> {
1165 if (model) {

Callers 1

update_legendMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected