I'm not sure about the axis labels yet, but your date data is suspect, and
moreover, your first column has type 'string'.  For 'date' values, you
should probably use the format "Date(yyyy, mm, dd)".  If you use a single
number, the number is now interpreted as a millisecond value.  But this is
in Universal time, rather than in your local time, so that might be why you
are getting a December 31 value.  Hope that helps.

On Wed, Jul 6, 2016 at 6:46 AM, Christian Schnellrieder <
[email protected]> wrote:

> Hello.
>
> Since some days i try to create a webpage with a google chart. The input
> is a json formated file.
> Everything works except the display of the date. Target is "2016-01" or
> "2016-Jan" but what i get is only "Thu Dec 31 2016, etc etc"
>
>
>
> <https://lh3.googleusercontent.com/-zSJvtKBtDKU/V3zfw8Cd8mI/AAAAAAAAHuk/EmMX1JAgTOoYEoeUrydLNigTCbxE436YQCLcB/s1600/chart1.jpg>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> How can i change the date to year and month?
> Thank you very much for any hint.
> Christian
>
> Source Code:
> graph.html
>
> <html>
>   <head>
>     <!--Load the AJAX API-->
>     <script type="text/javascript" src="
> https://www.gstatic.com/charts/loader.js";></script>
>     <script type="text/javascript" src="//
> ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
>     <script type="text/javascript">
>
> var options = {
>         animation: {
>                 duration: 3000,
>                 startup: true //This is the new option
>             },
>         title: 'Verbrauch',
>         hAxis: {
>           title: 'month',
>           format: 'Y',
>         },
>         vAxis: {
>           title: 'kWh'
>         },
>         width: 1200,
>         height: 500
>
>       };
>
>     // Load the Visualization API and the piechart package.
> //    google.charts.load('current', {'packages':['corechart']});
>         google.charts.load('visualization', '1.1', {'packages':
> ['corechart']});
>
>
>     // Set a callback to run when the Google Visualization API is loaded.
>     google.charts.setOnLoadCallback(drawChart);
>
>     function drawChart() {
>       var jsonData = $.ajax({
>           url: "getData.php",
>           dataType: "json",
>           async: false
>           }).responseText;
>
>       // Create our data table out of JSON data loaded from server.
>       var data = new google.visualization.DataTable(jsonData);
>
>       // Instantiate and draw our chart, passing in some options.
>       var chart = new
> google.visualization.ColumnChart(document.getElementById('chart_div'));
>
>         chart.draw(data, options);
>     }
>
>     </script>
>   </head>
>
>   <body>
>     <!--Div that will hold the pie chart-->
>     <div id="chart_div"></div>
>   </body>
> </html>
>
>
> data.json:
> {
>         "cols": [
>                 {"label":"Date","type":"string"},
>                 {"label":"Basis Tarif","type":"number"},
>                 {"label":"H/N Tarif","type":"number"},
>
>                 ],
>
>         "rows": [
>
> {"c":[{"v":"Date(1451601300000)"},{"v":"355.228"},{"v":"179.224"}] },
>
> {"c":[{"v":"Date(1451602800000)"},{"v":"373.213"},{"v":"290.455"}] },
>
> {"c":[{"v":"Date(1454281200000)"},{"v":"379.148"},{"v":"201.963"}] },
>
> {"c":[{"v":"Date(1456786800000)"},{"v":"374.395"},{"v":"178.306"}] },
>
> {"c":[{"v":"Date(1459461600000)"},{"v":"361.792"},{"v":"78.485"}] },
>
> {"c":[{"v":"Date(1462053600000)"},{"v":"347.246"},{"v":"51.025"}] },
>
> {"c":[{"v":"Date(1464732000000)"},{"v":"347.201"},{"v":"39.039"}] },
>                 ]
>
> }
>
>
>
> getData.php
> <?php
>
> // It reads a json formatted text file and outputs it.
>
> $string = file_get_contents("data.json");
> echo $string;
>
> // Instead you can query your database and parse into JSON.
>
> ?>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to
> [email protected].
> Visit this group at
> https://groups.google.com/group/google-visualization-api.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-visualization-api/ee3d0654-b8f7-420d-b32d-16d6f97f8e96%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/ee3d0654-b8f7-420d-b32d-16d6f97f8e96%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]>   5CC, Cambridge MA

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJOzPo1RYe294ebdmppVDiexZvG9VoxTPtXc_zBu4K6PfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to