Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds legacy time support for Waterfall chart #26136

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
import {
buildQueryContext,
ensureIsArray,
getXAxisColumn,
isXAxisSet,
QueryFormData,
} from '@superset-ui/core';

export default function buildQuery(formData: QueryFormData) {
const { x_axis, granularity_sqla, groupby } = formData;
const columns = [
...(isXAxisSet(formData) ? ensureIsArray(getXAxisColumn(formData)) : []),
...ensureIsArray(formData.groupby),
...ensureIsArray(x_axis || granularity_sqla),
...ensureIsArray(groupby),
];
return buildQueryContext(formData, baseQueryObject => [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@
* under the License.
*/
import React from 'react';
import { t } from '@superset-ui/core';
import { hasGenericChartAxes, t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlSubSectionHeader,
D3_TIME_FORMAT_DOCS,
DEFAULT_TIME_FORMAT,
formatSelectOptions,
sections,
sharedControls,
} from '@superset-ui/chart-controls';
import { showValueControl } from '../controls';

const config: ControlPanelConfig = {
controlPanelSections: [
sections.genericTime,
{
label: t('Query'),
expanded: true,
controlSetRows: [
['x_axis'],
['time_grain_sqla'],
[hasGenericChartAxes ? 'x_axis' : null],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't a row value of null result in an empty DOM placeholder?
How about conditionally appending generic x-axis control?

Suggested change
[hasGenericChartAxes ? 'x_axis' : null],
...(hasGenericChartAxes ? ['x_axis', 'time_grain_sqla'] : []),

Copy link
Member Author

@michael-s-molina michael-s-molina Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't a row value of null result in an empty DOM placeholder?

It does not. This pattern is used everywhere.

How about conditionally appending generic x-axis control?

We need to add the x_axis and time_grain_sqla into different arrays.

[hasGenericChartAxes ? 'time_grain_sqla' : null],
['groupby'],
['metric'],
['adhoc_filters'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class EchartsWaterfallChartPlugin extends ChartPlugin<
{ url: example3 },
],
name: t('Waterfall Chart'),
tags: [t('Categorical'), t('Comparison'), t('ECharts')],
tags: [t('Categorical'), t('Comparison'), t('ECharts'), t('Popular')],
thumbnail,
}),
transformProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export default function transformProps(
const { setDataMask = () => {}, onContextMenu, onLegendStateChanged } = hooks;
const {
currencyFormat,
granularitySqla = '',
groupby,
increaseColor,
decreaseColor,
Expand Down Expand Up @@ -213,7 +214,10 @@ export default function transformProps(
const breakdownName = isAdhocColumn(breakdownColumn)
? breakdownColumn.label!
: breakdownColumn;
const xAxisName = isAdhocColumn(xAxis) ? xAxis.label! : xAxis;
const xAxisColumn = xAxis || granularitySqla;
const xAxisName = isAdhocColumn(xAxisColumn)
? xAxisColumn.label!
: xAxisColumn;
const metricLabel = getMetricLabel(metric);

const transformedData = transformer({
Expand Down
Loading