Power trendline

43 views
Skip to first unread message

jlarroy ita

unread,
Mar 17, 2017, 9:55:39 AM3/17/17
to Google Chart API
Hello.

I need to create a ScatterChart with axis X and Y in logarithmic scale and with a power trendline but, as far as I know, Google Charts only supports three types of trendlines (linear, polynomial, and exponential) but not power trendlines. Is there any way to add power trendlines?

I copy a sample of my source code at the end of this message. Attached you can find an image with the result (made with Excel) which I'm looking for.

Thanks a lot.

      J.Larroy

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['serie1', 'serie2'],
[0.02891, 750.0],
[0.01292, 750.0],
[0.01385, 750.0],
[0.01487, 750.0],
[1.60000, 1.48161],
[1.70000, 1.90133],
[2.30000, 0.95124],
[27.70000, 0.11861],
[50.00000, 0.06090],
[178.50000, 0.01314],
[11.10000, 0.24285]
        ]);

        var options = {
          hAxis: {scaleType:'log'},
          vAxis: {scaleType:'log'},
          chartArea: {width:'50%'},
          trendlines: {
            0: {
              type: 'linear',
              showR2: true,
              visibleInLegend: true
            }
          }
        };

        var chartLinear = new google.visualization.ScatterChart(document.getElementById('chartLinear'));
        chartLinear.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chartLinear" style="height: 350px; width: 800px"></div>
  </body>
</html>
powerTrendline.JPG

Maria Christine Joy Salamat

unread,
Nov 26, 2019, 9:02:15 PM11/26/19
to Google Chart API
hi can i ask how to get all point generate in my polynomila graph using javacsript
Reply all
Reply to author
Forward
0 new messages