Search code examples
javascriptamchartsamcharts4

How to hide labels from categoryaxis Y


https://www.amcharts.com/demos/clustered-bar-chart/ Im using that chart to represent my values from the database, and at the moment i want to hide the labels name from the axisY, how can i do it?

var categoryAxis = chart3.yAxes.push(new am4charts.CategoryAxis());
        categoryAxis.dataFields.category = "Consultant_Name";
        categoryAxis.numberFormatter.numberFormat = "#";
        categoryAxis.renderer.inversed = true;
        categoryAxis.renderer.grid.template.location = 0;
        categoryAxis.renderer.cellStartLocation = 0.1;
        categoryAxis.renderer.cellEndLocation = 0.9;



        var valueAxis = chart3.xAxes.push(new am4charts.ValueAxis());
        valueAxis.renderer.opposite = true;

        // Create series
        function createSeries(field, name) {
            var series = chart3.series.push(new am4charts.ColumnSeries());
            series.dataFields.valueX = field;
            series.dataFields.categoryY = "Consultant_Name";
            series.name = name;
            series.columns.template.tooltipText = "Pace: [bold]{valueX}[/]";
            series.columns.template.height = am4core.percent(100);
            series.sequencedInterpolation = true;
            //series.hidden = true;

Solution

  • You can set categoryAxis.renderer.labels.template.visible to false to hide the labels:

    categoryAxis.renderer.labels.template.visible = false;
    

    Here is a code pen showing the result.