Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
Format Plotly Annotation properly

I am showing annotations by clicking on a plotly chart. Now I would like to align the lines to look better. The indentations should be the same for every line. It comes clear with the picture: enter image description here

 myPlot.on('plotly_click',
        function (data) {
            var point = data.points[0],
                newAnnotation = {
                    x: point.x,
                    y: point.y,
                    arrowhead: 7,
                    ax: 0,
                    ay: 80,
                    bgcolor: 'rgba(255, 255, 255, 0.85)',
                    arrowcolor: point.fullData.marker.color,
                    font: { size: 12 },
                    bordercolor: point.fullData.marker.color,
                    borderwidth: 2,
                    text:
                        ' | <b>Messung: </b> ' + vitSigTitle + '  |<br>' + '---- <br>'+
                        '<b>Zeitpunkt </b><br>' +
                        (new Date(point.x)).toLocaleString('default')+  '<br>'+
                        '<i>Jahr: </i>                  '   + (new Date(point.x)).getFullYear() + '<br>' +
                        '<i>Monat: </i>                '  + (new Date(point.x)).toLocaleString('default', { month: 'long' }) + '<br>' +
                        '<i>Tag: </i>               '  + (new Date(point.x)).toLocaleDateString('default', { weekday: 'long' }) + '<br>' +
                        '<i>Uhrzeit: </i>         '+ (new Date(point.x)).toLocaleTimeString() + '<br>' +
                        '<b>Messwert</b><br>' + (point.y) + vitSigUnit
                },
                newIndex = (node.children[0].layout.annotations || []).length;
            // delete instead if clicked twice
            if (newIndex) {
                var foundCopy = false;
                node.children[0].layout.annotations.forEach(function (ann, sameIndex) {
                    if (ann.text === newAnnotation.text) {
                        Plotly.relayout(node.children[0], 'annotations[' + sameIndex + ']', 'remove');
                        foundCopy = true;
                    }
                });
                if (foundCopy) return;
            }

As you see, "Tag" is completely offset.

Here is my code:

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!