简体   繁体   中英

Plotly API using Google Apps Script

I was wondering how to go about making a basic single dataset Plotly REST call using google apps scripts. Could someone please provide just a basic function that does this? It would greatly help me, and will try and help those in the future who help me. I think I'm getting hung up on adding the dataset. This what I have so far:

Let dataSet be a (nx2) array in the form [[date0, r0], [date1, r1], ..., [daten, rn]] st date0 > daten and ri in the reals.

function plot(dataSet){

  var key = "XXXXXXXXXX";
  var url = "https://plot.ly/clientresp";
  var un = "un=XXXXXXX";
  var origin = "origin=plot";
  var platform = "platform=lisp";

  ...

  return plotlyUrlImage;

}

Use UrlFetchApp.fetch and specify it to be a post request.

function plot(dataSet){
  var key = "XXXXXXXXXX";
  var url = "https://plot.ly/clientresp";
  var un = "XXXXXX";
  var origin = "plot";
  var platform = "lisp";

  var payload = {
    "un": un,
    "key": key,
    "origin": origin,
    "platform": platform,
    "args": JSON.stringify(args),
    "kwargs": JSON.stringify(kwargs)
  };

  var options = {
    "method": "post",
    "payload": payload
  };

  var response = UrlFetchApp.fetch(url, options);
  var rs = JSON.parse(response.getContentText());

  return rs["url"];
}

Reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM