fix(timeseries): allow annotations without color/isRegion/timeEnd (#101301)

pull/101310/head
Ben Sully 5 months ago committed by GitHub
parent bc00462875
commit 142a100915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      public/app/plugins/panel/timeseries/plugins/AnnotationsPlugin2.tsx

@ -142,7 +142,7 @@ export const AnnotationsPlugin2 = ({
let yKey = config.scales[1].props.scaleKey;
for (let i = 0; i < frame.length; i++) {
let color = getColorByName(vals.color[i] || DEFAULT_ANNOTATION_COLOR_HEX8);
let color = getColorByName(vals.color?.[i] || DEFAULT_ANNOTATION_COLOR_HEX8);
let x0 = u.valToPos(vals.xMin[i], xKey, true);
let x1 = u.valToPos(vals.xMax[i], xKey, true);
@ -173,12 +173,12 @@ export const AnnotationsPlugin2 = ({
ctx.setLineDash([5, 5]);
for (let i = 0; i < vals.time.length; i++) {
let color = getColorByName(vals.color[i] || DEFAULT_ANNOTATION_COLOR_HEX8);
let color = getColorByName(vals.color?.[i] || DEFAULT_ANNOTATION_COLOR_HEX8);
let x0 = u.valToPos(vals.time[i], 'x', true);
renderLine(ctx, y0, y1, x0, color);
if (vals.isRegion[i]) {
if (vals.isRegion?.[i]) {
let x1 = u.valToPos(vals.timeEnd[i], 'x', true);
renderLine(ctx, y0, y1, x1, color);
@ -216,14 +216,14 @@ export const AnnotationsPlugin2 = ({
let markers: React.ReactNode[] = [];
for (let i = 0; i < vals.time.length; i++) {
let color = getColorByName(vals.color[i] || DEFAULT_ANNOTATION_COLOR);
let color = getColorByName(vals.color?.[i] || DEFAULT_ANNOTATION_COLOR);
let left = Math.round(plot.valToPos(vals.time[i], 'x')) || 0; // handles -0
let style: React.CSSProperties | null = null;
let className = '';
let isVisible = true;
if (vals.isRegion[i]) {
let right = Math.round(plot.valToPos(vals.timeEnd[i], 'x')) || 0; // handles -0
if (vals.isRegion?.[i]) {
let right = Math.round(plot.valToPos(vals.timeEnd?.[i], 'x')) || 0; // handles -0
isVisible = left < plot.rect.width && right > 0;

Loading…
Cancel
Save