简体   繁体   中英

Google line chart time is showing

I'm working on google line chart and it is working fine but I want to hide time, when I hover at point it is showing complete date and time, I want only date not time how to hide time I search a lot but didn't find any solution and tried different parameters which I found on different forums but none of them work for me.

you can all see screen shot 谷歌折线图

as you can see date and time are mention and usage is 600 only date should be shown not time and my code is

    google.charts.load('current', {'packages':['line', 'corechart']});
    google.charts.setOnLoadCallback(drawChart);
    function drawChart() {
        var chartDiv = document.getElementById('chartDiv');
        var data = new google.visualization.DataTable();

        data.addColumn('date', 'Month');
        data.addColumn('number', "Sent");
        data.addColumn('number', "Signed");
        data.addColumn('number', "ID");
        data.addColumn('number', "Usage");

        data.addRows([
            [new Date(2017, 1, 2),   24,   57,    2,   12],
            [new Date(2017, 2, 4),   87,   87,    4,   45],
            [new Date("2017-03-05"),   54,   12,    6,   67],
            [new Date("2017-04-08"),   32,  153,    6,   87]
        ]);

        var materialOptions = {
                chart: {
                title: 'Chart of: (User 1)'
            },
            width: 1200,
            height: 600
        };

        function drawMaterialChart() {
            var materialChart = new google.charts.Line(chartDiv);
            materialChart.draw(data, materialOptions);
        }
        drawMaterialChart();
    }

One simple solution may be to treat the date as a string, so

    data.addColumn('string', 'Month'); //<-- change type date for string
    data.addColumn('number', "Sent");
    data.addColumn('number', "Signed");
    data.addColumn('number', "ID");
    data.addColumn('number', "Usage");

    data.addRows([ // then change all new Date() for strings
        ["1/2/2017",   24,   57,    2,   12],
        ["2/4/2017",   87,   87,    4,   45],
        ["3/5/2017"),   54,   12,    6,   67],
        ["4/8/2017"),   32,  153,    6,   87]
    ]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM