[英]Google Column Chart Missing data
我已經搜索了很多時間,但是沒有找到任何可行的解決方案,因此決定提出一個問題。 為什么我看不到我的firs data_row元素99.00日期?
這是代碼,我如何初始化所有腳本:
var colors = [ '#F1A504', '#80CE61', '#0BA3E4', '#7E4CCF' ];
var gChart = {
table_data : {
1: 'Reguliavimas "į viršų" kiekis',
2: 'Reguliavimas "žemyn" kiekis',
3: 'Reguliavimas "į viršų" kaina',
4: 'Reguliavimas "žemyn" kaina'
},
data_row : [
[ new Date( 2013, 3, 17, 0, 00, 00 ), 0.00, 99.00, 0.00, 40.00],
[new Date( 2013, 3, 17, 1, 00, 00 ), 0.00, 11.00, 0.00, 40.00],
[new Date( 2013, 3, 17, 2, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 3, 00, 00 ), 0.00, 27.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 4, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 5, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 6, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 7, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 8, 00, 00 ), 0.00, 42.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 9, 00, 00 ), 0.00, 30.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 10, 00, 00 ), 0.00, 20.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 11, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 12, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 13, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 14, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 15, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 16, 00, 00 ), 0.00, 46.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 17, 00, 00 ), 0.00, 90.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 18, 00, 00 ), 0.00, 90.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 19, 00, 00 ), 0.00, 108.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 20, 00, 00 ), 0.00, 75.00, 0.00, 38.00],
[new Date( 2013, 3, 17, 21, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 22, 00, 00 ), 0.00, 0.00, 0.00, 0.00],
[new Date( 2013, 3, 17, 23, 00, 00 ), 0.00, 0.00, 0.00, 0.00 ]
],
lang : 'lt',
maxV : 108.00,
minV : 0.00,
chartType: 1,
dataGroup: 'H'
};
function drawChart( id, table_data, data_row, lang, chartType, colors ){
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('datetime', 'Time');
for ( var i = 1; i <= objCount( table_data ); i++ ) {
dataTable.addColumn( 'number', table_data[i] );
}
var dataView = new google.visualization.DataView( dataTable );
var options3 = {
width: 670,
height: 380,
fontSize: 11,
colors: colors,
backgroundColor: 'transparent',
legend: 'none',
chartArea: {
top: 5,
left: 50,
width: 647,
height: 351
},
hAxis: {
textStyle: { color: "#9a9fa3" },
baselineColor: "#b1b3b6",
gridlines: {
color: "transparent",
count: 28
},
maxAlternation: 26,
format: gChart.dataGroup
},
vAxis: {
baselineColor: "#b1b3b6",
gridlines: {
color: "#eff0f1",
count: 8
},
textStyle: { color: "#9a9fa3" }
}
};
var chart = new google.visualization.ColumnChart( document.getElementById( id ) );
dataTable.addRows( data_row );
chart.draw( dataView, options3 );
}
/* LOADING GCHARTS */
google.load( "visualization", "1", { packages:["corechart"], language: gChart.lang } );
google.setOnLoadCallback(function() {
drawChart( 'chart', gChart.table_data, gChart.data_row, gChart.lang, gChart.chartType, colors );
});
請在未顯示第一列的Google可視化圖表中查看我的答案
本質上,您需要使用DataView將表的第一列設置為字符串格式。
后:
var dataView = new google.visualization.DataView( dataTable );
插入:
dataView.setColumns([{calc: function(data, row) { return data.getFormattedValue(row, 0); }, type:'string'}, 1, 2, 3, 4]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.