我有大量的大数据,这些大数据是我从数据库中提取到数组中的,我真的需要逗号来保证可用性。因此,在SQL中,我格式化数字,它们确实很棒。当我在Google图表中使用它们时,图表会中断。因此,我删除了SQL中的“格式”并显示原始数字,而Google Charts很高兴。真是两难。两者的可用性都非常出色。
这是我当前漂亮的图表代码。
<script type="text/javascript">
google.charts.load('current',{packages: ['corechart'],callback: drawChart});
function drawChart() {
var tableRows = [];
var results = document.getElementById('allstage');
Array.prototype.forEach.call(results.rows,function(row) {
var tableColumns = [];
Array.prototype.forEach.call(row.cells,function(cell) {
var cellText = cell.textContent || cell.innerText;
switch (cell.cellIndex) {
case 0:
tableColumns.push(cellText.trim());
break;
default:
switch (row.rowIndex) {
case 0:
tableColumns.push(cellText.trim());
break;
default:
tableColumns.push(parseFloat(cellText));
}
}
});
tableRows.push(tableColumns);
});
var data = google.visualization.arrayToDataTable(tableRows);
var formatter = new google.visualization.NumberFormat(
{negativeColor: 'red',negativeParens: true,pattern: '###,###'});
formatter.format(data,1);
var options = {
title: 'All Stages In Percent',titleTextStyle: {color: 'black',fontSize: 28},bar: {groupWidth: '70%'},chartArea: { backgroundColor: { fill: '#F0F8FC',opacity: 100 }},fontSize:12,legend: { position: 'right',textStyle: { color: 'black',fontSize: 12}},tooltip: {isHtml: true},is3D: true,};
var chart = new google.visualization.PieChart(document.getElementById('allstage_div'));
chart.draw(data,options);
}
有什么想法吗?我尝试发布问题图像,但该内容显示“您至少需要10个声誉才能发布图像!”太好了……朋友之间的声誉如何?简单的图像位于HTTP:// // i.ibb.co/DYZWbkc/Capture.jpg