Google Chart APIを使用してタイムラインチャートを作成しようとしています。しかし、問題は、特定の行にNULLの日付を扱うことができないことです。Google Chartタイムラインでヌル日付を設定する
はどのようにヌルの開始日と終了日が行を非表示にできますか?
google.charts.load("current", {packages:["timeline"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
google.visualization.events.addListener(chart, 'error', errorHandler);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Role' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
[
'NTC',
'NTC',
new Date('07/05/2016'),
new Date('07/06/2016'),
],
[
'Briefing Meeting',
'Baseline',
new Date('07/07/2016'),
new Date('07/06/2016'),
],
[
'Concept Design',
'Baseline',
new Date('07/05/2016'),
new Date('07/06/2016'),
],
[
'Concept Design',
'Forecast',
new Date('07/05/2016'),
new Date('07/06/2016'),
],
[
'Concept Design',
'Actual',
new Date('07/05/2016'),
new Date('07/06/2016'),
],
[
'Detail Design',
'Baseline',
new Date('07/05/2016'),
new Date('07/06/2016'),
],
[
'Detail Design',
'Forecast',
new Date('07/05/2016'),
new Date('07/06/2016'),
],
[
'Detail Design',
'Actual',
new Date('07/05/2016'),
new Date(),
],
]);
var colors = [];
var colorMap = {
Baseline: '#425cfb',
Forecast: '#f8ac08',
Actual: '#06af90',
NTC: '#1b9e2e'
}
for (var i = 0; i < dataTable.getNumberOfRows(); i++) {
colors.push(colorMap[dataTable.getValue(i, 1)]);
}
var options = {
colors: colors,
timeline: {
showBarLabels: false,
groupByRowLabel: true,
// rowLabelStyle: {fontName: 'Helvetica', fontSize: 24, color: '#603913'},
barLabelStyle: { fontName: 'Garamond', fontSize: 6 },
},
interpolateNulls: true,
};
}
新しい日付(0)を設定すると無効なdatetimeが表示されますが、回避策はありますか?あなたは、サーバーのコードでこれらの投稿をフィルタリングする可能性を持っている場合、すでに間違った行をフィルタリング
あなたはフィドルを作成しますか? – Santhucool
これは私が作成したフィドルです。これは私がここに投稿したものの改訂版です。あなたが見ることができるように https://jsfiddle.net/6s65tat2/ 、そこには新しいDate()に設定されているので、予測と実際の他の行などに表示する日とするが、それは返すべきではありません私が達成しようとしているものではない現在の日付。 –
これは更新されたフィドルです https://jsfiddle.net/txr3k2z0/ –