user2727841
user2727841

Reputation: 725

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 google line chart

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();
    }

Upvotes: 2

Views: 454

Answers (1)

tiomno
tiomno

Reputation: 2228

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]
    ]);

Upvotes: 3

Related Questions