|
|
@ -125,38 +125,70 @@ export const AnnotationsPlugin2 = ({ |
|
|
|
|
|
|
|
|
|
|
|
const ctx = u.ctx; |
|
|
|
const ctx = u.ctx; |
|
|
|
|
|
|
|
|
|
|
|
let y0 = u.bbox.top; |
|
|
|
|
|
|
|
let y1 = y0 + u.bbox.height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.save(); |
|
|
|
ctx.save(); |
|
|
|
|
|
|
|
|
|
|
|
ctx.beginPath(); |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.rect(u.bbox.left, u.bbox.top, u.bbox.width, u.bbox.height); |
|
|
|
ctx.rect(u.bbox.left, u.bbox.top, u.bbox.width, u.bbox.height); |
|
|
|
ctx.clip(); |
|
|
|
ctx.clip(); |
|
|
|
|
|
|
|
|
|
|
|
ctx.lineWidth = 2; |
|
|
|
|
|
|
|
ctx.setLineDash([5, 5]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
annos.forEach((frame) => { |
|
|
|
annos.forEach((frame) => { |
|
|
|
let vals = getVals(frame); |
|
|
|
let vals = getVals(frame); |
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < vals.time.length; i++) { |
|
|
|
if (frame.name === 'xymark') { |
|
|
|
let color = getColorByName(vals.color?.[i] || DEFAULT_ANNOTATION_COLOR_HEX8); |
|
|
|
// xMin, xMax, yMin, yMax, color, lineWidth, lineStyle, fillOpacity, text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let xKey = config.scales[0].props.scaleKey; |
|
|
|
|
|
|
|
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 x0 = u.valToPos(vals.xMin[i], xKey, true); |
|
|
|
|
|
|
|
let x1 = u.valToPos(vals.xMax[i], xKey, true); |
|
|
|
|
|
|
|
let y0 = u.valToPos(vals.yMax[i], yKey, true); |
|
|
|
|
|
|
|
let y1 = u.valToPos(vals.yMin[i], yKey, true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.fillStyle = colorManipulator.alpha(color, vals.fillOpacity[i]); |
|
|
|
|
|
|
|
ctx.fillRect(x0, y0, x1 - x0, y1 - y0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.lineWidth = Math.round(vals.lineWidth[i] * uPlot.pxRatio); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (vals.lineStyle[i] === 'dash') { |
|
|
|
|
|
|
|
// maybe extract this to vals.lineDash[i] in future?
|
|
|
|
|
|
|
|
ctx.setLineDash([5, 5]); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// solid
|
|
|
|
|
|
|
|
ctx.setLineDash([]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.strokeStyle = color; |
|
|
|
|
|
|
|
ctx.strokeRect(x0, y0, x1 - x0, y1 - y0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
let y0 = u.bbox.top; |
|
|
|
|
|
|
|
let y1 = y0 + u.bbox.height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.lineWidth = 2; |
|
|
|
|
|
|
|
ctx.setLineDash([5, 5]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < vals.time.length; i++) { |
|
|
|
|
|
|
|
let color = getColorByName(vals.color?.[i] || DEFAULT_ANNOTATION_COLOR_HEX8); |
|
|
|
|
|
|
|
|
|
|
|
let x0 = u.valToPos(vals.time[i], 'x', true); |
|
|
|
let x0 = u.valToPos(vals.time[i], 'x', true); |
|
|
|
|
|
|
|
|
|
|
|
if (!vals.isRegion?.[i]) { |
|
|
|
if (!vals.isRegion?.[i]) { |
|
|
|
renderLine(ctx, y0, y1, x0, color); |
|
|
|
renderLine(ctx, y0, y1, x0, color); |
|
|
|
// renderUpTriangle(ctx, x0, y1, 8 * uPlot.pxRatio, 5 * uPlot.pxRatio, color);
|
|
|
|
// renderUpTriangle(ctx, x0, y1, 8 * uPlot.pxRatio, 5 * uPlot.pxRatio, color);
|
|
|
|
} else if (canvasRegionRendering) { |
|
|
|
} else if (canvasRegionRendering) { |
|
|
|
renderLine(ctx, y0, y1, x0, color); |
|
|
|
renderLine(ctx, y0, y1, x0, color); |
|
|
|
|
|
|
|
|
|
|
|
let x1 = u.valToPos(vals.timeEnd[i], 'x', true); |
|
|
|
let x1 = u.valToPos(vals.timeEnd[i], 'x', true); |
|
|
|
|
|
|
|
|
|
|
|
renderLine(ctx, y0, y1, x1, color); |
|
|
|
renderLine(ctx, y0, y1, x1, color); |
|
|
|
|
|
|
|
|
|
|
|
ctx.fillStyle = colorManipulator.alpha(color, 0.1); |
|
|
|
ctx.fillStyle = colorManipulator.alpha(color, 0.1); |
|
|
|
ctx.fillRect(x0, y0, x1 - x0, u.bbox.height); |
|
|
|
ctx.fillRect(x0, y0, x1 - x0, u.bbox.height); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|