Changeset 20863
- Timestamp:
- 07/06/16 12:02:49 (9 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/Makefile.am
r20811 r20863 146 146 ${ISSM_DIR}/src/m/parameterization/setmask.js \ 147 147 ${ISSM_DIR}/src/m/plot/slider.js \ 148 ${ISSM_DIR}/src/m/plot/tooltips.js \149 148 ${ISSM_DIR}/src/m/plot/applyoptions.js \ 150 149 ${ISSM_DIR}/src/m/plot/checkplotoptions.js \ -
issm/trunk-jpl/src/m/plot/applyoptions.js
r20833 r20863 16 16 //Variable options initialization {{{ 17 17 var caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]); 18 var colorbarorientiation = options.getfieldvalue('colorbarorientation','vertical');19 18 var colorbarinnerlabels = options.getfieldvalue('colorbarinnerlabels','off'); 20 var cheightoffset = options.getfieldvalue('colorbarfontsize',18)*options.getfieldvalue('colorbarheight',1);21 19 var ccanvasid,ctitleid,clabelsid,ccanvas,ctitle,clabels,ccontext,cmap,colorbar,cwidth,cheight,cgradient,color,y,x; 22 20 //}}} … … 29 27 for (var i=cdivisions; i >= 0; i--) { 30 28 var scale = (Math.log10(caxis[1])-Math.log10(caxis[0]))/Math.log10(options.getfieldvalue('log',10)); 31 labels[i] = (Math.pow(options.getfieldvalue('log',10),Math.log10(caxis[0])/Math.log10(options.getfieldvalue('log',10))+scale*(cdivisions-i)/cdivisions)).to Precision(precision);29 labels[i] = (Math.pow(options.getfieldvalue('log',10),Math.log10(caxis[0])/Math.log10(options.getfieldvalue('log',10))+scale*(cdivisions-i)/cdivisions)).toFixed(precision); 32 30 } 33 31 } else { 34 32 for (var i=cdivisions; i >= 0; i--) { 35 labels[i] = (caxisdelta*(cdivisions-i)/cdivisions+caxis[0]).to Precision(precision);33 labels[i] = (caxisdelta*(cdivisions-i)/cdivisions+caxis[0]).toFixed(precision); 36 34 } 37 35 } //}}} 38 36 //Initialize colorbar canvas {{{ 39 37 40 ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid') +'-colorbar');38 ccanvasid = options.getfieldvalue('colorbarid',options.getfieldvalue('canvasid').replace('canvas','colorbar-canvas')); 41 39 ccanvas = $('#'+ccanvasid)[0]; 42 40 cwidth = ccanvas.width*options.getfieldvalue('colorbarwidth',1); 43 41 cheight = ccanvas.height*options.getfieldvalue('colorbarheight',1); 44 ccanvas.width = cwidth;45 ccanvas.height = cheight;42 //ccanvas.width = cwidth; 43 //ccanvas.height = cheight; 46 44 ccontext = ccanvas.getContext('2d'); 47 45 ccontext.clearRect(0,0, cwidth, cheight); … … 49 47 cmap = options.getfieldvalue('colormap','jet'); 50 48 colorbar = colorbars[cmap]; 51 cgradient = ccontext.createLinearGradient(0, cheightoffset/2,0,cheight);49 cgradient = ccontext.createLinearGradient(0,0,0,cheight); 52 50 //}}} 53 51 //Draw colorbar gradient {{{ … … 68 66 //}}} 69 67 //Draw colorbar labels {{{ 70 clabelsid = options.getfieldvalue('colorbarid', options.getfieldvalue('canvasid')+'-colorbar')+'-labels';68 clabelsid = options.getfieldvalue('colorbarid', ccanvasid).replace('canvas','labels'); 71 69 clabels = $('#'+clabelsid); 72 clabels.height(cheight);73 clabels.css({'color':options.getfieldvalue('colorbarfontcolor','black'), 'font-size':options.getfieldvalue('colorbarfontsize',18)+'px'});70 //clabels.height(cheight); 71 //clabels.css({'color':options.getfieldvalue('colorbarfontcolor','black'), 'font-size':options.getfieldvalue('colorbarfontsize',18)+'px'}); 74 72 if (colorbarinnerlabels=='on') { 75 73 clabels.removeClass('sim-colorbar-labels-outer'); … … 83 81 clabels.empty(); 84 82 for (var i=0; i <= cdivisions; i++) { 85 y = i/(cdivisions+1)*cheight;83 y = (i+0.5)/(cdivisions+1)*cheight; 86 84 x = 0.2*cwidth; 87 85 clabelstring += '<li><span>'+labels[i]+'</span></li>'; 88 86 ccontext.beginPath(); 89 ccontext.moveTo(0,y +cheightoffset*1);90 ccontext.lineTo(x,y +cheightoffset*1);91 ccontext.moveTo(cwidth-x,y +cheightoffset*1);92 ccontext.lineTo(cwidth,y +cheightoffset*1);87 ccontext.moveTo(0,y); 88 ccontext.lineTo(x,y); 89 ccontext.moveTo(cwidth-x,y); 90 ccontext.lineTo(cwidth,y); 93 91 ccontext.stroke(); 94 92 } … … 96 94 //}}} 97 95 //Draw colorbar title {{{ 98 ctitleid = options.getfieldvalue('colorbarid', options.getfieldvalue('canvasid')+'-colorbar')+'-title';96 ctitleid = options.getfieldvalue('colorbarid', ccanvasid).replace('canvas','heading'); 99 97 ctitle = $('#'+ctitleid); 100 ctitle.width(cwidth);98 //ctitle.width(cwidth); 101 99 if (options.exist('colorbartitle')) { 102 100 ctitle.html(options.getfieldvalue('colorbartitle')); 103 ctitle.css({'color':options.getfieldvalue('colorbarfontcolor','black'), 'font-size':options.getfieldvalue('colorbarfontsize',18)+'px'});101 //ctitle.css({'color':options.getfieldvalue('colorbarfontcolor','black'), 'font-size':options.getfieldvalue('colorbarfontsize',18)+'px'}); 104 102 } //}}} 105 103 } -
issm/trunk-jpl/src/m/plot/gauge.js
r20748 r20863 1 function gauge() { 2 //GAGUE - create a gague and label that display a value with unit label 3 // 4 // Usage: 5 // gaugeslr = gauge('gaugediv','slr-controldiv','label','m'); 1 /* 2 References: https://bernii.github.io/gauge.js/ 3 */ 4 function gaugeInit(){ 5 6 // Convert arguments to options. 7 var args = Array.prototype.slice.call(arguments); 8 var options = new pairoptions(args); 9 10 // Recover option values. 11 var canvasId = options.getfieldvalue('canvasId', 'sim-gauge-canvas'); 12 var textFieldId = options.getfieldvalue('textFieldId', 'gauge-text'); 13 var value = options.getfieldvalue('value', 0); 14 var max = options.getfieldvalue('max', 22); 15 var colors = options.getfieldvalue('colors', [[0.0, "#FFFF00"], 16 [0.50, "#FF8000"], 17 [1.0, "#FF0000"]]); 6 18 7 //Convert arguments to options 8 var args = Array.prototype.slice.call(arguments); 9 var options = new pairoptions(args); 10 11 gaugecanvas = options.getfieldvalue('gaugecanvas','gauge'); 12 gaugetext = options.getfieldvalue('gaugetext','gauge-text'); 13 gaugediv = options.getfieldvalue('gaugediv','slr-controldiv'); 14 gaugevalue = options.getfieldvalue('value',0); 15 min = options.getfieldvalue('min',0); 16 max = options.getfieldvalue('max',22); 17 colors = options.getfieldvalue('colors',[[0.0, "#000000" ], [0.50, "#880000"], [1.0, "#ff0000"]]); 18 label = options.getfieldvalue('label',''); 19 // Construct associative array of options. 20 var opts = { 21 lines: 12, // The number of lines to draw 22 angle: 0, // The length of each line 23 lineWidth: 0.39, // The line thickness 24 25 pointer: { 26 length: 0, // The radius of the inner circle 27 strokeWidth: 0, // The rotation offset 28 color: '#000000' // Fill color 29 }, 30 31 limitMax: 'false', // If true, the pointer will not go past the end of the gauge 32 percentColors: colors, 33 strokeColor: '#E0E0E0', // to see which ones work best for you 34 generateGradient: true 35 }; 19 36 20 $('<div class="bordered margin-8 padding-8"><canvas id="'+gaugecanvas+'" width="100px" height="50%" class="gauge-canvas"></canvas><div id="'+gaugetext+'" class="gauge-text"></div></div>').appendTo('#'+gaugediv); 37 // Create new gauge. 38 var newGauge = new Gauge(document.getElementById(canvasId)).setOptions(opts); 21 39 22 var opts = { 23 lines: 12, // The number of lines to draw 24 angle: 0, // The length of each line 25 lineWidth: 0.38, // The line thickness 26 pointer: { 27 length: 0, // The radius of the inner circle 28 strokeWidth: 0, // The rotation offset 29 color: '#000000' // Fill color 30 }, 31 limitMax: 'false', // If true, the pointer will not go past the end of the gauge 32 colorStart: '#6F6EA0', // Colors 33 colorStop: '#C0C0DB', // just experiment with them 34 strokeColor: '#EEEEEE', // to see which ones work best for you 35 percentColors: colors, 36 generateGradient: true 37 }; 38 var target = document.getElementById(gaugecanvas) 39 var gauge = new Gauge(target).setOptions(opts); 40 gauge.setTextField(document.getElementById(gaugetext)); 41 gauge.label = label; 42 gauge.textField.render = function(gauge) { 43 return this.el.innerHTML = gauge.displayedValue.toFixed(0) + ' ' + gauge.label; 40 // Bind text field to gauge. 41 newGauge.setTextField(document.getElementById(textFieldId)); 42 43 newGauge.textField.render = function(newGauge){ 44 return this.el.innerHTML = newGauge.displayedValue.toFixed(0); 44 45 }; 45 gauge.minValue = min; 46 gauge.maxValue= max;47 gauge.animationSpeed= 1;48 gauge.set(1); // set once to initialize?49 gauge.set(gaugevalue);// set actual value46 47 newGauge.maxValue = max; 48 newGauge.animationSpeed = 1; 49 newGauge.set(1); // Somehow this prevents pointer from rendering on initialization. 50 newGauge.set(value); // set actual value 50 51 51 return gauge;52 return newGauge; 52 53 } 54 /* exported gaugeInit, refreshErrorMessages */ -
issm/trunk-jpl/src/m/plot/slider.js
r20823 r20863 92 92 93 93 $(selector).appendTo(selector + '-value'); 94 95 /* 96 NOTE: Slider must be "refreshed" after any JavaScript change to it, as 97 it is an AJAX object. 98 */ 94 99 $(selector).slider('refresh'); 95 100 } 101 /* exported sliderMoveInput, refreshErrorMessages */ 96 102 97 /* 98 value/label updated by node transient runs in plot_unit. 99 */ 103 100 104 function progressInit(){ 101 105 … … 111 115 var playButton = $(sim + '-controls-button-play'); 112 116 var reverseButton = $(sim + '-controls-button-reverse'); 113 var timeText = $(sim + '-controls- text-time');117 var timeText = $(sim + '-controls-progress-time'); 114 118 115 119 /* 116 Update progress barslider attributes.120 Update slider attributes. 117 121 118 122 NOTE: Although slider has already been created, need to call slider() … … 164 168 }); 165 169 166 reverseButton.click(function(){167 canvas.movieReverse = !canvas.movieReverse;168 if (canvas.movieReverse) {169 reverseButton.find("span").removeClass("fa-backward");170 reverseButton.find("span").addClass("fa-forward");171 }172 else {173 reverseButton.find("span").removeClass("fa-forward");174 reverseButton.find("span").addClass("fa-backward");175 }176 });177 178 170 canvas.timeLabel = timeText; 179 171 } 172 /* exported progressInit, refreshErrorMessages */
Note:
See TracChangeset
for help on using the changeset viewer.