javascript – Logarithmic Plot for a Graph (PHP or JS)-ThrowExceptions

Exception or error:

I have tried with things like canvasJS, Jpgraph, Google Graph, etc but I can’t seem to make it look similar to this, in the sense of it being Vertical.

Google Chart Attempt:

google.charts.load('current', {packages: ['corechart', 'line']});
google.charts.setOnLoadCallback(drawBasic);

function drawBasic() {

  var data = new google.visualization.DataTable();


  data = google.visualization.arrayToDataTable([
      ['X', 'Item1', 'Item2'],

           ['0',  0,      0],
           ['100',  749.8942093,       749.8942093],
           ['1000',  865.9643234,   865.9643234]
  ]);

  var options = {
  orientation: 'vertical',
    hAxis: {
      title: 'Time'
    },

    vAxis: {
      title: 'Popularity'
    }

  };

  var chart = new 
google.visualization.LineChart(document.getElementById('chart_div'));

  chart.draw(data, options);
}

Does anyone have experience making something like this?

logchart

How to solve:

This resolved the issue as adding the type to both the y and x-axis and including a range for both as well.

  var layout = {
  width: 700,
  height: 700,
xaxis: {
  type: 'log',
  range: [3,5]  // Log Range.  10^n
},
yaxis: {
  type: 'log',
  range: [-2,3]  // Log Range.  10^n
}
};

Leave a Reply

Your email address will not be published. Required fields are marked *