SherCoder
SherCoder

Reputation: 688

date formatting and remove column name in Google charts

IMG

I have two issues in this google chart.

  1. I want to either get rid of the word Resour... on the right side or display the entire word.
  2. When I hover over any bar, I want to display the time or maybe both time and date for that data point

Here is my code to display the chart:

<script type='text/javascript'>
    google.load('visualization', '1', { 'packages': ['corechart'] });
    google.setOnLoadCallback(drawSizeChart);

    function drawSizeChart() {

        $.post('/metrics/GetSiteSize', { sID: "@Model.SiteId" },
        function (data) {

            var tdata = new google.visualization.DataTable();
            tdata.addColumn('string', 'Date');
            tdata.addColumn('number', 'Resources');

            for (var i = 0; i < data.length; i++) {
                var date = (new Date(parseInt(data[i].created_at.substr(6)))).toString().substring(4, 15);
                var rCount = data[i].resource_count;
                tdata.addRow([date, rCount]);
            }

            var options = {
                title: 'Resource Count',
                };

            var chart = new google.visualization.ColumnChart(document.getElementById('site_size'));
            chart.draw(tdata, options);
        });
    }
</script>

Upvotes: 0

Views: 1276

Answers (1)

SwarthyMantooth
SwarthyMantooth

Reputation: 1857

Accord to the top comment in this question, "it actually appears as though you can omit the chdl= parameter to get a scatter without a legend." Hope that helps. EDIT: Hah, I didn't read the whole thing.

Use...

legend: {position: 'none'}

Upvotes: 3

Related Questions