Google visualization Google Charts折线图错误…给定轴上的所有系列必须具有相同的数据类型

Google visualization Google Charts折线图错误…给定轴上的所有系列必须具有相同的数据类型,google-visualization,linechart,Google Visualization,Linechart,我正在绘制包含以下数据的折线图: 而且效果很好。 但当我尝试向数据中添加另一个文本列时-例如: 我得到以下错误:“给定轴上的所有系列必须具有相同的数据类型” 我需要第三列,以便为以后创建categoryFilter 我该怎么做 谢谢您可以在不影响数据的情况下存储表、列、行和单元格的任何类型的属性 存储行属性的示例超重: var data = google.visualization.arrayToDataTable([ ['Name', 'Donuts eaten'], {c:['

我正在绘制包含以下数据的折线图:

而且效果很好。 但当我尝试向数据中添加另一个文本列时-例如:

我得到以下错误:“给定轴上的所有系列必须具有相同的数据类型”

我需要第三列,以便为以后创建categoryFilter

我该怎么做


谢谢

您可以在不影响数据的情况下存储表、列、行和单元格的任何类型的属性

存储行属性的示例
超重

 var data = google.visualization.arrayToDataTable([
   ['Name', 'Donuts eaten'],
   {c:['Michael'  , 5],p:{overweight:'yes'}},
   {c:['Elisa'    , 7],p:{overweight:'no'}},
   {c:['Robert'   , 3],p:{overweight:'yes'}},
   {c:['John'     , 2],p:{overweight:'no'}},
   {c:['Jessica'  , 6],p:{overweight:'yes'}},
   {c:['Aaron'    , 1],p:{overweight:'no'}},
   {c:['Margareth', 8],p:{overweight:'yes'}}
 ]);

过滤器的可能实现:

google.setOnLoadCallback(绘图图);
函数绘图图(){
var data=google.visualization.arrayToDataTable([
['Name','Donuts eated'],
{c:['Michael',5],p:{超重:'yes'},
{c:['Elisa',7],p:{超重:'no'},
{c:['Robert',3],p:{超重:'yes'},
{c:['John',2],p:{超重:'no'},
{c:['Jessica',6],p:{超重:'yes'},
{c:['Aaron',1],p:{超重:'no'},
{c:['Margareth',8],p:{超重:'yes'}
]);
var chart=new google.visualization.LineChart(document.getElementById('chart');
window.filter=函数(val){
var view=newgoogle.visualization.DataView(数据);
如果(val!=“0”){
对于(var r=view.getNumberOfRows()-1;r>=0;--r){
if(val!==view.getRowProperty(r,“超重”){
视图。隐藏视图([r]);
}
}
}
图表。绘制(视图);
}
筛选器(document.getElementsByTagName('select')[0].value);
}

无过滤器
超重
不超重

您可以在不影响数据的情况下存储表、列、行和单元格的任何类型的属性

存储行属性的示例
超重

 var data = google.visualization.arrayToDataTable([
   ['Name', 'Donuts eaten'],
   {c:['Michael'  , 5],p:{overweight:'yes'}},
   {c:['Elisa'    , 7],p:{overweight:'no'}},
   {c:['Robert'   , 3],p:{overweight:'yes'}},
   {c:['John'     , 2],p:{overweight:'no'}},
   {c:['Jessica'  , 6],p:{overweight:'yes'}},
   {c:['Aaron'    , 1],p:{overweight:'no'}},
   {c:['Margareth', 8],p:{overweight:'yes'}}
 ]);

过滤器的可能实现:

google.setOnLoadCallback(绘图图);
函数绘图图(){
var data=google.visualization.arrayToDataTable([
['Name','Donuts eated'],
{c:['Michael',5],p:{超重:'yes'},
{c:['Elisa',7],p:{超重:'no'},
{c:['Robert',3],p:{超重:'yes'},
{c:['John',2],p:{超重:'no'},
{c:['Jessica',6],p:{超重:'yes'},
{c:['Aaron',1],p:{超重:'no'},
{c:['Margareth',8],p:{超重:'yes'}
]);
var chart=new google.visualization.LineChart(document.getElementById('chart');
window.filter=函数(val){
var view=newgoogle.visualization.DataView(数据);
如果(val!=“0”){
对于(var r=view.getNumberOfRows()-1;r>=0;--r){
if(val!==view.getRowProperty(r,“超重”){
视图。隐藏视图([r]);
}
}
}
图表。绘制(视图);
}
筛选器(document.getElementsByTagName('select')[0].value);
}

无过滤器
超重
不超重
 var data = google.visualization.arrayToDataTable([
   ['Name', 'Donuts eaten'],
   {c:['Michael'  , 5],p:{overweight:'yes'}},
   {c:['Elisa'    , 7],p:{overweight:'no'}},
   {c:['Robert'   , 3],p:{overweight:'yes'}},
   {c:['John'     , 2],p:{overweight:'no'}},
   {c:['Jessica'  , 6],p:{overweight:'yes'}},
   {c:['Aaron'    , 1],p:{overweight:'no'}},
   {c:['Margareth', 8],p:{overweight:'yes'}}
 ]);