谷歌图表未显示自定义列的角度数据

时间:2017-01-26 14:52:53

标签: javascript angularjs charts google-chartwrapper

我有以下javascript对象数组,我存储在$ scope.o

[{"id":"jimmy.cibby@redsss.com","label":"marc.cibby@redsss.com","type":"number","p":{}},{"id":"matthew.cibby@redsss.com","label":"matthew.cibby@redsss.com","type":"number","p":{}},{"id":"ari.grads@redsssdsss.com","label":"ari.grads@redsssdsss.com","type":"number","p":{}},{"id":"yup@redsssdsss.com","label":"yup@redsssdsss.com","type":"number","p":{}},{"id":"service@redsssdsss.com","label":"service@redsss.com","type":"number"}]

然后我对谷歌图表进行了以下设置:

$scope.data= {
  "type": "LineChart",
  "displayed": true,
  "data": {
    "cols":$scope.o,
    "rows": [
      {
        "c": [
          {
            "v": "January"
          },
          {
            "v": 19,
            "f": "42 items"
          },
          {
            "v": 12,
            "f": "Ony 12 items"
          },
          {
            "v": 7,
            "f": "7 servers"
          },
          {
            "v": 4
          },
          {"v": 5}
        ]
      },
      {
        "c": [
          {
            "v": "February"
          },
          {
            "v": 13
          },
          {
            "v": 1,
            "f": "1 unit (Out of stock this month)"
          },
          {
            "v": 12
          },
          {
            "v": 2
          },
          {
            "v": 2
          }
        ]
      },
      {
        "c": [
          {
            "v": "March"
          },
          {
            "v": 24
          },
          {
            "v": 5
          },
          {
            "v": 11
          },
          {
            "v": 6
          },
          {
            "v":12
          }
        ]
      }
    ]
  },
  "options": {
    "title": "some data",
    "tooltip": {trigger: "selection"},
    "isStacked": "true",
    "fill": 20,
    "displayExactValues": true,
    "chartArea": {width: "70%", height: "70%"},
    "vAxis": {
      "title": "data",
      "gridlines": {
        "count": 10
      }
    },
    "hAxis": {
      "title": "month"
    }
  },
  "formatters": {}
}




}]);

正如您所看到的,我在此处对示例应用所做的全部工作:http://angular-google-chart.github.io/angular-google-chart/docs/latest/examples/multi-chart/ 将列更改为自定义列。

这种作品 - 图例通过电子邮件地址标签,但图表为空,没有数据。

有关为何会发生这种情况的任何建议?

1 个答案:

答案 0 :(得分:0)

修正了......我需要添加: $ scope.o.push({                 id:“月”,                 标签:“月”,                 类型:“字符串”             }); 在for循环之前。菜鸟错误!