Comments (7)
Hey @inbreaks! I'm Dosu, a bot here to help you with bug fixes, questions, and becoming a contributor. How can I assist you today?
To resolve the issue of redundant percentages and totals being displayed on the time-series line chart, you can adjust the control panel configuration and modify the tooltip formatting logic in Apache Superset.
-
Adjust Control Panel Configuration:
Modify thecontrolPanelSections
configuration to ensure that unnecessary elements like redundant percentages and totals are not included. Here is an example configuration:const config: ControlPanelConfig = { controlPanelSections: [ sections.legacyTimeseriesTime, timeSeriesSection[0], { label: t('Chart Options'), expanded: true, controlSetRows: [ ['color_scheme'], [showBrush], [ { name: 'send_time_range', config: { type: 'CheckboxControl', label: t('Propagate'), renderTrigger: true, default: false, description: t('Send range filter events to other charts'), }, }, ], [showLegend], [richTooltip], [showMarkers], [lineInterpolation], ], }, { label: t('X Axis'), expanded: true, controlSetRows: [ [xAxisLabel], [bottomMargin], [xTicksLayout], [xAxisFormat], [xAxisShowMinmax, null], ], }, { label: t('Y Axis'), expanded: true, controlSetRows: [ [yAxisLabel], [leftMargin], [yAxisShowMinmax], [yLogScale], ['y_axis_format'], [yAxisBounds], ], }, timeSeriesSection[1], sections.annotations, ], controlOverrides: { row_limit: { default: 50000, }, }, formDataOverrides: formData => ({ ...formData, metrics: getStandardizedControls().popAllMetrics(), groupby: getStandardizedControls().popAllColumns(), }), }; export default config;
-
Modify Tooltip Formatting Logic:
Adjust thetransformProps
function insuperset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
to ensure that the tooltip does not display redundant percentages and totals. Here is an example adjustment:const tooltipFormatter = xAxisDataType === GenericDataType.Temporal ? getTooltipTimeFormatter(tooltipTimeFormat) : String; const echartOptions: EChartsCoreOption = { // ... other options tooltip: { ...getDefaultTooltip(refs), show: !inContextMenu, trigger: richTooltip ? 'axis' : 'item', formatter: (params: any) => { const [xIndex, yIndex] = isHorizontal ? [1, 0] : [0, 1]; const xValue: number = richTooltip ? params[0].value[xIndex] : params.value[xIndex]; const forecastValue: any[] = richTooltip ? params : [params]; if (richTooltip && tooltipSortByMetric) { forecastValue.sort((a, b) => b.data[yIndex] - a.data[yIndex]); } const forecastValues: Record<string, ForecastValue> = extractForecastValuesFromTooltipParams(forecastValue, isHorizontal); const isForecast = Object.values(forecastValues).some( value => value.forecastTrend || value.forecastLower || value.forecastUpper, ); const formatter = forcePercentFormatter ? percentFormatter : getCustomFormatter(customFormatters, metrics) ?? defaultFormatter; const rows: string[][] = []; const total = Object.values(forecastValues).reduce( (acc, value) => value.observation !== undefined ? acc + value.observation : acc, 0, ); const showTotal = Boolean(isMultiSeries) && richTooltip && !isForecast; const showPercentage = showTotal && !forcePercentFormatter; const keys = Object.keys(forecastValues); keys.forEach(key => { const value = forecastValues[key]; if (value.observation === 0 && stack) { return; } const row = formatForecastTooltipSeries({ ...value, seriesName: key, formatter, }); if (showPercentage && value.observation !== undefined) { row.push(percentFormatter.format(value.observation / (total || 1))); } rows.push(row); }); if (stack) { keys.reverse(); rows.reverse(); } if (showTotal) { const totalRow = ['Total', formatter.format(total)]; if (showPercentage) { totalRow.push(percentFormatter.format(1)); } rows.push(totalRow); } return tooltipHtml( rows, tooltipFormatter(xValue), keys.findIndex(key => key === focusedSeries), ); }, }, // ... other options };
By making these adjustments, you can ensure that redundant percentages and totals are not displayed on your time-series line chart [1][2][3].
To continue talking to Dosu, mention @dosu.
from superset.
CC @michael-s-molina who has been looking at these tooltip displays. Maybe they can be rendered conditionally (e.g. skip if percentage format). I also can't help but wonder if it indicates a problem that you have 171.5% of something
from superset.
Hi @inbreaks. To support this use case, we would need some form of control to precisely configure what parts of the tooltip you want to display. We don't have that feature currently. Right now, you might want to disable the Rich Tooltip option until we provide such feature.
from superset.
Thanks @michael-s-molina , how do I turn off Rich Tooltip? Is it possible to configure DEFAULT_FEATURE_FLAGS to do this?
![Screenshot 2024-06-06 at 09 51 16](https://private-user-images.githubusercontent.com/70410625/337270734-00e1d9e5-6410-44eb-a5c6-fc6c8063bde9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgyNTQzNzgsIm5iZiI6MTcxODI1NDA3OCwicGF0aCI6Ii83MDQxMDYyNS8zMzcyNzA3MzQtMDBlMWQ5ZTUtNjQxMC00NGViLWE1YzYtZmM2YzgwNjNiZGU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEzVDA0NDc1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE4ODljYzkzODQ0MWIzNTcwNGQxMTk1NmM5OTMxMmZjNmI2NzgyNTZkZTc2MjM4YTkzMzJkODNmMDdiNDE1NjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.-LswJQNbO2c3bxvTtfXh-ml5J1m8nF2Mk3_NeqfRpd8)
from superset.
Hi @inbreaks. I'm not sure if I fully understand the problem. Given that this new tooltip was not officially released yet, I'm assuming you are using master
. I just checked the latest master version and I'm not able to reproduce the problem. The percentages are shown when there's no contribution.
![Screenshot 2024-06-04 at 08 58 11](https://private-user-images.githubusercontent.com/70410625/336440073-dbfca0af-5bc8-4b20-82d3-3d81af3c9652.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgyNTQzNzgsIm5iZiI6MTcxODI1NDA3OCwicGF0aCI6Ii83MDQxMDYyNS8zMzY0NDAwNzMtZGJ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BbXotU2lnbmF0dXJlPTBiM2FiMDQ5MGM0ODZkNWM3MmZmYmUxMWNjMDRjZWRmNmUxMmI2M2NjMmIzNTg1MDk1OGNhNjMxNWM2MmZmNTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.P7ZOsXoScYbxTVnPYQUXZhgOdK6BGsdk-T_Pu_wOOyE)
The only scenario I can think of that could generate your screenshot is if you formatted the Y-axis to always display as percentage.
from superset.
Hi @michael-s-molina the background of this use case is to calculate the next-day retention rate of new users from each traffic channel, so the Y-axis will always show the percentage, but the total is not 100%, for example
traffic sources | next-day retention |
---|---|
20% | |
30% | |
TikTok | 35% |
Therefore, calculating total and percentage is redundant
from superset.
Hi @inbreaks. To support this use case, we would need some form of control to precisely configure what parts of the tooltip you want to display. We don't have that feature currently. Right now, you might want to disable the Rich Tooltip option until we provide such feature.
Thanks @michael-s-molina , how do I turn off Rich Tooltip? Is it possible to configure DEFAULT_FEATURE_FLAGS
to do this?
from superset.
Related Issues (20)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superset.