Ero sivun ”Widget:XJwCharts” versioiden välillä
Järvi-meriwikistä
Rivi 22: | Rivi 22: | ||
jQuery( '.jwChart' ).each( function() { | jQuery( '.jwChart' ).each( function() { | ||
+ | var memo {}; | ||
var now = new Date(); | var now = new Date(); | ||
− | + | memo.chartEl = jQuery( this ); | |
− | if ( typeof chartEl.prop( 'id' ) == 'undefined' ) { chartEl.prop( 'id', 'jwChart_' + now.getTime() ); } | + | if ( typeof memo.chartEl.prop( 'id' ) == 'undefined' ) { memo.chartEl.prop( 'id', 'jwChart_' + now.getTime() ); } |
− | chartEl.append( '<div class="jwloading"></div>' ); | + | memo.chartEl.append( '<div class="jwloading"></div>' ); |
− | + | memo.jw = new jwApi(); | |
− | jw.loadObses( { 'obscode': 'ice', 'siteid': '284245', 'custom': '[[Jäätilanne::2||5]]' }, function( o ) { | + | memo.jw.loadObses( { 'obscode': 'ice', 'siteid': '284245', 'custom': '[[Jäätilanne::2||5]]' }, function( o ) { |
− | |||
− | |||
− | + | memo.data = {}; | |
var firstW = 3000; lastW = 0; | var firstW = 3000; lastW = 0; | ||
var firstF = 500; var lastB = -500; | var firstF = 500; var lastB = -500; | ||
Rivi 41: | Rivi 40: | ||
var cnewyear = new Date( now.getFullYear()+1, 0, 1 ); | var cnewyear = new Date( now.getFullYear()+1, 0, 1 ); | ||
− | for ( var o in jw.obsList ) { | + | for ( var o in memo.jw.obsList ) { |
− | var obs = jw.obs[ jw.obsList [ o ] ]; | + | var obs = memo.jw.obs[ jw.obsList [ o ] ]; |
obs.data = JSON.parse( obs.printouts.DataJSON ); | obs.data = JSON.parse( obs.printouts.DataJSON ); | ||
Rivi 95: | Rivi 94: | ||
} | } | ||
− | + | memo.dataTable = new google.visualization.DataTable(); | |
− | dataTable.addColumn( 'number', 'Winter' ); | + | memo.dataTable.addColumn( 'number', 'Winter' ); |
− | dataTable.addColumn( 'date', 'Freezing' ); | + | memo.dataTable.addColumn( 'date', 'Freezing' ); |
− | dataTable.addColumn( 'date', 'Freezing' ); | + | memo.dataTable.addColumn( 'date', 'Freezing' ); |
− | dataTable.addColumn( 'date', 'Ice break-up' ); | + | memo.dataTable.addColumn( 'date', 'Ice break-up' ); |
− | dataTable.addColumn( 'date', 'Ice break-up' ); | + | memo.dataTable.addColumn( 'date', 'Ice break-up' ); |
− | dataTable.addColumn({ role: 'tooltip'}); | + | memo.dataTable.addColumn({ role: 'tooltip'}); |
− | dataTable.addColumn({ role: 'annotation' } ); | + | memo.dataTable.addColumn({ role: 'annotation' } ); |
− | dataTable.addRows( table ); | + | memo.dataTable.addRows( table ); |
− | + | memo.options = { | |
legend: 'none', | legend: 'none', | ||
hAxis: { slantedText: false, maxAlternation: 1, format: '####' }, | hAxis: { slantedText: false, maxAlternation: 1, format: '####' }, | ||
Rivi 112: | Rivi 111: | ||
}; | }; | ||
− | + | memo.chart = new google.visualization.CandlestickChart( chartEl[0] ); | |
− | + | memo.chart.draw( memo.dataTable, memo.options); | |
− | + | memo.chartEl.find( '.jwloading' ).remove(); | |
− | chart.draw( dataTable, options); | ||
− | |||
− | |||
}); | }); |