Set different axes type - Javascript Chart.js

Javascript examples for Chart.js:Axis

Description

Set different axes type

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Chart JS (Mixed Example)</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*w ww.j  a v a2s . com*/
var ctx = new Chart(document.getElementById("line-chart"), {
    type: 'line',
    data: {
        datasets: [{
            data: [{'y': 418872.7, 'x': 18.1},
                   {'y': 262233.1, 'x': 46.8}, 
                   {'y': 180687.1, 'x': 75.5}, 
                   {'y': 133676.3, 'x': 104.3}],
            label: "Model",
            borderColor: "#3e95cd",
            fill: false
        }, {
            label : 'Data',
            fill:false,
            showLine: false,
            backgroundColor: "#FF0000",
            data : [{x: 17.0, y: 454995.091169},
            {x: 18.0, y: 457656.874749},
            {x: 19.0, y: 444574.49162},
            {x: 20.0, y: 432511.514968},
            {x: 21.0, y: 421184.776328}],
                  type: 'line'
        }]
    },
    options: {
        title:{
            display: true,
            text:"Test"
        },
        scales: {
            xAxes: [{
                type: 'logarithmic',
                position: 'bottom'
            }],
            yAxes: [{
                type: 'logarithmic'
            }]
        }
    }
})
    }

      </script> 
   </head> 
   <body> 
      <canvas id="line-chart" width="400" height="400"></canvas>  
   </body>
</html>

Related Tutorials