Add NVD3's bullet chart (#1775)

* Add NVD3's bullet chart.

* Add empty lines before nested function definitions.

* Add thumbnail for bullet chart.

* Add bullet chart to gallery.rst.

* Add "requiresTime: false", fix indentation.

* Avoid scaling bullet chart vertically.

* Use a default if no range is specified.

* Fix coloring of bullet chart.
This commit is contained in:
Daniel Darabos
2016-12-12 16:58:13 +00:00
committed by Maxime Beauchemin
parent afb3c24d5a
commit 2993ff1d75
9 changed files with 171 additions and 1 deletions

View File

@@ -252,6 +252,10 @@ function nvd3Vis(slice) {
chart.maxBoxWidth(75); // prevent boxes from being incredibly wide
break;
case 'bullet':
chart = nv.models.bulletChart();
break;
default:
throw new Error('Unrecognized visualization for nvd3' + vizType);
}
@@ -261,6 +265,9 @@ function nvd3Vis(slice) {
}
let height = slice.height() - 15;
if (vizType === 'bullet') {
height = Math.min(height, 50);
}
chart.height(height);
slice.container.css('height', height + 'px');
@@ -309,7 +316,9 @@ function nvd3Vis(slice) {
chart.y2Axis.tickFormat(d3.format(fd.y_axis_format));
}
}
chart.color((d) => category21(d[colorKey]));
if (vizType !== 'bullet') {
chart.color((d) => category21(d[colorKey]));
}
if (fd.x_axis_label && fd.x_axis_label !== '' && chart.xAxis) {
let distance = 0;