Changeset 907e4ce934b70871cb0b706d166983f75f94f0ef
- Timestamp:
- 03/20/09 13:06:38
(9 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1237554398 +0000
- git-parent:
[e87b8b78cb0434e48ee9292152bb547ba908f391]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1237554398 +0000
- Message:
auto scale the right axis too
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
re87b8b7 |
r907e4ce |
|
139 | 139 | var doptions, dplaceholder, ddata; |
---|
140 | 140 | |
---|
| 141 | function ytickformatter (ddata, axisidx) { |
---|
| 142 | return function(val,axis) { |
---|
| 143 | for(var i=0; i<ddata.length; i++) { |
---|
| 144 | if(ddata[i].yaxis == axisidx && |
---|
| 145 | ddata[i].reconnoiter_display_expression) { |
---|
| 146 | var meta = { _max: Math.max(Math.abs(axis.datamax), |
---|
| 147 | Math.abs(axis.datamin)), |
---|
| 148 | // for delta calc, we don't want to |
---|
| 149 | // lose precision |
---|
| 150 | floor: ['.'], ciel: ['.'], round: ['~','.'] |
---|
| 151 | }, |
---|
| 152 | pval = rpn_eval(val, ddata[i].reconnoiter_display_expression, meta); |
---|
| 153 | if((val > 0 && pval < 0) || |
---|
| 154 | (val < 0 && pval > 0)) { |
---|
| 155 | // Sign inversion means we're being clever and using |
---|
| 156 | // the negative axis as a positive one. |
---|
| 157 | pval = Math.abs(pval); |
---|
| 158 | } |
---|
| 159 | return pval.toFixed(axis.tickDecimals) + |
---|
| 160 | ((meta.suffix != null) ? meta.suffix : ''); |
---|
| 161 | } |
---|
| 162 | } |
---|
| 163 | return val.toFixed(axis.tickDecimals); |
---|
| 164 | } |
---|
| 165 | } |
---|
| 166 | |
---|
141 | 167 | return { |
---|
142 | 168 | init: |
---|
… | … | |
322 | 348 | }; |
---|
323 | 349 | })(this)); |
---|
| 350 | dplaceholder = placeholder; |
---|
| 351 | |
---|
| 352 | for(var i=0; i<r.data.length; i++) { |
---|
| 353 | if(r.data[i].reconnoiter_display_expression) |
---|
| 354 | r.data[i].dataManip = rpn_magic(r.data[i].reconnoiter_display_expression); |
---|
| 355 | } |
---|
| 356 | ddata = r.data; |
---|
324 | 357 | |
---|
325 | 358 | if(!r.options.grid) r.options.grid = {}; |
---|
… | … | |
333 | 366 | r.options.points.radius = 2; |
---|
334 | 367 | if(!r.options.yaxis) r.options.yaxis = {}; |
---|
335 | | r.options.yaxis.tickFormatter = function (val, axis) { |
---|
336 | | for(var i=0; i<ddata.length; i++) { |
---|
337 | | if(ddata[i].yaxis == 1 && |
---|
338 | | ddata[i].reconnoiter_display_expression) { |
---|
339 | | var meta = { _max: Math.max(Math.abs(axis.datamax), |
---|
340 | | Math.abs(axis.datamin)), |
---|
341 | | // for delta calc, we don't want to |
---|
342 | | // lose precision |
---|
343 | | floor: ['.'], ciel: ['.'], round: ['~','.'] |
---|
344 | | }, |
---|
345 | | pval = rpn_eval(val, ddata[i].reconnoiter_display_expression, meta); |
---|
346 | | if((val > 0 && pval < 0) || |
---|
347 | | (val < 0 && pval > 0)) { |
---|
348 | | // Sign inversion means we're being clever and using |
---|
349 | | // the negative axis as a positive one. |
---|
350 | | pval = Math.abs(pval); |
---|
351 | | } |
---|
352 | | return pval.toFixed(axis.tickDecimals) + |
---|
353 | | ((meta.suffix != null) ? meta.suffix : ''); |
---|
354 | | } |
---|
355 | | } |
---|
356 | | return val.toFixed(axis.tickDecimals); |
---|
357 | | }; |
---|
| 368 | r.options.yaxis.tickFormatter = ytickformatter(ddata, 1); |
---|
| 369 | if(!r.options.y2axis) r.options.y2axis = {}; |
---|
| 370 | r.options.y2axis.tickFormatter = ytickformatter(ddata, 2); |
---|
358 | 371 | r.options.xaxis.localtime = true; |
---|
359 | | |
---|
360 | 372 | doptions = r.options; |
---|
361 | | dplaceholder = placeholder; |
---|
362 | | ddata = r.data; |
---|
363 | | for(var i=0; i<r.data.length; i++) { |
---|
364 | | if(r.data[i].reconnoiter_display_expression) |
---|
365 | | r.data[i].dataManip = rpn_magic(r.data[i].reconnoiter_display_expression); |
---|
366 | | } |
---|
367 | 373 | |
---|
368 | 374 | var plot = this.flot_plot = $.plot(placeholder, r.data, r.options); |
---|