x-axis setting for line chart - Javascript Chart.js

Javascript examples for Chart.js:Line Chart

Description

x-axis setting for line chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> 
      <script type="text/javascript" src="https://raw.githack.com/leighquince/Chart.js/master/Chart.js"></script> 
   </head> 
   <body> 
      <canvas id="chart" width="1200px"></canvas> 
      <script type="text/javascript">
var ctx = document.getElementById("chart").getContext("2d");
var data = {//from  w w  w. ja v  a  2s .  c  om
    labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
    datasets: [{
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.5)",
        strokeColor: "rgba(220,220,220,0.8)",
        highlightFill: "rgba(220,220,220,0.75)",
        highlightStroke: "rgba(220,220,220,1)",
        data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
    }]
};
var myLineChart = new Chart(ctx).Line(data, {
    //return true from the function to filter out the label
    labelsFilter: function (value, index, labels) {
        return (index + 1) % 5 !== 0;
    }
});

      </script>  
   </body>
</html>

Related Tutorials