English 中文(简体)
无法在使用APICAP的谷歌图表中添加3系列的线图
原标题:Unable to add a line chart with 3 series into a Google sheet using API

我有一个项目,对ESP32(Arduino IDE ketch)的某些参数进行监测,而且我可以将结果变成一个表格。 每一天都会制作新的表格,以节省日期。 在新版面制作后,我想在表格中插入一个有3系列的线图,使用<代码>addChart。 有一个系列是ok的,但是,如果我界定的3个系列,我会发现下一个错误,那么,三个参数就会更清晰地演变。

"error": {
        "code": 400,
        "message": "Invalid requests[0].addChart: If specifying more than one sourceRange within a domain or series, each sourceRange across the domain & series must be in order and contiguous.",
        "status": "INVALID_ARGUMENT"

我所尝试的简明扼要:

domain sources: A1:A1000 (time of event) on axis x
series1 sources: B1:B1000 (values of parameter A)
series2 sources: C1:C1000 (values of parameter B)
series2 sources: D1:D1000 (values of parameter C)

Using 结果是:

{
  "requests": [
{
    "addChart": {
        "chart": {
            "spec": {
                "basicChart": {
                    "chartType": "LINE",
                    "domains": {
                        "domain": {
                            "sourceRange": {
                                "sources": [
                                    {
                                        "startRowIndex": 1,
                                        "endRowIndex": 1000,
                                        "startColumnIndex": 0,
                                        "endColumnIndex": 1,
                                        "sheetId": 1439439696
                                    },
                  {
                                        "startRowIndex": 1,
                                        "endRowIndex": 1000,
                                        "startColumnIndex": 0,
                                        "endColumnIndex": 1,
                                        "sheetId": 1439439696
                                    },
                  {
                                        "startRowIndex": 1,
                                        "endRowIndex": 1000,
                                        "startColumnIndex": 0,
                                        "endColumnIndex": 1,
                                        "sheetId": 1439439696
                                    }
                ]
                            }
                        }
                    },
                    "series": {
                        "series": {
                            "sourceRange": {
                                "sources": [
                  {
                                        "startRowIndex": 1,
                                        "endRowIndex": 1000,
                                        "startColumnIndex": 5,
                                        "endColumnIndex": 6,
                                        "sheetId": 1439439696
                                    },
                  {
                                        "startRowIndex": 1,
                                        "endRowIndex": 1000,
                                        "startColumnIndex": 6,
                                        "endColumnIndex": 7,
                                        "sheetId": 1439439696
                                    },
                                    {
                                        "startRowIndex": 1,
                                        "endRowIndex": 1000,
                                        "startColumnIndex": 7,
                                        "endColumnIndex": 8,
                                        "sheetId": 1439439696
                                    }
                  ]
                            }
                        }
                    }
                }
            },
            "position": {
                "overlayPosition": {
                    "anchorCell": {
                        "sheetId": 1439439696,
                        "rowIndex": 2,
                        "columnIndex": 2
                    }
       }
            }
        }
    }
}
}

Where am I wrong?

我预计:

问题回答

阁下,

domain sources: A1:A1000 (time of event) on axis x series1 sources: B1:B1000 (values of parameter A) series2 sources: C1:C1000 (values of parameter B) series2 sources: D1:D1000 (values of parameter C)

在你显示的情况时,似乎使用了“A”至“D”栏。 但是,当我看到你提出询问的机构时,似乎使用了“F”至“H”栏。 此外,不幸的是,你的请求机构似乎是使用批量的一个无效结构。 当这些要点反映在抽样请求机构中时,情况如下。

Modified request body:

{
  "requests": [
    {
      "addChart": {
        "chart": {
          "spec": {
            "basicChart": {
              "chartType": "LINE",
              "domains": [
                {
                  "domain": {
                    "sourceRange": {
                      "sources": [
                        {
                          "sheetId": 1439439696,
                          "startRowIndex": 0,
                          "endRowIndex": 1000,
                          "startColumnIndex": 0,
                          "endColumnIndex": 1
                        }
                      ]
                    }
                  }
                }
              ],
              "series": [
                {
                  "series": {
                    "sourceRange": {
                      "sources": [
                        {
                          "sheetId": 1439439696,
                          "startRowIndex": 0,
                          "endRowIndex": 1000,
                          "startColumnIndex": 1,
                          "endColumnIndex": 2
                        }
                      ]
                    }
                  }
                },
                {
                  "series": {
                    "sourceRange": {
                      "sources": [
                        {
                          "sheetId": 1439439696,
                          "startRowIndex": 0,
                          "endRowIndex": 1000,
                          "startColumnIndex": 2,
                          "endColumnIndex": 3
                        }
                      ]
                    }
                  }
                },
                {
                  "series": {
                    "sourceRange": {
                      "sources": [
                        {
                          "sheetId": 1439439696,
                          "startRowIndex": 0,
                          "endRowIndex": 1000,
                          "startColumnIndex": 3,
                          "endColumnIndex": 4
                        }
                      ]
                    }
                  }
                }
              ],
              "headerCount": 1
            }
          },
          "position": {
            "overlayPosition": {
              "anchorCell": {
                "sheetId": 1439439696,
                "rowIndex": 2,
                "columnIndex": 2
              }
            }
          }
        }
      }
    }
  ]
}
  • In this request body, columns "A" to "D" are used.

Note:

  • Unfortunately, I do not know your actual Spreadsheet. But, when I tested this request body using a sample Spreadsheet and the sample values, no error occurred, and a new chart was inserted. If an error occurs, please confirm your sheet ID and values again.

References:





相关问题
Editing legend name on an excel chart using C#

I want to edit the name of the legends given on my excel chart. Right now I have 5 Series on a chart and the legend displays the names "Series 1", "Series 2", "Series 3", "Series 4", "Series 5". I ...

Flash charts that can map/dither the data on X axis

I looked at different flash chart software (free and commercial) and could find only one that supports the feature I want: map my dataset on the predefined X axis. Let me give an example. Let s say ...

Grid Chart using GWT

Is there any library in gwt that will create grid chart, something similar to this : http://www.eyescience.com/images/vision/amsler_grid.gif. Thank you.

Microsoft .Net Chart Control not showing markers

I m using the Microsoft Chart Controls for Microsoft .NET Framework 3.5 and am having a spot of trouble getting Data Markers to show on the image. I m generating the chart at run-time, so can t just ...

Drawing 3D bar graphs using PHP?

I m looking to draw a 3d bar graph similar to the one below alt text http://techportal.co.za/article_images/image004.png My problem is that I can t seem to find any useful library that can do this ...

热门标签