If you have a "date" column in your database and a "time" column (which for
this purpose would probably have to be an integer for the number of minutes
in the day, eg 10:30 AM would be 630 minutes), then you can use filters to
get the last x hours.
var today = new Date();
var yesterday = new
Date(today.getFullYear(), today.getMonth(), today.getDay() - 1);
var dateFormatter = new google.visualization.DateFormat({pattern:
'yyyy-MM-dd'});
var todayString = dateFormatter.formatValue(today);
var yesterdayString = dateFormatter.formatValue(yesterday);
var minutes = today.getHours() * 60 + today.getMinutes();
// query for last 6 hours
var query6Hours = new google.visualization.Query(url);
if (minutes >= 360) {
query6Hours.setQuery('select <columns> where <date column> = date + '
todayString + ' and <minutes column> > ' + (minutes - 360));
}
else {
// minutes yesterday > (1440 - 360 + minutes)
query6Hours.setQuery('select <columns> where (<date column> = date + '
todayString + ') or (<date column> = date + ' yesterdayString + ' and
<minutes column> > ' + (1080 + minutes));
}
// query for last 12 hours
var query12Hours = new google.visualization.Query(url);
if (minutes >= 720) {
query12Hours.setQuery('select <columns> where <date column> = date + '
todayString + ' and <minutes column> > ' + (minutes - 720));
}
else {
// minutes yesterday > (1440 - 720 + minutes)
query12Hours.setQuery('select <columns> where (<date column> = date + '
todayString + ') or (<date column> = date + ' yesterdayString + ' and
<minutes column> > ' + (720 + minutes));
}
// etc...
You could also write one query for the past 24 hours and use DataViews to
filter the data into smaller sets.
On Friday, November 22, 2013 12:22:50 PM UTC-5, Michał Kowalski wrote:
>
> Thanks for your reply.
>
> I want to reduce amount of data I get from the spreadsheet. I'd like to
> make few charts - like from last hour, last 6, 12, 24 hours etc.
>
> I did everything what's written on this page -
> https://developers.google.com/chart/interactive/docs/spreadsheets . At
> the end there is a possible solution - but I have to manually choose a
> range. And this doesn't work for me because every 10min I get another data
> which won't be included.
>
> MK
>
> W dniu piątek, 22 listopada 2013 17:50:21 UTC+2 użytkownik asgallant
> napisał:
>>
>> Are you looking to limit the amount of data that you get from the
>> spreadsheet or are you looking for a way to reduce the amount of data
>> displayed at any one time in the chart(s)? The first will depend on how
>> you are getting the data from the spreadsheet. The second, you can use a
>> control like a
>> ChartRangeFilter<https://developers.google.com/chart/interactive/docs/gallery/controls#chartrangefilter>to
>> allow the user to zoom and pan the data set.
>>
>> On Friday, November 22, 2013 7:49:50 AM UTC-5, Michał Kowalski wrote:
>>>
>>> Hi,
>>>
>>> I've created line charts based on spreadsheet document. On server side a
>>> python script add a new row every 10 minutes. After some time the chart
>>> starts to be quite 'unreadable'.
>>>
>>> My question - is there a way to show entries from last 24h? Or just show
>>> some previously entered numer of entries?
>>>
>>> Thanks for your help
>>> Michał K.
>>>
>>
--
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.