Google 图表 - 在柱形图上绘制趋势线
Google charts - Plot trendlines on column chart
我正在尝试在柱形图上绘制趋势线。但是线条不显示。
请参考 jsfiddle https://jsfiddle.net/sashant9/m04py64w/
我根据 google 图表文档使用了 'trendlines: { 1:{},2:{}}'。
请检查下面的代码。
function drawVisitorGraph() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Date');
data.addColumn('number', 'Search Visitors');
data.addColumn('number', 'Unique Visitors');
data.addRow(["2015-07-01",1774,3266]);
data.addRow(["2015-07-02",1891,3017]);
data.addRow(["2015-07-03",1572,2730]);
data.addRow(["2015-07-04",979,1604]);
data.addRow(["2015-07-05",1024,1702]);
data.addRow(["2015-07-06",2163,4097]);
var chart = new google.visualization.ColumnChart(document.querySelector('#visitor_graph'));
var options = {
bars: 'vertical',
vAxis: {format: 'decimal'},
trendlines: { 1:{},2:{}},
width: '100%',
height: '100%',
colors: ['#070979', '#EC0F13']
}
chart.draw(data,options);
}
//google.setOnLoadCallback(drawChart);
google.load('visualization', '1.1', {packages: ['corechart'], callback: drawVisitorGraph});
请尝试下面的代码,检查工作 fiddle here.
function drawVisitorGraph() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Search Visitors');
data.addColumn('number', 'Unique Visitors');
data.addRow([new Date(2015,07,01),1774,3266]);
data.addRow([new Date(2015,07,02),1891,3017]);
data.addRow([new Date(2015,07,03),1572,2730]);
data.addRow([new Date(2015,07,04),979,1604]);
data.addRow([new Date(2015,07,05),1024,1702]);
data.addRow([new Date(2015,07,06),2163,4097]);
var chart = new google.visualization.ColumnChart(document.querySelector('#visitor_graph'));
var options = {
bars: 'vertical',
vAxis: {format: 'decimal'},
trendlines: { 0:{},1:{}},
width: '100%',
height: '100%',
colors: ['#070979', '#EC0F13']
}
chart.draw(data,options);
}
//google.setOnLoadCallback(drawChart);
google.load('visualization', '1.1', {packages: ['corechart'], callback: drawVisitorGraph});
我正在尝试在柱形图上绘制趋势线。但是线条不显示。 请参考 jsfiddle https://jsfiddle.net/sashant9/m04py64w/
我根据 google 图表文档使用了 'trendlines: { 1:{},2:{}}'。
请检查下面的代码。
function drawVisitorGraph() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Date');
data.addColumn('number', 'Search Visitors');
data.addColumn('number', 'Unique Visitors');
data.addRow(["2015-07-01",1774,3266]);
data.addRow(["2015-07-02",1891,3017]);
data.addRow(["2015-07-03",1572,2730]);
data.addRow(["2015-07-04",979,1604]);
data.addRow(["2015-07-05",1024,1702]);
data.addRow(["2015-07-06",2163,4097]);
var chart = new google.visualization.ColumnChart(document.querySelector('#visitor_graph'));
var options = {
bars: 'vertical',
vAxis: {format: 'decimal'},
trendlines: { 1:{},2:{}},
width: '100%',
height: '100%',
colors: ['#070979', '#EC0F13']
}
chart.draw(data,options);
}
//google.setOnLoadCallback(drawChart);
google.load('visualization', '1.1', {packages: ['corechart'], callback: drawVisitorGraph});
请尝试下面的代码,检查工作 fiddle here.
function drawVisitorGraph() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Search Visitors');
data.addColumn('number', 'Unique Visitors');
data.addRow([new Date(2015,07,01),1774,3266]);
data.addRow([new Date(2015,07,02),1891,3017]);
data.addRow([new Date(2015,07,03),1572,2730]);
data.addRow([new Date(2015,07,04),979,1604]);
data.addRow([new Date(2015,07,05),1024,1702]);
data.addRow([new Date(2015,07,06),2163,4097]);
var chart = new google.visualization.ColumnChart(document.querySelector('#visitor_graph'));
var options = {
bars: 'vertical',
vAxis: {format: 'decimal'},
trendlines: { 0:{},1:{}},
width: '100%',
height: '100%',
colors: ['#070979', '#EC0F13']
}
chart.draw(data,options);
}
//google.setOnLoadCallback(drawChart);
google.load('visualization', '1.1', {packages: ['corechart'], callback: drawVisitorGraph});