Skip to content

Commit

Permalink
Closes #193. Closes #201.
Browse files Browse the repository at this point in the history
  • Loading branch information
stormpython committed Jul 24, 2014
1 parent 44a3547 commit b7cef0c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 76 deletions.
109 changes: 41 additions & 68 deletions src/kibana/components/vislib/modules/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,7 @@ define(function (require) {

selection.each(function (d) {
d.series.forEach(function (label) {
if (label.label) {
items.push(label.label);
} else {
items.push(d.yAxisLabel);
}
items.push(label.label);
});
});

Expand Down Expand Up @@ -487,45 +483,44 @@ define(function (require) {
var testInterval;
var dateoffset;

if (milsInterval >= 86400000 * 364) {
testInterval = 'year';
dateoffset = 1;
}
if (milsInterval < 86400000 * 364) {
testInterval = 'month';
dateoffset = 1;
}
if (milsInterval < 86400000 * 30) {
testInterval = 'week';
dateoffset = (milsInterval / 86400000 * 7);
}
if (milsInterval < 86400000 * 7) {
testInterval = 'day';
dateoffset = (milsInterval / 86400000);
}
if (milsInterval < 86400000) {
testInterval = 'hour';
dateoffset = (milsInterval / 3600000);
switch (true) {
case milsInterval >= 86400000 * 364:
testInterval = 'year';
dateoffset = 1;
break;
case milsInterval >= 86400000 * 30:
testInterval = 'month';
dateoffset = 1;
break;
case milsInterval >= 86400000 * 7:
testInterval = 'week';
dateoffset = (milsInterval / 86400000 * 7);
break;
case milsInterval >= 86400000:
testInterval = 'day';
dateoffset = (milsInterval / 86400000);
break;
case milsInterval >= 3600000:
testInterval = 'hour';
dateoffset = (milsInterval / 3600000);
break;
case milsInterval >= 60000:
testInterval = 'minute';
dateoffset = (milsInterval / 60000);
break;
default:
testInterval = 'second';
dateoffset = (milsInterval / 1000);
}
if (milsInterval < 3600000) {
testInterval = 'minute';
dateoffset = (milsInterval / 60000);
}
if (milsInterval < 60000) {
testInterval = 'second';
dateoffset = (milsInterval / 1000);
}

// apply interval to last date in keys
var maxIntervalOffset = d3.time[testInterval]
.offset(new Date(maxDate), dateoffset);
var minIntervalOffset = d3.time[testInterval]
.offset(new Date(minDate), -dateoffset);

xScale = d3.time.scale()
.domain([minIntervalOffset, maxIntervalOffset])
.range([0, width])
.nice(xTicks);

xScale.domain([
d3.time[testInterval].offset(new Date(minDate), -dateoffset),
d3.time[testInterval].offset(new Date(maxDate), dateoffset)
]);
} else {
xScale = d3.scale.ordinal()
.domain(keys)
Expand Down Expand Up @@ -757,20 +752,10 @@ define(function (require) {
.enter()
.append('g')
.attr('class', function (d) {
if (!d.label) {
return colors[yAxisLabel];
} else {
return colors[d.label];
}

return colors[d.label];
})
.style('fill', function (d) {
if (!d.label) {
return colors[yAxisLabel];
} else {
return colors[d.label];
}

return colors[d.label];
});

var bars = layer.selectAll('rect')
Expand Down Expand Up @@ -934,6 +919,7 @@ define(function (require) {
})
.attr('width', function () {
var val;

if (data.ordered === undefined || !data.ordered.date) {
val = xScale.rangeBand();
} else {
Expand All @@ -942,27 +928,14 @@ define(function (require) {
var barSpacing = barWidth * 0.25;
val = barWidth - barSpacing;
}
if (isNaN(val) || val < 0.5) {
throw new Error('The container is too small for this chart.');
} else {
return val;
}

return val;
})
.attr('y', function (d) {
var val = yScale(d.y0 + d.y);
if (isNaN(val) || val < 0) {
throw new Error('line 907: bars attr y: ' + val);
} else {
return val;
}
return yScale(d.y0 + d.y);
})
.attr('height', function (d) {
var val = yScale(d.y0) - yScale(d.y0 + d.y);
if (isNaN(val) || val <= 0) {
throw new Error('line 915: bars attr height: ' + val);
} else {
return val;
}
return yScale(d.y0) - yScale(d.y0 + d.y);
});
break;
}
Expand Down
15 changes: 7 additions & 8 deletions src/kibana/components/vislib/modules/lineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ define(function (require) {

selection.each(function (d) {
d.series.forEach(function (label) {
if (label.label) {
items.push(label.label);
} else {
items.push(d.yAxisLabel);
}
items.push(label.label);
});
});

Expand Down Expand Up @@ -526,7 +522,8 @@ define(function (require) {
})
.attr('fill', 'none')
.attr('stroke', function (d) {
return d.label ? colors[d.label] : colors[yAxisLabel];
return colors[d.label];
// return d.label ? colors[d.label] : colors[yAxisLabel];
})
.attr('stroke-width', 3);

Expand All @@ -552,7 +549,8 @@ define(function (require) {
return 'rl rl-' + chart.getClassName(d.label, yAxisLabel);
})
.attr('stroke', function (d) {
return d.label ? colors[d.label] : colors[yAxisLabel];
return colors[d.label];
// return d.label ? colors[d.label] : colors[yAxisLabel];
});

var circle = layer.selectAll('.points')
Expand All @@ -573,7 +571,8 @@ define(function (require) {
circle
.attr('fill', '#ffffff')
.attr('stroke', function (d) {
return d.label ? colors[d.label] : colors[yAxisLabel];
return colors[d.label];
// return d.label ? colors[d.label] : colors[yAxisLabel];
})
.attr('stroke-width', 3.5)
.attr('opacity', 0);
Expand Down

0 comments on commit b7cef0c

Please sign in to comment.