1
0
Fork 0

Highlight max values on line charts

This commit is contained in:
Gregory Eremin 2016-01-10 17:29:23 +03:00
parent 51be9ed2d1
commit a8cab895db
1 changed files with 15 additions and 0 deletions

View File

@ -210,6 +210,13 @@ var LineChart = React.createClass({
return [x, y]; return [x, y];
}); });
var numMaxPoints = points.map(function(point, i) {
var val = point[key];
return val === max ? 1 : 0;
}).reduce(function(sum, val) {
return sum + val;
});
var path = npoints.map(function(point, i) { var path = npoints.map(function(point, i) {
var x = point[0], y = point[1]; var x = point[0], y = point[1];
@ -224,6 +231,14 @@ var LineChart = React.createClass({
var x = point[0], y = point[1]; var x = point[0], y = point[1];
var r = 2; // Radius var r = 2; // Radius
// Hide leftmost and zero points
if (x === paddingLeft || y === height - paddingBottom) {
r = 0;
}
// Highlight max values if less then 50% of values are max
if (y == paddingTop && numMaxPoints / points.length < .5) {
r = 4;
}
return <circle key={"dot-"+ i} return <circle key={"dot-"+ i}
cx={x} cx={x}