i think you can put a query or rows in controllers, and then do it on the
views side :
e.g.
*views/default/test.html*
<table>
<tr>
<td>
<div id="stock_nav" style="margin: 0 auto; width : 95%;"></div>
</td>
</tr>
</table>
{{
rows_stock = db(query_nav).select(distinct = True, groupby =
db.nav.nav_date,
cache = cache_db, cacheable = True)
}}
<script type="text/javascript">
$(function () {
$(document).ready(function () {
Highcharts.setOptions({
lang: {
decimalPoint: ',',
thousandsSep: '.'
}
});
// stock nav
$('#stock_nav').highcharts('StockChart', {
chart: {
//type: 'spline',
type: 'line',
zoomType: 'x'
},
credits: {
enabled: false
},
legend: {
enabled: true
},
rangeSelector: {
selected: 1
},
series: [{
name: '{{=T('NAV per Unit') }}',
data: [
{{
for row_stock_nav in rows_stock:
timestamp = (row_stock_nav.nav_date - datetime.date(1970,1,1)
).total_seconds()
}}
[ {{=timestamp * 1000}}, {{=row_stock_nav.nav_per_unit }} ],
{{pass}}
]
}],
title: {
text: '{{=T('NAV per Unit') }}'
},
tooltip: {
pointFormat: '<span
style="color:{series.color}">{series.name} : <b>Rp. {point.y:,.4f}</b><br/>'
},
xAxis: {
type: 'datetime',
minRange: 30 * 24 * 3600 * 1000,
dateTimeLabelFormats: {
second: '%Y-%m-%d<br/>%H:%M:%S',
minute: '%Y-%m-%d<br/>%H:%M',
hour: '%Y-%m-%d<br/>%H:%M',
day: '%Y<br/>%m-%d',
week: '%Y<br/>%m-%d',
month: '%Y-%m',
year: '%Y'
}
},
yAxis: {
title: {
text: '{{=T('NAV per Unit') }}'
}
}
}, function (chart) {
// apply the date pickers
setTimeout(function () {
$('input.highcharts-range-selector',
$(chart.container).parent())
.datepicker();
}, 0);
});
});
});
</script>
best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.