Home Forums Chart Support Drawing horizontal lines

Drawing horizontal lines

Viewing 5 posts - 1 through 5 (of 5 total)
  • #59873

    Hi Guys,

    I’ve used striplines to draw vertical lines but I would like to draw horizontal lines where I set the start and end of those lines, so that between each two vertical lines one horizontal line, I thought of using striplines as well but my understanding that with striplines you can’t set where the lines start and end?

    Thanks

    #59875

    @rbadis,

    Striplines are drawn either from top to bottom, or from left to right extremes. However, you can use a line chart to achieve your requirement. Please take a look at this JSFiddle for an example of the same.

    Chart with stripline and connecting line


    Ananya Deka
    Team CanvasJS

    #59898

    Thanks Ananya, do know know how can I do it programatically rather then in design?
    I tried something like this but didn’t work:
    chart.options.data[0].type: “line”;
    chart.options.data[0].dataPoints.push({x: 500, y: 0.005});
    chart.options.data[0].dataPoints.push({x: 800, y: 0.005});

    #59900

    @rbadis,

    chart.addTo() method is used to add the line dataseries programmatically, as shown in the example. The code you are trying does not work because the series needs to be created before “type” or “datapoints” can be assigned.

    If you are looking to change the y-values such that the line is centered vertically, you can use the y-axis range to calculate the midpoint. In case you are still having issues, please create a JSFiddle and share with us, so that we can understand your scenario better and help you out.


    Ananya Deka
    Team CanvasJS

    #59902

    Thanks Ananya for your help

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.