SBIN2010 commented on code in PR #45397:
URL: https://github.com/apache/superset/pull/45397#discussion_r4405742577
##########
superset-frontend/plugins/plugin-chart-echarts/src/Histogram/transformProps.ts:
##########
@@ -81,23 +103,47 @@ export default function transformProps(
const percentFormatter = getPercentFormatter(NumberFormats.PERCENT_2_POINT);
const groupbySet = new Set(groupby.map(getColumnLabel));
- const xAxisData: string[] = Object.keys(data[0])
- .filter(key => !groupbySet.has(key))
- .map(key => {
- const array = key.split(' - ').map(value => parseFloat(value));
- return `${xAxisFormatter(array[0])} - ${xAxisFormatter(array[1])}`;
- });
+ const firstRow = data[0];
+ const binKeys = firstRow
+ ? Object.keys(firstRow).filter(
+ key => !groupbySet.has(key) && parseBinKey(key) !== undefined,
+ )
+ : [];
+ const bins: HistogramBin[] = binKeys.map((key, index) => {
+ const edges = parseBinKey(key);
+ const start = edges?.start ?? Number.NaN;
+ const end = edges?.end ?? Number.NaN;
+ const startLabel = xAxisFormatter(start);
+ const endLabel = xAxisFormatter(end);
+ return {
+ start,
+ end,
+ isLast: index === binKeys.length - 1,
+ label: `${startLabel} - ${endLabel}`,
+ };
+ });
+ const xAxisData = bins.map(bin => bin.label);
+ const seriesGroupby: DataRecordValue[][] = [];
const barSeries: BarSeriesOption[] = data.map(datum => {
+ const groupbyValues = groupby.map(
+ key => datum[getColumnLabel(key)] as DataRecordValue,
+ );
+ seriesGroupby.push(groupbyValues);
const seriesName =
- groupby.length > 0
- ? groupby.map(key => datum[getColumnLabel(key)]).join(', ')
- : getColumnLabel(column);
- const seriesData = Object.keys(datum)
- .filter(key => groupbySet.has(key) === false)
- .map(key => datum[key] as number);
+ groupby.length > 0 ? groupbyValues.join(', ') : getColumnLabel(column);
+ const seriesData = bins.map((bin, index) => {
+ const filterKey = getHistogramCrossFilterKey(bin, groupbyValues);
+ const isDimmed =
+ selectedKeys.length > 0 && !selectedKeys.includes(filterKey);
Review Comment:
The selection key is constructed based on the current min and max values.
Now, if the data or a filter shifts these values such that no column matches
the stored key, the columns are not dimmed. Otherwise, the entire chart would
remain dimmed while the old range continues to filter the other charts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]