in lib/@uncharted.software/stories-facets/src/components/facet/facetVertical.js [420:456]
FacetVertical.prototype._updateSparkline = function() {
if (this._spec.timeseries && this._spec.timeseries.length) {
this._sparklineContainer.empty();
var sparkline = $(facetVertical_sparkline(this._spec));
this._sparklineContainer.append(sparkline);
var sparkWidth = this._sparklineContainer.width();
var sparkHeight = this._sparklineContainer.height()-2;
// Compute the maximum value so total and selected sparklines are the same height
var maxValue = 0;
this._spec.timeseries.forEach(function(count) { maxValue = Math.max(maxValue,count); });
maxValue = maxValue ? maxValue : 1; // prevent divide by 0
var totalSparklinePath = this._renderSparkline(sparkWidth,sparkHeight,this._spec.timeseries, maxValue);
totalSparklinePath.appendTo(sparkline);
// If we have a selection, add it to the svg, otherwise, override the styling if provided
if (this._spec.selected && this._spec.selected.timeseries) {
var selectedSparklinePath = this._renderSparkline(sparkWidth,sparkHeight,this._spec.selected.timeseries, maxValue);
selectedSparklinePath.appendTo(sparkline);
totalSparklinePath[0].classList.add('facet-sparkline-total');
selectedSparklinePath[0].classList.add('facet-sparkline-selected');
if (this._spec.isQuery && this._spec.icon && this._spec.icon.color) {
selectedSparklinePath.css('stroke', this._spec.icon.color);
}
} else {
if (this._spec.icon && this._spec.icon.color) {
totalSparklinePath.css('stroke',this._spec.icon.color);
}
}
}
};