【问题标题】:Need Google Apps Script Plotting Data on Google Sheets with Lines and Data Markers需要 Google Apps 脚本在带有线条和数据标记的 Google 表格上绘制数据
【发布时间】:2021-02-18 01:16:40
【问题描述】:

我想用如图所示的数据绘制图表:

左边的日期将是 x 轴,每一列将是它自己的系列,如图所示:

这是通过简单地突出显示单元格并制作散点图来完成的。

我喜欢它就像一个折线图,其中每个系列都连接在一起,并且系列的各种范围(这样第三个数据列就不会倾斜范围)。例如,左侧的范围为 0 到 50,但右侧(黄色)系列的右侧范围为 0 到 160。

这是我尝试过的:

function createEmbeddedLineChart(sheetPlot, intStartRow, intStartCol, intEndRow) {
  var chartDataRange = sheetPlot.getRange(intStartRow,intStartCol,intEndRow-intStartRow+1,4);

  var hAxisOptions = {
    slantedText: true,
    slantedTextAngle: 60,
    gridlines: {
      count: 12
    }
  };
  
  var lineChartBuilder = sheetPlot.Chart().newScatterChart();
  var chart = lineChartBuilder
    .addRange(chartDataRange)
    .setPosition(5, 8, 0, 0)
    .setTitle('Da Big Plot')
    .setNumHeaders(1)
    .setLegendPosition(Charts.Position.RIGHT)
    .setOption('hAxis', hAxisOptions)
    .setOption("useFirstColumnAsDomain", true)
    .build();
 
  sheetPlot.insertChart(chart);  
}

我的问题是它不会连接线,除非数据列是连续的。

提前感谢您对此提供的任何指导。我在这里的谷歌文档中找不到它太容易了:https://developers.google.com/apps-script/reference/charts/charts

编辑时间:太平洋标准时间 2021 年 2 月 17 日下午 22:29 这是我想要的一个例子。 另请注意,日期列也有小时、分钟和秒。但它们只是隐藏的;因此,为什么他们不在约会上。 我想要:

*两个(或更多)垂直轴刻度。

*每个数据点的点 *连接点的线

【问题讨论】:

  • 很遗憾,我无法理解Id like it to be like a line chart where each of the series are connected and various ranges for the series (so that the 3rd data column is not skewing the range). For example I would have a range of 0 to 50 on the left, but the right (yellow) series would have its own rang eon the right from 0 to 160.。我为此道歉。您能否提供您期望的示例输出图表作为图像?
  • 您好 Tanaike,我在帖子末尾添加了我想要的图片。我希望这有助于描述我想要什么。
  • 感谢您回复并添加更多信息。

标签: google-apps-script plot missing-data linechart


【解决方案1】:

无法使用您的标准创建折线图。您可以随时 create an Issue Tracker feature request 扩展 Charts 以包含您想要的结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    相关资源
    最近更新 更多