Ok. I added an actual strict json representation and wasn't seen data
points ( http://prnt.sc/ekmlav ). Console has no errors.
Code:
{
"cols": [
{"id":"","label":"","pattern":"","type":"datetime"},
{"id":"","label":"","pattern":"#.######","type":"number"}
],
"rows": [
{"c":[{"v":"Date(2017, 2, 17, 10, 49, 21)","f":1.008876}]},
{"c":[{"v":"Date(2017, 2, 18, 10, 51, 15)","f":2.007845}]},
{"c":[{"v":"Date(2017, 2, 19, 10, 50, 35)","f":3.006823}]}
]
}
I don't know why..
Can I use other format files or data(txt, array)? Do you have examples? I
need that data refreshing dynamically. Maybe arrayToDataTable() helps me?
Maybe you know some hacks? I found this conversation (
https://groups.google.com/forum/#!searchin/google-visualization-api/Row$20given$20with$20size$20different$20than|sort:relevance/google-visualization-api/jM7M4i2nEwE/vRo4p4JJq0wJ
)
Your reply will be higly appreciated.
среда, 15 марта 2017 г., 15:54:27 UTC+2 пользователь Daniel LaLiberte
написал:
>
> Sorry, my mistake. This use of the string format for dates and datetimes
> has not ever worked when used with the addRows() method. If you need to
> pass date strings, you will need to use the actual strict json
> representation shown in the example here:
> https://developers.google.com/chart/interactive/docs/datesandtimes#dates-and-times-using-the-date-string-representation
>
> This is because the only reason you need to use this string representation
> of dates and datetimes is for json which doesn't permit the 'new' keyword
> to construct dates. For consistency, I expect we should be able to support
> this same format in other cases as well.
>
> For reference, also see:
> https://developers.google.com/chart/interactive/docs/datatables_dataviews#creating-and-populating-a-datatable
>
>
>
> On Wed, Mar 15, 2017 at 9:19 AM, Daniel LaLiberte <[email protected]
> <javascript:>> wrote:
>
>> Thanks for reporting this. For some reason, the string notation for
>> dates and datetimes is not working. Until we fix it, you will have to use
>> JavaScript date constructors. e.g. new Date(2017, 2, 17, 10, 49, 21)
>> without the quotes.
>>
>>
>> On Wed, Mar 15, 2017 at 8:07 AM, Dmitry Tumannik <[email protected]
>> <javascript:>> wrote:
>>
>>> Hello.
>>> I'm in trouble with that.
>>>
>>> function drawChart() {
>>>
>>> var chart = new
>>> google.visualization.AnnotationChart(document.getElementById('chart_div'));
>>>
>>> function updateData () {
>>> $.ajax({
>>> url: 'getData.php',
>>> dataType: 'json',
>>> success: function (json) {
>>> data = new google.visualization.DataTable(json);
>>> data.addColumn('datetime', 'Date');
>>> data.addColumn('number', 'Number');
>>> data.addRows(json);
>>> chart.draw(data);
>>> },
>>> error: function() {
>>> console.log('nodata');
>>> }
>>> });
>>> }
>>>
>>> setTimeout(function () {
>>> updateData();
>>> }, 1000);
>>>
>>> }
>>>
>>>
>>> getData:
>>>
>>> $string = file_get_contents("testData.json");
>>> echo $string;
>>>
>>>
>>> JSON:
>>>
>>> [
>>> ["Date(2017, 2, 17, 10, 49, 21)",386],["Date(2017, 2, 17, 10, 51,
>>> 15)",452],["Date(2017, 2, 17, 10, 50, 35)",327]
>>> ]
>>>
>>>
>>> What I am doing wrong?
>>>
>>> --
>>> 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]
>>> <javascript:>.
>>> To post to this group, send email to [email protected]
>>> <javascript:>.
>>> 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/73de14b5-efd2-4f16-9b2d-43921b83956a%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/google-visualization-api/73de14b5-efd2-4f16-9b2d-43921b83956a%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] <javascript:> 5CC, Cambridge MA
>>
>
>
>
> --
> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
> [email protected] <javascript:> 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/2011bf22-9210-44d6-93c3-01ca86408875%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.