Seeking ConnectIQ API for Pen Style to draw dashed lines, other graphing related operations.

Former Member
Former Member

Hello - The spec for one of our views shows a graph with dashed lines for thresholds.  I'm doing the following to draw a solid line:

dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT);
dc.setPenWidth(2);
dc.drawLine(hiThresholdX1, hiThresholdY, hiThresholdX2, hiThresholdY);

I grepped all the samples for anything related to setting the Pen Style to dashed rather than solid with no luck.  Also, scanned the APIs but again no luck.

I can draw many short lines along the vector to create a dashed line appearance but wonder if I'm missing something that is readily available.

Any insights are most welcome.  Thanks, Matthew

  • If you want dashed lines, that is something you need to do yourself. You could use an image and just draw that image instead of a bunch of drawLines

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Appreciate the quick reply.  Good to confirm I wasn't missing something obvious.  Always wanted to do my own dashed lines.  ;}  Thanks, Matthew

  • Former Member
    Former Member over 5 years ago in reply to Former Member

    function drawDashedLine(dc, graphLeft, graphRight, thresholdY) {
        var dashLen = 8;
        var x = 0;
        for (x = 0; x < graphRight; x += dashLen*2) {
            dc.drawLine(x, thresholdY, x+dashLen, thresholdY);
        }
        // dc.drawLine(graphLeft, thresholdY, graphRight, thresholdY);
    }