Home Forums Chart Support Bar Chart – label for each bar not visible

Bar Chart – label for each bar not visible

Viewing 2 posts - 1 through 2 (of 2 total)
  • #44676

    I am trying to add label in bar chart, but it is showing label (on y-axis) only alternate bar. We want it to be visible for each bar. Please suggest.

    Code – https://jsfiddle.net/8tdwgb1L/

    
      window.onload = function () {
        var chart = new CanvasJS.Chart("chartContainer",
        {
          title:{
            text: "Understanding Legend"
          },
    
          legend: {
           horizontalAlign: "left", // "center" , "right"
           verticalAlign: "center",  // "top" , "bottom"
           fontSize: 15
         },
         data: [
         {
          type: "bar",
          showInLegend: true,
          legendText: "Numbers",
          dataPoints: [
          {label: "Jon", y: 230 },
          {label: "Jon1", y: 230 },
          {label: "Jose", y: 245},
          {label: "Jose1", y: 245},
          {label: "Joey", y: 345},
          {label: "Joey1", y: 345},
          {label: "Trin", y: 367 },
          {label: "Trin1", y: 367 },
          {label: "Mike", y: 453 },
          {label: "Mike1", y: 453 },
          {label: "Hulk", y: 256 },
          {label: "Hulk1", y: 256 },
          {label: "Dan", y: 478},
          {label: "Dan1", y: 478},
          {label: "Nate", y: 543 },      
          {label: "Nate1", y: 543 },      
          {label: "Jen", y: 456 },
          {label: "Jen1", y: 456 }
          ]
        }
        ]
      });
    
        chart.render();
      }
      
    #44679

    @kpandey017,

    Labels are displayed at regular intervals on the axis. Additionally, to enhance readability and prevent overlapping, the chart omits alternate labels, in some cases. However, if you prefer to display all labels, you can achieve this by setting the interval to 1.

    axisX: {
      interval: 1
    }

    Please take a look at this updated JSFiddle for the working code.

    Showing all Axis Labels - Interval


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.