Changeset 1adb126cce45fc884846d696bc04a58e0305df7e
- Timestamp:
- 03/20/09 15:44:11
(9 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1237563851 +0000
- git-parent:
[fab20f2d0270e682d105890980b5ed40a062c39b]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1237563851 +0000
- Message:
use hard colors for background and choose tooltip text color based on luminosity
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
r907e4ce |
r1adb126 |
|
393 | 393 | .html(''); |
---|
394 | 394 | for(var i = 0; i < items.length; i++) { |
---|
395 | | var soft = |
---|
396 | | 'rgb(' + |
---|
397 | | (items[i].series.color.match(/\((.+)\)/))[1] |
---|
398 | | .split(',') |
---|
399 | | .map(function(a) { |
---|
400 | | return Math.round(255-(255-a)*0.1); |
---|
401 | | }) |
---|
402 | | .join(',') + |
---|
403 | | ')'; |
---|
| 395 | var rgb = (items[i].series.color.match(/\((.+)\)/))[1].split(','); |
---|
| 396 | // blend it with white emulating 80% opacity |
---|
| 397 | rgb = rgb.map(function(a) { return Math.round(255-(255-a)*0.8); }); |
---|
| 398 | var soft = 'rgb(' + rgb.join(',') + ')'; |
---|
404 | 399 | var val = items[i].datapoint[1]; |
---|
405 | 400 | if(items[i].series.dataManip) { |
---|
… | … | |
408 | 403 | if(meta.suffix) val = val + meta.suffix; |
---|
409 | 404 | } |
---|
| 405 | |
---|
| 406 | // I want Y of YUV... for text color selection |
---|
| 407 | // if Y [0,255], if high (>128) I want black, else white |
---|
| 408 | |
---|
| 409 | var Y = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]; |
---|
410 | 410 | var tt = $('<div><div/>') |
---|
411 | 411 | .html((items[i].datapoint[2] ? items[i].datapoint[2] : val) + " (" + items[i].series.label + ")") |
---|
412 | | .css( { backgroundColor: soft }); |
---|
| 412 | .css( { color: ( Y > 128 ? 'black' : 'white' ), backgroundColor: soft }); |
---|
413 | 413 | tt.appendTo($("div.tooltip")); |
---|
414 | 414 | hoverings.push(items[i]); |
---|