谷歌图表 - 在柱形图上绘制趋势线

时间:2015-07-30 10:58:08

标签: javascript google-visualization jsapi

我正在尝试在柱形图上绘制趋势线。但线条没有显示。 请参考jsfiddle https://jsfiddle.net/sashant9/m04py64w/

我根据谷歌图表文档使用了'趋势线:{1:{},2:{}}'。

请检查以下代码。

ORA-06550: line 2, column 1: PLS-00103: Encountered the symbol "ELSE" when expecting one of the following: . ( * % & - + / at mod remainder rem then <an exponent (**)> and or || multiset 
ORA-06550: line 7, column 18: PLS-00103: Encountered the symbol ";" when expecting one of the following: if The symbol "if" was substituted for ";" to continue.
ORA-06550: line 7, column 54: PLS-00103: Encountered the symbol    "end-of-file" when expecting one of the following: begin case declare
end exception

1 个答案:

答案 0 :(得分:1)

请尝试以下代码,检查工作小提琴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});