Home Forums Chart Support Set XAxis Value to start at 0

Set XAxis Value to start at 0

Viewing 8 posts - 1 through 8 (of 8 total)
  • #11292

    Hey All,

    I was wondering if there is a way to set the XAxis and Y Axis to start at 0. Currently they both start at whatever there lowest value is in the dataPoints be that 0, 0.2, 0.5.

    Thanks for the help!
    -Extrabeefy

    #11295

    Extrabeefy,

    To start both axis at 0 you can set axisX minimum and axisY minimum to 0 as shown in the code snippet below –

    axisX: {
       minimum: 0
     },
     axisY: {
       minimum: 0
     },

    Also, kindly take a look at this JSFiddle for a complete working code.

    setting minimum value for both axis

    #11315

    Ah ok thank you from the example I figured it meant if I didn’t have a value of 0 then it would show 0.2. Thank you!

    • This reply was modified 8 years, 6 months ago by Extrabeefy.
    #16097

    Hi,

    I have a problem. I need to show a line chart which will always start from the yaxis line edge. That means, i cannot set x: 0, because that will move the data point a little right from the y axis line. A sample is shown in the image. Is there any way i can do this?null

    • This reply was modified 7 years, 2 months ago by vishnumohan89.
    #16098

    Line Chart Start From Y Axis Edge

    #16102

    @vishnumohan89,

    To design a line chart that always starts from y-axis line you can set the minimum of axisX to the x-value of the first dataPoint. Please check the below code snippet –

    function setAxisXMinimum(){
       chart.axisX[0].set("minimum", chart.options.data[0].dataPoints[0].x);
    }

    Also, kindly take a look at this JSFiddle for complete working code.

    setting minimum of x-axis

    ___________
    Indranil Deo
    Team CanvasJS

    #39310

    What if I want the bar chart to start from -140 and only rise to the indicated value?

    #39311

    Nevermind. Used a range chart and it works fine.

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

You must be logged in to reply to this topic.