Google visualization 在google图表中显示零值注释
我正在使用GoogleCharts API创建柱状图。我创建了所有数据列,并在列中显示注释。但问题是,如果列值为零,则不会显示注释。如何解决这个问题。我需要显示“0” 我的代码是:Google visualization 在google图表中显示零值注释,google-visualization,Google Visualization,我正在使用GoogleCharts API创建柱状图。我创建了所有数据列,并在列中显示注释。但问题是,如果列值为零,则不会显示注释。如何解决这个问题。我需要显示“0” 我的代码是: google.load('visualization', '1.0', {'packages':['corechart']}); google.setOnLoadCallback(drawChart4); function drawChart4() { var dat
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawChart4);
function drawChart4() {
var data = new google.visualization.DataTable();
data.addColumn({ type: 'string', lable:'Something'});
data.addColumn('number','SLA Met');
data.addColumn({ type: 'number', role: 'annotation'});
data.addColumn('number','SLA Not Met');
data.addColumn({ type: 'number', role: 'annotation'});
data.addRows([
['Ancillary',<%=ANCILLARY_MET %>,<%=ANCILLARY_MET %>,<%=ANCILLARY_NOTMET%>,<%=ANCILLARY_NOTMET%> ],
['CIS',<%=CIS_MET %>,<%=CIS_MET %>,<%=CIS_NOTMET%>,<%=CIS_NOTMET%>],
['ERP FSCM',<%=FSCM_MET %>,<%=FSCM_MET %>,<%=FSCM_NOTMET%>,<%=FSCM_NOTMET%>],
['ERP HCM',<%=HCM_MET %>,<%=HCM_MET %>,<%=HCM_NOTMET%>,<%=HCM_NOTMET%>]
]);
var options = {'colors' : ['#3366CC', '#fcb441'],
title: 'Resolution SLA(Tower Wise)',titleTextStyle:{fontName:'"Arial"'},
hAxis: {title: 'Tower', titleTextStyle: {color: 'black',fontSize:'15',fontName:'"Arial"'}},
vAxis: {minValue:0},
legend:{position: 'bottom'},
tooltip:{trigger:'none'}
};
var chart = new google.visualization.ColumnChart(document.getElementById('g5'));
chart.draw(data, options);
}
google.load('visualization','1.0',{'packages':['corechart']});
setOnLoadCallback(drawChart4);
函数drawChart4(){
var data=new google.visualization.DataTable();
addColumn({type:'string',lable:'Something'});
data.addColumn('number','SLA Met');
addColumn({type:'number',role:'annotation'});
data.addColumn('number','SLA Not meted');
addColumn({type:'number',role:'annotation'});
data.addRows([
[‘辅助’,,,],
[CIS',,,],
['ERP FSCM',,,],
['ERP HCM',,,]
]);
变量选项={'colors':['3366CC','fcb441'],
标题:'Resolution SLA(塔式)',标题文字样式:{fontName:'“Arial”},
hAxis:{title:'Tower',titleTextStyle:{color:'black',fontSize:'15',fontName:'Arial'},
变量:{minValue:0},
图例:{位置:'bottom'},
工具提示:{触发器:'none'}
};
var chart=new google.visualization.ColumnChart(document.getElementById('g5');
图表绘制(数据、选项);
}
似乎您在注释中使用了错误的类型编号。为了
{ type: 'string', role: 'annotation'}
并作为字符串输入,即使值“0”也会显示注释
另见
更新:为了澄清,您只需更改注释的输入类型,例如
['Ancillary', 15, 15, 3, 3 ],
到
所以你的代码应该是:
data.addColumn({ type: 'string', lable:'Something'});
data.addColumn('number','SLA Met');
data.addColumn({ type: 'string', role: 'annotation'});
data.addColumn('number','SLA Not Met');
data.addColumn({ type: 'string', role: 'annotation'});
谢谢你的回答。但我无法获得解决方案。如果我更改注释类型,图表将不显示。您还必须更改输入值。例如,从0到“0”或从350到“350”。#0轴的“数据列不能是字符串类型”错误出现在chart.Data.addRows([['associative'、'0'、'0'、'10'、'10']);可能使注释不出现的一件事是,如果“点”的值为null,则从null更改为零,解决了问题。这件事发生在我的柱状图上。
data.addColumn({ type: 'string', lable:'Something'});
data.addColumn('number','SLA Met');
data.addColumn({ type: 'string', role: 'annotation'});
data.addColumn('number','SLA Not Met');
data.addColumn({ type: 'string', role: 'annotation'});