How do I hide the x-axis label/text that is displayed in chart.js ?
Setting scaleShowLabels:false
only removes the y-axis labels.
<script> var options = { scaleFontColor: "#fa0", datasetStrokeWidth: 1, scaleShowLabels : false, animation : false, bezierCurve : true, scaleStartValue: 0, }; var lineChartData = { labels : ["1","2","3","4","5","6","7"], datasets : [ { fillColor : "rgba(151,187,205,0.5)", strokeColor : "rgba(151,187,205,1)", pointColor : "rgba(151,187,205,1)", pointStrokeColor : "#fff", data : [1,3,0,0,6,2,10] } ] } var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(lineChartData,options); </script>
To hide or remove X-axis labels, use set(xlabel=None). To display the figure, use show() method.
Procedure. Select the axis chart object. To show or hide the axis labels, in the Properties pane, select or clear the Axis label check box.
Right-click the category labels you want to change, and click Select Data. In the Horizontal (Category) Axis Labels box, click Edit. In the Axis label range box, enter the labels you want to use, separated by commas.
To remove an axis title, on the Layout tab, in the Labels group, click Axis Title, click the type of axis title that you want to remove, and then click None. To quickly remove a chart or axis title, click the title, and then press DELETE. You can also right-click the chart or axis title, and then click Delete.
var chart = new Chart(ctx, { ... options:{ scales:{ xAxes: [{ display: false //this will remove all the x-axis grid lines }] } } }); var chart = new Chart(ctx, { ... options: { scales: { xAxes: [{ ticks: { display: false //this will remove only the label } }] } } });
Reference: chart.js documentation
Old answer (written when the current version was 1.0 beta) just for reference below:
To avoid displaying labels in chart.js
you have to set scaleShowLabels : false
and also avoid to pass the labels
:
<script> var options = { ... scaleShowLabels : false }; var lineChartData = { //COMMENT THIS LINE TO AVOID DISPLAYING THE LABELS //labels : ["1","2","3","4","5","6","7"], ... } ... </script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With