简体   繁体   English

使用Google Apps脚本的Plotly API

[英]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. 我想知道如何使用Google Apps脚本进行基本的单个数据集Plotly REST调用。 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. 令dataSet为(nx2)数组,其形式为[[date0,r0],[date1,r1],...,[daten,rn]] st date0> daten和ri。

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. 使用UrlFetchApp.fetch并将其指定为post请求。

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: 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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