Changeset 20748
- Timestamp:
- 06/15/16 22:08:25 (9 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.js
r20652 r20748 1 1 function applyoptions(md,data,datatype,options,canvas,gl,node){ 2 //APPLYOPTIONS - apply theoptions to current plot2 //APPLYOPTIONS - apply colobar, text, cloud, and expdisp options to current plot 3 3 // 4 4 // Usage: … … 16 16 //Variable options initialization {{{ 17 17 var caxis = options.getfieldvalue('caxis',[ArrayMin(data),ArrayMax(data)]); 18 var canvassize = options.getfieldvalue('canvassize',480);19 20 var ccontext,ccanvas,ccanvasid,ccanvashtml,cheight,cwidth,color,y,x;21 18 var colorbarorientiation = options.getfieldvalue('colorbarorientation','vertical'); 22 19 var cheightoffset = options.getfieldvalue('colorbarfontsize',18); … … 24 21 var cwidthscale = 0.5; //Default size of actual colorbar width, relative to canvas width (range [0,1]) 25 22 var cheightscale = 0.875; //Default size of actual colorbar height, relative to canvas height (range [0,1]) 23 var ccontext,ccanvas,ccanvasid,ccanvashtml,cheight,cwidth,color,y,x; 26 24 //}}} 27 25 //Set colorbar lables {{{ … … 31 29 var clabelitem; 32 30 var precision = options.getfieldvalue('colorbarprecision',3); 33 34 31 if (options.getfieldvalue('log','off')!='off') { 35 for (var i =cdivisions; i >= 0; i--) {32 for (var i=cdivisions; i >= 0; i--) { 36 33 var scale = (Math.log10(caxis[1])-Math.log10(caxis[0]))/Math.log10(options.getfieldvalue('log',10)); 37 34 labels[i] = (Math.pow(options.getfieldvalue('log',10),Math.log10(caxis[0])/Math.log10(options.getfieldvalue('log',10))+scale*(cdivisions-i)/cdivisions)).toPrecision(precision); 38 35 } 39 36 } else { 40 for (var i =cdivisions; i >= 0; i--) {37 for (var i=cdivisions; i >= 0; i--) { 41 38 labels[i] = (caxisdelta*(cdivisions-i)/cdivisions+caxis[0]).toPrecision(precision); 42 39 } … … 52 49 ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height); 53 50 ccontext.beginPath(); 54 51 55 52 var cgradient = ccontext.createLinearGradient(0,cheightoffset/2,0,cheight); 56 53 var cmap = options.getfieldvalue('cmap','jet'); 57 54 var colorbar = colorbars[cmap]; 58 for (var i =0; i < colorbar.length; i++) {55 for (var i=0; i < colorbar.length; i++) { 59 56 color = colorbar[colorbar.length-i-1]; 60 57 color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)]; … … 67 64 ccontext.beginPath(); 68 65 ccontext.lineWidth='1'; 69 ccontext.strokeStyle= 'black';66 ccontext.strokeStyle=options.getfieldvalue('colorbarfontcolor','black'); 70 67 ccontext.rect(0,cheightoffset*3/2,cwidth,cheight); 71 68 ccontext.stroke(); 72 69 73 for (var i =0; i <= cdivisions; i++) {70 for (var i=0; i <= cdivisions; i++) { 74 71 y = i/cdivisions*cheight+cheightoffset/2; 75 72 x = 0.2*cwidth; … … 81 78 ccontext.stroke(); 82 79 ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif'; 83 ccontext.fillStyle= 'black';80 ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black'); 84 81 ccontext.textAlign='left'; 85 82 ccontext.fillText(labels[i],cwidth+x,y+cheightoffset*3/2); … … 87 84 if (options.exist('colorbartitle')) { 88 85 ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif'; 89 ccontext.fillStyle= 'black';86 ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black'); 90 87 ccontext.textAlign='left'; 91 88 ccontext.textBaseline='bottom'; … … 94 91 } //}}} 95 92 else { //colorbarorientiation=='horizontal' {{{ 96 cheight = options.getfieldvalue('colorbarheight',canvassize/20);97 cwidth = options.getfieldvalue('colorbarwidth',0.95)*canvassize;98 93 ccanvasid = options.getfieldvalue('colorbarcanvasid',options.getfieldvalue('canvasid')+'_colorbar'); 99 94 ccanvashtml = document.getElementById(ccanvasid); 100 95 cwidth = ccanvashtml.width*0.7*options.getfieldvalue('colorbarwidth',1); 96 cheight = ccanvashtml.height*0.4*options.getfieldvalue('colorbarheight',1); 101 97 ccanvas = $('#'+ccanvasid); 102 cwidth = ccanvashtml.clientWidth;103 cheight = ccanvashtml.clientHeight;104 98 ccontext = ccanvas[0].getContext('2d'); 105 99 ccontext.clearRect(0,0, ccanvashtml.width, ccanvashtml.height); … … 109 103 var cmap = options.getfieldvalue('cmap','jet'); 110 104 var colorbar = colorbars[cmap]; 111 for (var i =0; i < colorbar.length; i++) {105 for (var i=0; i < colorbar.length; i++) { 112 106 color = colorbar[colorbar.length-i-1]; 113 107 color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)]; … … 120 114 ccontext.beginPath(); 121 115 ccontext.lineWidth='1'; 122 ccontext.strokeStyle= 'black';116 ccontext.strokeStyle=options.getfieldvalue('colorbarfontcolor','black'); 123 117 ccontext.rect(cwidthoffset,cheightoffset,cwidth,cheight); 124 118 ccontext.stroke(); 125 119 126 for (var i =0; i <= cdivisions; i++) {120 for (var i=0; i <= cdivisions; i++) { 127 121 y = 0.2*cheight; 128 122 x = i/cdivisions*cwidth; … … 134 128 ccontext.stroke(); 135 129 ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif'; 136 ccontext.fillStyle= 'black';130 ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black'); 137 131 ccontext.textAlign='center'; 138 132 ccontext.fillText(labels[cdivisions-i],x+cwidthoffset,cheight+cheightoffset*2); … … 140 134 if (options.exist('colorbartitle')) { 141 135 ccontext.font=String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif'; 142 ccontext.fillStyle= 'black';136 ccontext.fillStyle=options.getfieldvalue('colorbarfontcolor','black'); 143 137 ccontext.textAlign='center'; 144 138 ccontext.textBaseline='bottom'; … … 167 161 var cmap = options.getfieldvalue('cmap','jet'); 168 162 var colorbar = colorbars[cmap]; 169 for (var i =0; i < colorbar.length; i++) {163 for (var i=0; i < colorbar.length; i++) { 170 164 color = colorbar[colorbar.length-i-1]; 171 165 color = [Math.round(color[0]*255),Math.round(color[1]*255),Math.round(color[2]*255)]; … … 239 233 240 234 vertices.itemSize = 3; 241 for(var i =0; i < x.length; i++){235 for(var i=0; i < x.length; i++){ 242 236 vertices[vertices.length] = x[i]; 243 237 vertices[vertices.length] = y[i]; … … 317 311 318 312 vertices.itemSize = 3; 319 for(var i =0; i < x.length; i++){313 for(var i=0; i < x.length; i++){ 320 314 vertices[vertices.length] = x[i]; 321 315 vertices[vertices.length] = y[i]; … … 368 362 textcoordinates = [(textposition[0]+1.0)/2.0*textcanvaswidth, (-textposition[1]+1.0)/2.0*textcanvasheight]; //NDC to screenspace 369 363 textcontext.font = String(options.getfieldvalue('colorbarfontsize',18))+'px "Lato",Helvetica,Arial,sans-serif'; 370 textcontext.fillStyle = 'black';371 textcontext.strokeStyle = 'black';364 textcontext.fillStyle = options.getfieldvalue('colorbarfontcolor','black'); 365 textcontext.strokeStyle = options.getfieldvalue('colorbarfontcolor','black'); 372 366 textcontext.textAlign = 'center'; 373 367 textcontext.textBaseline = 'middle'; -
issm/trunk-jpl/src/m/plot/gauge.js
r20726 r20748 1 //GAGUE - create a gague and label that display a value2 //3 // Usage:4 // gauge=gauge(); TODO: Expand5 6 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'); 6 7 7 //Convert arguments to options 8 8 var args = Array.prototype.slice.call(arguments); -
issm/trunk-jpl/src/m/plot/plot_manager.js
r20586 r20748 1 1 function plot_manager(md,options,subplotwidth,nlines,ncols,i){ 2 //PLOT__MANAGER - distribute the plots, called by plotmodel3 //4 // Usage:5 // plot_manager(md,options,subplotwidth,i);6 //7 // See also: PLOTMODEL, PLOT_UNIT2 //PLOT__MANAGER - distribute the plots, called by plotmodel 3 // 4 // Usage: 5 // plot_manager(md,options,subplotwidth,i); 6 // 7 // See also: PLOTMODEL, PLOT_UNIT 8 8 9 9 //parse options and get a structure of options. 10 10 checkplotoptions(md,options); 11 11 12 //get data to be displayed 12 13 var data = options.getfieldvalue('data'); -
issm/trunk-jpl/src/m/plot/plot_mesh.js
r20586 r20748 1 1 function plot_mesh(md,options,canvas) { 2 //PLOT_MESH - Function for plotting wireframe mesh. 3 // 2 4 // Usage: 3 5 // plot_mesh(md,options,canvas); 4 6 // 5 // See also: PLOTMODEL 7 // See also: PLOTMODEL, PLOT_MANAGER 6 8 7 9 //declare variables: {{{ -
issm/trunk-jpl/src/m/plot/plot_overlay.js
r20586 r20748 1 1 function plot_overlay(md,data,options,canvas){ 2 2 //PLOT_OVERLAY - Function for plotting a georeferenced image. 3 //This function is called from within the plotmodel code.4 3 // 5 4 // Usage: -
issm/trunk-jpl/src/m/plot/plot_quiver.js
r20586 r20748 5 5 // plot_quiver(md,options,canvas) 6 6 // 7 // See also: PLOTMODEL, PLOT_MANAGER 7 8 8 9 //declare variables: {{{ -
issm/trunk-jpl/src/m/plot/slider.js
r20726 r20748 1 //SLIDER - create a slider bar to set a value 2 // 3 // Usage: 4 // slider=slider(); TODO: Expand 1 function slider() { 2 //SLIDER - Slider bar with initial value, callback on change, unique name, min/max value range, description message, fill color, widht/height, value precision, value step, and the id of the div to create the slider in. 3 // 4 // Usage: 5 // slider('value',0,'callback',function(value){PlotGreenland(value,0);PlotSlr()},'name','greenland','min',0,'max',100,'message',['Remove ice: ','%'],'color','#BBBBBB','width','100%','height','24px','precision',2,'step',5,'slidersdiv','greenland-sliders'); 5 6 6 function slider() {7 7 //Convert arguments to options 8 8 var args = Array.prototype.slice.call(arguments); … … 59 59 } 60 60 61 //PROGRESS - create a progress bar to display a value62 //63 // Usage:64 // progress=progress(); TODO: Expand65 66 61 function progress() { 62 //PROGRESS - Progress bar with initial value, unique name, width/height, and the id of the div to create the slider in. One progress per canvas, value/label updated by node transient runs in plot_unit. 63 // 64 // Usage: 65 // progress('value',0,'name','hma','width','100%','height',sliderheight,'progressdiv','hma-progressdiv'); 66 // 67 // See also: PLOT_UNIT 68 67 69 //Convert arguments to options 68 70 var args = Array.prototype.slice.call(arguments); -
issm/trunk-jpl/src/m/plot/tooltips.js
r20726 r20748 1 //TOOLTIP - create a hidden toolip that shows html formatted info on hover 2 // 3 // Usage: 4 // tooltip=tooltip(); TODO: Expand 1 function tooltip() { 2 //TOOLTIP - create a hidden toolip with value text that shows html formatted info on hover over the tooltipdiv. 3 // 4 // Usage: 5 // tooltip('value','<h4>HAIG Glacier (Canadian Rocky Mountains) 30 year transient simulation</h4>','tooltipdiv','info-tooltipdiv'); 5 6 6 function tooltip() {7 7 //Convert arguments to options 8 8 var args = Array.prototype.slice.call(arguments);
Note:
See TracChangeset
for help on using the changeset viewer.