Ero sivun ”Widget:JwObsCharts” versioiden välillä
Järvi-meriwikistä
Rivi 1 401: | Rivi 1 401: | ||
}); | }); | ||
− | jQuery( window ).resize(function() { | + | jQuery( window ).resize(function() { |
− | + | doResize( memo ); | |
− | |||
− | |||
}); | }); | ||
Rivi 1 418: | Rivi 1 416: | ||
function doResize( memo ) { | function doResize( memo ) { | ||
− | + | ||
− | var w = memo.chartEl.width(); | + | function wait() { |
− | + | ||
+ | var w = memo.chartEl.width(); | ||
+ | var h = memo.chartEl.height(); | ||
− | + | if ( w*h != 0 ) { | |
− | + | memo.margins = { top: 10, right: 10, bottom: 80, left: 80 }; | |
− | + | var w = memo.chartEl.width(); | |
− | + | var h = memo.chartEl.height(); | |
− | + | var l = Math.max( memo.margins.left, 0.1*w ); | |
− | + | var r = Math.max( memo.margins.right, 0.02*w ); | |
− | + | var t = Math.max( memo.margins.top, 0.02*h ); | |
− | + | var b = Math.max( memo.margins.bottom, 0.15*h ); | |
− | + | if (!!document.fullscreenElement) { | |
− | + | //memo.options.chartArea = { top: memo.margins.top*2, left: memo.margins.left*2, width: (memo.widgetEl.width() - memo.margins.left*2 - memo.margins.right - 24), height: (memo.widgetEl.height() - memo.margins.top*2 - memo.margins.bottom*2), backgroundColor: { fill: '#daf0fa', stroke: '#fff', strokeWidth: 6 }}; | |
− | + | } else { | |
− | + | //memo.options.chartArea = { top: memo.margins.top, left: memo.margins.left, width: (memo.widgetEl.width() - memo.margins.left - memo.margins.right), height: (memo.widgetEl.height() - memo.margins.top - memo.margins.bottom), backgroundColor: { fill: '#daf0fa', stroke: '#fff', strokeWidth: 6 }}; | |
− | + | } | |
− | + | //memo.options.chartArea = { top: t, left: l, width: (w - l - r), height: (h - t - b), backgroundColor: { fill: '#daf0fa', stroke: '#fff', strokeWidth: 6 }}; | |
− | + | memo.options.chartArea = { top: t, left: l, width: (w - l - r), height: (h - t - b), backgroundColor: { fill: '#fff', stroke: '#eee', strokeWidth: 4 }}; | |
− | + | //console.log( memo.options ); | |
− | + | memo.chart.draw( memo.data, memo.options ); | |
− | + | // hide every second vaxis gridline on cat charts | |
− | + | if ( i18n[memo.obscode]['type'] == 'cat') { | |
− | + | var glc = 0; | |
− | + | jQuery( document.getElementById(memo.id) ).find( 'rect[height="1"]' ).each( function() { | |
− | + | if ( ( glc++ % 2 ) == 0 ) { | |
− | + | jQuery( this ).attr( 'fill', 'none' ); | |
− | + | } | |
− | + | }); | |
− | + | } | |
− | + | // add dash to trendlines | |
− | + | jQuery( document.getElementById(memo.id) ).find( 'path[stroke-width="2.33"]' ).each( function() { | |
− | + | jQuery( this ).attr('stroke-dasharray', '5, 5'); | |
− | + | }); | |
− | + | // move current observations to top | |
− | + | gEl = jQuery( document.getElementById(memo.id) ).find( 'svg' ).append( 'g' ); | |
− | + | //jQuery( document.getElementById(memo.id) ).find( 'circle[stroke-width="3"]' ).detach().appendTo( gEl ); | |
− | + | jQuery( document.getElementById(memo.id) ).find( 'path[stroke="#3366cc"]' ).detach().appendTo( gEl ); | |
− | + | jQuery( document.getElementById(memo.id) ).find( 'circle[fill="#3366cc"]' ).detach().appendTo( gEl ); | |
− | + | jQuery( document.getElementById(memo.id) ).find( 'circle[stroke-width="3"]' ).each( function() { jQuery( this ).parent().append( jQuery( this ) ); }); | |
− | + | //jQuery( document.getElementById(memo.id) ).find( 'circle[fill="#3366cc"]' ).each( function() { jQuery( this ).parent().append( jQuery( this ) ); }); | |
− | + | //jQuery( document.getElementById(memo.id) ).find( 'path[stroke="#3366cc"]' ).each( function() { jQuery( this ).parent().append( jQuery( this ) ); }); | |
+ | } | ||
} | } | ||
+ | setTimeout( wait, 100 ); | ||
} | } |