12
12
/* jshint -W079 */
13
13
14
14
var Rickshaw = {
15
- version : '1.6.6 ' ,
15
+ version : '1.7.0 ' ,
16
16
17
17
namespace : function ( namespace , obj ) {
18
18
@@ -1167,25 +1167,25 @@ Rickshaw.namespace('Rickshaw.Fixtures.Number');
1167
1167
1168
1168
Rickshaw . Fixtures . Number . formatKMBT = function ( y ) {
1169
1169
var abs_y = Math . abs ( y ) ;
1170
- if ( abs_y >= 1000000000000 ) { return y / 1000000000000 + "T" }
1171
- else if ( abs_y >= 1000000000 ) { return y / 1000000000 + "B" }
1172
- else if ( abs_y >= 1000000 ) { return y / 1000000 + "M" }
1173
- else if ( abs_y >= 1000 ) { return y / 1000 + "K" }
1174
- else if ( abs_y < 1 && abs_y > 0 ) { return y . toFixed ( 2 ) }
1175
- else if ( abs_y === 0 ) { return '' }
1176
- else { return y }
1170
+ if ( abs_y >= 1000000000000 ) { return ( y / 1000000000000 ) . toFixed ( 2 ) + "T" }
1171
+ else if ( abs_y >= 1000000000 ) { return ( y / 1000000000 ) . toFixed ( 2 ) + "B" }
1172
+ else if ( abs_y >= 1000000 ) { return ( y / 1000000 ) . toFixed ( 2 ) + "M" }
1173
+ else if ( abs_y >= 1000 ) { return ( y / 1000 ) . toFixed ( 2 ) + "K" }
1174
+ else if ( abs_y < 1 && abs_y > 0 ) { return y . toFixed ( 2 ) }
1175
+ else if ( abs_y === 0 ) { return '0 ' }
1176
+ else { return y }
1177
1177
} ;
1178
1178
1179
1179
Rickshaw . Fixtures . Number . formatBase1024KMGTP = function ( y ) {
1180
- var abs_y = Math . abs ( y ) ;
1181
- if ( abs_y >= 1125899906842624 ) { return y / 1125899906842624 + "P" }
1182
- else if ( abs_y >= 1099511627776 ) { return y / 1099511627776 + "T" }
1183
- else if ( abs_y >= 1073741824 ) { return y / 1073741824 + "G" }
1184
- else if ( abs_y >= 1048576 ) { return y / 1048576 + "M" }
1185
- else if ( abs_y >= 1024 ) { return y / 1024 + "K" }
1186
- else if ( abs_y < 1 && abs_y > 0 ) { return y . toFixed ( 2 ) }
1187
- else if ( abs_y === 0 ) { return '' }
1188
- else { return y }
1180
+ var abs_y = Math . abs ( y ) ;
1181
+ if ( abs_y >= 1125899906842624 ) { return ( y / 1125899906842624 ) . toFixed ( 2 ) + "P" }
1182
+ else if ( abs_y >= 1099511627776 ) { return ( y / 1099511627776 ) . toFixed ( 2 ) + "T" }
1183
+ else if ( abs_y >= 1073741824 ) { return ( y / 1073741824 ) . toFixed ( 2 ) + "G" }
1184
+ else if ( abs_y >= 1048576 ) { return ( y / 1048576 ) . toFixed ( 2 ) + "M" }
1185
+ else if ( abs_y >= 1024 ) { return ( y / 1024 ) . toFixed ( 2 ) + "K" }
1186
+ else if ( abs_y < 1 && abs_y > 0 ) { return y . toFixed ( 2 ) }
1187
+ else if ( abs_y === 0 ) { return '0 ' }
1188
+ else { return y }
1189
1189
} ;
1190
1190
Rickshaw . namespace ( "Rickshaw.Color.Palette" ) ;
1191
1191
@@ -1510,6 +1510,7 @@ Rickshaw.Graph.Axis.X = function(args) {
1510
1510
1511
1511
this . graph = args . graph ;
1512
1512
this . orientation = args . orientation || 'top' ;
1513
+ this . color = args . color || "#000000" ;
1513
1514
1514
1515
this . pixelsPerTick = args . pixelsPerTick || 75 ;
1515
1516
if ( args . ticks ) this . staticTicks = args . ticks ;
@@ -1527,6 +1528,7 @@ Rickshaw.Graph.Axis.X = function(args) {
1527
1528
. append ( "svg:svg" )
1528
1529
. attr ( 'height' , this . height )
1529
1530
. attr ( 'width' , this . width )
1531
+ . attr ( 'stroke' , this . color )
1530
1532
. attr ( 'class' , 'rickshaw_graph x_axis_d3' ) ;
1531
1533
1532
1534
this . element = this . vis [ 0 ] [ 0 ] ;
@@ -1627,6 +1629,7 @@ Rickshaw.Graph.Axis.Y = Rickshaw.Class.create( {
1627
1629
1628
1630
this . graph = args . graph ;
1629
1631
this . orientation = args . orientation || 'right' ;
1632
+ this . color = args . color || "#000000" ;
1630
1633
1631
1634
this . pixelsPerTick = args . pixelsPerTick || 75 ;
1632
1635
if ( args . ticks ) this . staticTicks = args . ticks ;
@@ -1644,6 +1647,7 @@ Rickshaw.Graph.Axis.Y = Rickshaw.Class.create( {
1644
1647
this . element = args . element ;
1645
1648
this . vis = d3 . select ( args . element )
1646
1649
. append ( "svg:svg" )
1650
+ . attr ( 'stroke' , this . color )
1647
1651
. attr ( 'class' , 'rickshaw_graph y_axis' ) ;
1648
1652
1649
1653
this . element = this . vis [ 0 ] [ 0 ] ;
@@ -1805,13 +1809,23 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
1805
1809
1806
1810
var self = this ;
1807
1811
1808
- var colorSafe = { } ;
1812
+ var propertiesSafe = { } ;
1809
1813
var activeLine = null ;
1810
1814
1811
1815
var disabledColor = args . disabledColor || function ( seriesColor ) {
1812
1816
return d3 . interpolateRgb ( seriesColor , d3 . rgb ( '#d8d8d8' ) ) ( 0.8 ) . toString ( ) ;
1813
1817
} ;
1814
1818
1819
+ var transformFn = args . transform || function ( isActive , series ) {
1820
+ var newProperties = { } ;
1821
+ if ( ! isActive ) {
1822
+ // backwards compability
1823
+ newProperties . color = disabledColor ( series . color ) ;
1824
+ }
1825
+ return newProperties ;
1826
+ } ;
1827
+
1828
+
1815
1829
this . addHighlightEvents = function ( l ) {
1816
1830
1817
1831
l . element . addEventListener ( 'mouseover' , function ( e ) {
@@ -1820,8 +1834,11 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
1820
1834
else activeLine = l ;
1821
1835
1822
1836
self . legend . lines . forEach ( function ( line ) {
1837
+ var newProperties ;
1838
+ var isActive = false ;
1823
1839
1824
1840
if ( l === line ) {
1841
+ isActive = true ;
1825
1842
1826
1843
// if we're not in a stacked renderer bring active line to the top
1827
1844
if ( self . graph . renderer . unstack && ( line . series . renderer ? line . series . renderer . unstack : true ) ) {
@@ -1832,11 +1849,21 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
1832
1849
var series = self . graph . series . splice ( seriesIndex , 1 ) [ 0 ] ;
1833
1850
self . graph . series . push ( series ) ;
1834
1851
}
1835
- return ;
1836
1852
}
1837
1853
1838
- colorSafe [ line . series . name ] = colorSafe [ line . series . name ] || line . series . color ;
1839
- line . series . color = disabledColor ( line . series . color ) ;
1854
+ newProperties = transformFn ( isActive , line . series ) ;
1855
+
1856
+ propertiesSafe [ line . series . name ] = propertiesSafe [ line . series . name ] || {
1857
+ color : line . series . color ,
1858
+ stroke : line . series . stroke
1859
+ } ;
1860
+
1861
+ if ( newProperties . color ) {
1862
+ line . series . color = newProperties . color ;
1863
+ }
1864
+ if ( newProperties . stroke ) {
1865
+ line . series . stroke = newProperties . stroke ;
1866
+ }
1840
1867
1841
1868
} ) ;
1842
1869
@@ -1859,8 +1886,10 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
1859
1886
delete line . originalIndex ;
1860
1887
}
1861
1888
1862
- if ( colorSafe [ line . series . name ] ) {
1863
- line . series . color = colorSafe [ line . series . name ] ;
1889
+ var lineProperties = propertiesSafe [ line . series . name ] ;
1890
+ if ( lineProperties ) {
1891
+ line . series . color = lineProperties . color ;
1892
+ line . series . stroke = lineProperties . stroke ;
1864
1893
}
1865
1894
} ) ;
1866
1895
@@ -2484,6 +2513,7 @@ Rickshaw.Graph.Legend = Rickshaw.Class.create( {
2484
2513
this . element = args . element ;
2485
2514
this . graph = args . graph ;
2486
2515
this . naturalOrder = args . naturalOrder ;
2516
+ this . colorKey = args . colorKey || 'color' ;
2487
2517
2488
2518
this . element . classList . add ( this . className ) ;
2489
2519
@@ -2531,7 +2561,7 @@ Rickshaw.Graph.Legend = Rickshaw.Class.create( {
2531
2561
}
2532
2562
var swatch = document . createElement ( 'div' ) ;
2533
2563
swatch . className = 'swatch' ;
2534
- swatch . style . backgroundColor = series . color ;
2564
+ swatch . style . backgroundColor = series [ this . colorKey ] ;
2535
2565
2536
2566
line . appendChild ( swatch ) ;
2537
2567
@@ -2560,7 +2590,6 @@ Rickshaw.Graph.Legend = Rickshaw.Class.create( {
2560
2590
return line ;
2561
2591
}
2562
2592
} ) ;
2563
-
2564
2593
Rickshaw . namespace ( 'Rickshaw.Graph.RangeSlider' ) ;
2565
2594
2566
2595
Rickshaw . Graph . RangeSlider = Rickshaw . Class . create ( {
@@ -3320,7 +3349,7 @@ Rickshaw.Graph.Renderer = Rickshaw.Class.create( {
3320
3349
var fill = this . fill ? series . color : 'none' ;
3321
3350
var stroke = this . stroke ? series . color : 'none' ;
3322
3351
var strokeWidth = series . strokeWidth ? series . strokeWidth : this . strokeWidth ;
3323
- var opacity = series . opacity ? series . opacity : this . opacity ;
3352
+ var opacity = series . opacity === undefined ? this . opacity : series . opacity ;
3324
3353
3325
3354
series . path . setAttribute ( 'fill' , fill ) ;
3326
3355
series . path . setAttribute ( 'stroke' , stroke ) ;
@@ -3379,7 +3408,6 @@ Rickshaw.Graph.Renderer = Rickshaw.Class.create( {
3379
3408
}
3380
3409
}
3381
3410
} ) ;
3382
-
3383
3411
Rickshaw . namespace ( 'Rickshaw.Graph.Renderer.Line' ) ;
3384
3412
3385
3413
Rickshaw . Graph . Renderer . Line = Rickshaw . Class . create ( Rickshaw . Graph . Renderer , {
@@ -3696,7 +3724,7 @@ Rickshaw.Graph.Renderer.ScatterPlot = Rickshaw.Class.create( Rickshaw.Graph.Rend
3696
3724
series . forEach ( function ( series ) {
3697
3725
3698
3726
if ( series . disabled ) return ;
3699
- var opacity = series . opacity ? series . opacity : 1 ;
3727
+ var opacity = series . opacity === undefined ? 1 : series . opacity ;
3700
3728
3701
3729
var nodes = vis . selectAll ( "path" )
3702
3730
. data ( series . stack . filter ( function ( d ) { return d . y !== null } ) )
@@ -3708,7 +3736,7 @@ Rickshaw.Graph.Renderer.ScatterPlot = Rickshaw.Class.create( Rickshaw.Graph.Rend
3708
3736
if ( series . className ) {
3709
3737
nodes . classed ( series . className , true ) ;
3710
3738
}
3711
-
3739
+
3712
3740
Array . prototype . forEach . call ( nodes [ 0 ] , function ( n ) {
3713
3741
n . setAttribute ( 'fill' , series . color ) ;
3714
3742
} ) ;
0 commit comments