Home Forums Chart Support dynamic Year-Month on Axis value-bar chart

dynamic Year-Month on Axis value-bar chart

Viewing 3 posts - 1 through 3 (of 3 total)
  • #39456

    I want to display dynamic x-Axis value..
    for example 2022-Mar , 2022-April,

    axisY: {
    title: “Patient Treatment Duration”,
    //intervalType: “month”,
    labelFormatter: function (e)
    {
    //return CanvasJS.formatDate( e.value, “MMM-YYYY”);
    var abc = [‘2022-aug’,’2022-sep’];
    for (var i = 0; i < abc.length; i++){
    return CanvasJS.formatDate(new Date(abc[i]), “YYYY-MMM”);
    }
    },
    includeZero: true,
    },

    • This topic was modified 2 years ago by rajuweb.
    #39459

    var chart = new CanvasJS.Chart(“chartContainer”, {
    title:{
    text: “Basic Column Chart”
    },
    axisY: {
    title: “Patient Treatment Duration”,
    //intervalType: “month”,
    labelFormatter: function (e)
    {
    return CanvasJS.formatDate( e.value, “MMM-YYYY”);
    },
    includeZero: true,
    },
    data: [{
    type: “bar”,
    indexLabel: “{y}”,
    indexLabelPlacement: “inside”,
    indexLabelFontWeight: “bolder”,
    indexLabelFontColor: “white”,
    dataPoints: [
    {label:”A”,y: 71 },
    {label:”b”,y: 55},
    {label:”c”,y: 50 },
    {label:”d”,y: 65 },
    {label:”e”,y: 95 }
    ]
    }]
    });

    chart.render();

    #39466

    @rajuweb,

    You can pass x-value in date-time format and use valueFormatString to define how axis labels must be formatted before they appear on the x-axis.


    Thangaraj Raman
    Team CanvasJS

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

You must be logged in to reply to this topic.