Skip to content

Commit fe5f376

Browse files
committed
1.7.0
1 parent cbbf36b commit fe5f376

File tree

5 files changed

+63
-35
lines changed

5 files changed

+63
-35
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rickshaw",
3-
"version": "1.6.6",
3+
"version": "1.7.0",
44
"description": "Rickshaw is a JavaScript toolkit for creating interactive time series graphs.",
55
"main": [
66
"./rickshaw.js",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rickshaw",
3-
"version": "1.6.6",
3+
"version": "1.7.0",
44
"homepage": "https://shutterstock.github.io/rickshaw/",
55
"dependencies": {
66
"d3": "^3.5.16"

rickshaw.js

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/* jshint -W079 */
1313

1414
var Rickshaw = {
15-
version: '1.6.6',
15+
version: '1.7.0',
1616

1717
namespace: function(namespace, obj) {
1818

@@ -1167,25 +1167,25 @@ Rickshaw.namespace('Rickshaw.Fixtures.Number');
11671167

11681168
Rickshaw.Fixtures.Number.formatKMBT = function(y) {
11691169
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 }
11771177
};
11781178

11791179
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 }
11891189
};
11901190
Rickshaw.namespace("Rickshaw.Color.Palette");
11911191

@@ -1510,6 +1510,7 @@ Rickshaw.Graph.Axis.X = function(args) {
15101510

15111511
this.graph = args.graph;
15121512
this.orientation = args.orientation || 'top';
1513+
this.color = args.color || "#000000";
15131514

15141515
this.pixelsPerTick = args.pixelsPerTick || 75;
15151516
if (args.ticks) this.staticTicks = args.ticks;
@@ -1527,6 +1528,7 @@ Rickshaw.Graph.Axis.X = function(args) {
15271528
.append("svg:svg")
15281529
.attr('height', this.height)
15291530
.attr('width', this.width)
1531+
.attr('stroke', this.color)
15301532
.attr('class', 'rickshaw_graph x_axis_d3');
15311533

15321534
this.element = this.vis[0][0];
@@ -1627,6 +1629,7 @@ Rickshaw.Graph.Axis.Y = Rickshaw.Class.create( {
16271629

16281630
this.graph = args.graph;
16291631
this.orientation = args.orientation || 'right';
1632+
this.color = args.color || "#000000";
16301633

16311634
this.pixelsPerTick = args.pixelsPerTick || 75;
16321635
if (args.ticks) this.staticTicks = args.ticks;
@@ -1644,6 +1647,7 @@ Rickshaw.Graph.Axis.Y = Rickshaw.Class.create( {
16441647
this.element = args.element;
16451648
this.vis = d3.select(args.element)
16461649
.append("svg:svg")
1650+
.attr('stroke', this.color)
16471651
.attr('class', 'rickshaw_graph y_axis');
16481652

16491653
this.element = this.vis[0][0];
@@ -1805,13 +1809,23 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
18051809

18061810
var self = this;
18071811

1808-
var colorSafe = {};
1812+
var propertiesSafe = {};
18091813
var activeLine = null;
18101814

18111815
var disabledColor = args.disabledColor || function(seriesColor) {
18121816
return d3.interpolateRgb(seriesColor, d3.rgb('#d8d8d8'))(0.8).toString();
18131817
};
18141818

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+
18151829
this.addHighlightEvents = function (l) {
18161830

18171831
l.element.addEventListener( 'mouseover', function(e) {
@@ -1820,8 +1834,11 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
18201834
else activeLine = l;
18211835

18221836
self.legend.lines.forEach( function(line) {
1837+
var newProperties;
1838+
var isActive = false;
18231839

18241840
if (l === line) {
1841+
isActive = true;
18251842

18261843
// if we're not in a stacked renderer bring active line to the top
18271844
if (self.graph.renderer.unstack && (line.series.renderer ? line.series.renderer.unstack : true)) {
@@ -1832,11 +1849,21 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
18321849
var series = self.graph.series.splice(seriesIndex, 1)[0];
18331850
self.graph.series.push(series);
18341851
}
1835-
return;
18361852
}
18371853

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+
}
18401867

18411868
} );
18421869

@@ -1859,8 +1886,10 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
18591886
delete line.originalIndex;
18601887
}
18611888

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;
18641893
}
18651894
} );
18661895

@@ -2484,6 +2513,7 @@ Rickshaw.Graph.Legend = Rickshaw.Class.create( {
24842513
this.element = args.element;
24852514
this.graph = args.graph;
24862515
this.naturalOrder = args.naturalOrder;
2516+
this.colorKey = args.colorKey || 'color';
24872517

24882518
this.element.classList.add(this.className);
24892519

@@ -2531,7 +2561,7 @@ Rickshaw.Graph.Legend = Rickshaw.Class.create( {
25312561
}
25322562
var swatch = document.createElement('div');
25332563
swatch.className = 'swatch';
2534-
swatch.style.backgroundColor = series.color;
2564+
swatch.style.backgroundColor = series[this.colorKey];
25352565

25362566
line.appendChild(swatch);
25372567

@@ -2560,7 +2590,6 @@ Rickshaw.Graph.Legend = Rickshaw.Class.create( {
25602590
return line;
25612591
}
25622592
} );
2563-
25642593
Rickshaw.namespace('Rickshaw.Graph.RangeSlider');
25652594

25662595
Rickshaw.Graph.RangeSlider = Rickshaw.Class.create({
@@ -3320,7 +3349,7 @@ Rickshaw.Graph.Renderer = Rickshaw.Class.create( {
33203349
var fill = this.fill ? series.color : 'none';
33213350
var stroke = this.stroke ? series.color : 'none';
33223351
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;
33243353

33253354
series.path.setAttribute('fill', fill);
33263355
series.path.setAttribute('stroke', stroke);
@@ -3379,7 +3408,6 @@ Rickshaw.Graph.Renderer = Rickshaw.Class.create( {
33793408
}
33803409
}
33813410
} );
3382-
33833411
Rickshaw.namespace('Rickshaw.Graph.Renderer.Line');
33843412

33853413
Rickshaw.Graph.Renderer.Line = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
@@ -3696,7 +3724,7 @@ Rickshaw.Graph.Renderer.ScatterPlot = Rickshaw.Class.create( Rickshaw.Graph.Rend
36963724
series.forEach( function(series) {
36973725

36983726
if (series.disabled) return;
3699-
var opacity = series.opacity ? series.opacity : 1;
3727+
var opacity = series.opacity === undefined ? 1 : series.opacity;
37003728

37013729
var nodes = vis.selectAll("path")
37023730
.data(series.stack.filter( function(d) { return d.y !== null } ))
@@ -3708,7 +3736,7 @@ Rickshaw.Graph.Renderer.ScatterPlot = Rickshaw.Class.create( Rickshaw.Graph.Rend
37083736
if (series.className) {
37093737
nodes.classed(series.className, true);
37103738
}
3711-
3739+
37123740
Array.prototype.forEach.call(nodes[0], function(n) {
37133741
n.setAttribute('fill', series.color);
37143742
} );

rickshaw.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/Rickshaw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* jshint -W079 */
22

33
var Rickshaw = {
4-
version: '1.6.6',
4+
version: '1.7.0',
55

66
namespace: function(namespace, obj) {
77

0 commit comments

Comments
 (0)