From 56459300e2fdff26ad360ce75034be5dd8702f4e Mon Sep 17 00:00:00 2001 From: Frank Sauerburger <frank@sauerburger.com> Date: Thu, 14 Jan 2021 12:40:32 +0100 Subject: [PATCH] Add Graph to legend --- uhepp-js/src/components/UheppHist.jsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/uhepp-js/src/components/UheppHist.jsx b/uhepp-js/src/components/UheppHist.jsx index b81825b..ca5a823 100644 --- a/uhepp-js/src/components/UheppHist.jsx +++ b/uhepp-js/src/components/UheppHist.jsx @@ -469,12 +469,6 @@ const tex_html = mathjax.document('', { } }); -const length_metrix = (str) => { - var short_count = (str.match(/[,.tli1: ]/g) || []).length; - var long_count = (str.match(/[MWXZ]/g) || []).length; - return str.length + 0.2 * long_count - 0.5 * short_count -} - const EmbeddedMathJax = ({src, posX, posY, align="left"}) => { let html = tex_html; let node = document.createElement("div"); @@ -528,6 +522,22 @@ const Legend = ({ const mathSkip = 120; let i = 0 let legend = [] + post_uhepp.graphs.map((graph, graph_i) => { + + legend.push(<> + <line x1={0} x2={20} + y1={(i + 1) * lineSkip - 5} + y2={(i + 1) * lineSkip - 5} + strokeWidth="2" + stroke={graph.style.color || "#000"} + key={`legend-${i}`} + /> + <MixedText x={30} y={(i + 1) * lineSkip} + key={`legend-label-${i}`}>{graph.label}</MixedText> + </>) + + i++ + }) post_uhepp.stacks.map((stack, stack_index) => { stack.content.map((stack_item, si_i) => { if (stack.type == "points") { -- GitLab