hughhhh closed pull request #4643: Added option to add fill to area line charts URL: https://github.com/apache/incubator-superset/pull/4643
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/superset/assets/javascripts/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx index cc35d0e573..9ea407d5ae 100644 --- a/superset/assets/javascripts/explore/stores/controls.jsx +++ b/superset/assets/javascripts/explore/stores/controls.jsx @@ -376,6 +376,14 @@ export const controls = { description: null, }, + line_fill_area: { + type: 'CheckboxControl', + label: t('Fill Area of Line Chart'), + renderTrigger: true, + default: false, + description: null, + }, + pivot_margins: { type: 'CheckboxControl', label: t('Show totals'), diff --git a/superset/assets/javascripts/explore/stores/visTypes.js b/superset/assets/javascripts/explore/stores/visTypes.js index 75443469f3..6aad1b8905 100644 --- a/superset/assets/javascripts/explore/stores/visTypes.js +++ b/superset/assets/javascripts/explore/stores/visTypes.js @@ -187,6 +187,7 @@ export const visTypes = { ['y_axis_label', 'left_margin'], ['y_axis_showminmax', 'y_log_scale'], ['y_axis_format', 'y_axis_bounds'], + ['line_fill_area', null], ], }, sections.NVD3TimeSeries[1], diff --git a/superset/assets/visualizations/nvd3_vis.js b/superset/assets/visualizations/nvd3_vis.js index 7cfb1c3320..54597bb0da 100644 --- a/superset/assets/visualizations/nvd3_vis.js +++ b/superset/assets/visualizations/nvd3_vis.js @@ -75,6 +75,7 @@ function hideTooltips() { $('.nvtooltip').css({ opacity: 0 }); } + function getMaxLabelSize(container, axisClass) { // axis class = .nv-y2 // second y axis on dual line chart // axis class = .nv-x // x axis on time series line chart @@ -173,6 +174,17 @@ function nvd3Vis(slice, payload) { } else { chart = nv.models.lineChart(); } + + if (fd.line_fill_area) { + data = data.map(d => ({ + ...d, + area: true, + fillOpacity: 0.1, + })); + + chart.forceY([0]); + } + // To alter the tooltip header // chart.interactiveLayer.tooltip.headerFormatter(function(){return '';}); chart.xScale(d3.time.scale.utc()); @@ -654,7 +666,6 @@ function nvd3Vis(slice, payload) { const domain = [xMin, xMax]; xScale.domain(domain); chart.xDomain(domain); - annotations.selectAll('line') .data(records) .enter() ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services