eschutho commented on code in PR #34526:
URL: https://github.com/apache/superset/pull/34526#discussion_r2268365575
##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx:
##########
@@ -473,3 +473,218 @@ export default {
sort_by_metric,
order_by_cols,
};
+
+// dynamically add matrixify controls
+['columns', 'rows'].forEach(axisParam => {
+ const axis = axisParam; // Capture the value in a local variable
+ sharedControls[`matrixify_mode_${axis}`] = {
+ type: 'RadioButtonControl',
+ label: t(`Metrics / Dimensions`),
+ default: 'metrics',
+ options: [
+ ['metrics', t('Metrics')],
+ ['dimensions', t('Dimension Members')],
+ ],
+ renderTrigger: true,
+ };
+
+ sharedControls[`matrixify_${axis}`] = {
+ ...dndAdhocMetricControl,
+ label: t(`Metrics`),
+ multi: true,
+ validators: [], // Not required
+ // description: t(`Select metrics for ${axis}`),
+ renderTrigger: true,
+ visibility: ({ controls }) =>
+ controls?.[`matrixify_mode_${axis}`]?.value === 'metrics',
+ };
+
+ // Combined dimension and values control
+ sharedControls[`matrixify_dimension_${axis}`] = {
+ type: 'MatrixifyDimensionControl',
+ label: t(`Dimension Selection`),
+ description: t(`Select dimension and values`),
+ default: { dimension: '', values: [] },
+ validators: [], // Not required
+ renderTrigger: true,
+ mapStateToProps: ({ datasource, controls }) => ({
+ datasource,
+ selectionMode:
+ controls?.[`matrixify_dimension_selection_mode_${axis}`]?.value ||
+ 'members',
+ }),
+ visibility: ({ controls }) =>
+ controls?.[`matrixify_mode_${axis}`]?.value === 'dimensions' &&
+ controls?.[`matrixify_dimension_selection_mode_${axis}`]?.value !==
+ 'topn',
+ };
+
+ // Dimension picker for TopN mode (just dimension, no values)
+ sharedControls[`matrixify_topn_dimension_${axis}`] = {
+ type: 'SelectControl',
+ label: (
+ <div>
+ <Tag color="error" style={{ marginBottom: '8px' }}>
+ Not Implemented Yet
+ </Tag>
+ <div>{t('Dimension')}</div>
+ </div>
+ ),
+ description: t(`Select dimension for Top N`),
+ default: null,
+ mapStateToProps: ({ datasource }) => ({
+ choices:
+ datasource?.columns?.map((col: any) => [
+ col.column_name,
+ col.column_name,
+ ]) || [],
+ }),
+ renderTrigger: true,
+ visibility: ({ controls }) =>
+ controls?.[`matrixify_mode_${axis}`]?.value === 'dimensions' &&
+ controls?.[`matrixify_dimension_selection_mode_${axis}`]?.value ===
+ 'topn',
+ };
+
+ // Add selection mode control (Dimension Members vs TopN)
+ sharedControls[`matrixify_dimension_selection_mode_${axis}`] = {
+ type: 'RadioButtonControl',
+ label: t(`Selection Method`),
Review Comment:
Sentence case?
--
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]