Skip to content

Commit

Permalink
Merge branch 'master' into enxdev/refactor-antd5-icons
Browse files Browse the repository at this point in the history
  • Loading branch information
EnxDev committed Feb 14, 2025
2 parents 0cefa6d + ffe9244 commit 90843e1
Show file tree
Hide file tree
Showing 28 changed files with 764 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
######################################################################
# Node stage to deal with static asset construction
######################################################################
ARG PY_VER=3.11-slim-bookworm
ARG PY_VER=3.11.11-slim-bookworm

# If BUILDPLATFORM is null, set it to 'amd64' (or leave as is otherwise).
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
Expand Down
1 change: 1 addition & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ assists people when migrating to a new version.
- [25166](https://github.com/apache/superset/pull/25166) Changed the default configuration of `UPLOAD_FOLDER` from `/app/static/uploads/` to `/static/uploads/`. It also removed the unused `IMG_UPLOAD_FOLDER` and `IMG_UPLOAD_URL` configuration options.
- [30284](https://github.com/apache/superset/pull/30284) Deprecated GLOBAL_ASYNC_QUERIES_REDIS_CONFIG in favor of the new GLOBAL_ASYNC_QUERIES_CACHE_BACKEND configuration. To leverage Redis Sentinel, set CACHE_TYPE to RedisSentinelCache, or use RedisCache for standalone Redis
- [31961](https://github.com/apache/superset/pull/31961) Upgraded React from version 16.13.1 to 17.0.2. If you are using custom frontend extensions or plugins, you may need to update them to be compatible with React 17.
- [31260](https://github.com/apache/superset/pull/31260) Docker images now use `uv pip install` instead of `pip install` to manage the python envrionment. Most docker-based deployments will be affected, whether you derive one of the published images, or have custom bootstrap script that install python libraries (drivers)

### Potential Downtime

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/installation/kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ The following example installs the drivers for BigQuery and Elasticsearch, allow
```yaml
bootstrapScript: |
#!/bin/bash
pip install .[postgres] \
uv pip install .[postgres] \
.[bigquery] \
.[elasticsearch] &&\
if [ ! -f ~/bootstrap ]; then echo "Running Superset with uid {{ .Values.runAsUser }}" > ~/bootstrap; fi
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
"colorama",
"croniter>=0.3.28",
"cron-descriptor",
"cryptography>=42.0.4, <44.0.0",
"cryptography>=42.0.4, <45.0.0",
"deprecation>=2.1.0, <2.2.0",
"flask>=2.2.5, <3.0.0",
"flask-appbuilder>=4.5.3, <5.0.0",
Expand Down Expand Up @@ -87,7 +87,6 @@ dependencies = [
"redis>=4.6.0, <5.0",
"selenium>=4.14.0, <5.0",
"shillelagh[gsheetsapi]>=1.2.18, <2.0",
"shortid",
"sshtunnel>=0.4.0, <0.5",
"simplejson>=3.15.0",
"slack_sdk>=3.19.0, <4",
Expand Down
2 changes: 0 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ selenium==4.27.1
# via apache-superset (pyproject.toml)
shillelagh==1.2.18
# via apache-superset (pyproject.toml)
shortid==0.1.2
# via apache-superset (pyproject.toml)
simplejson==3.19.3
# via apache-superset (pyproject.toml)
six==1.16.0
Expand Down
4 changes: 0 additions & 4 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,6 @@ shillelagh==1.2.18
# via
# -c requirements/base.txt
# apache-superset
shortid==0.1.2
# via
# -c requirements/base.txt
# apache-superset
simplejson==3.19.3
# via
# -c requirements/base.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const titleControls: ControlPanelSectionConfig = {
type: 'SelectControl',
freeForm: true,
clearable: true,
label: t('X AXIS TITLE BOTTOM MARGIN'),
label: t('X Axis Title Margin'),
renderTrigger: true,
default: TITLE_MARGIN_OPTIONS[0],
choices: formatSelectOptions(TITLE_MARGIN_OPTIONS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@

import { QueryFormMetric, isSavedMetric, isAdhocMetricSimple } from './types';

export default function getMetricLabel(metric: QueryFormMetric): string {
export default function getMetricLabel(
metric: QueryFormMetric,
index?: number,
queryFormMetrics?: QueryFormMetric[],
verboseMap?: Record<string, string>,
): string {
let label = '';
if (isSavedMetric(metric)) {
return metric;
}
if (metric.label) {
return metric.label;
}
if (isAdhocMetricSimple(metric)) {
return `${metric.aggregate}(${
label = metric;
} else if (metric.label) {
({ label } = metric);
} else if (isAdhocMetricSimple(metric)) {
label = `${metric.aggregate}(${
metric.column.columnName || metric.column.column_name
})`;
} else {
label = metric.sqlExpression;
}
return metric.sqlExpression;
return verboseMap?.[label] || label;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
formatSelectOptionsForRange,
dndGroupByControl,
columnsByType,
sections,
D3_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT,
} from '@superset-ui/chart-controls';
import { showLegendControl, showValueControl } from '../controls';

Expand Down Expand Up @@ -105,14 +107,65 @@ const config: ControlPanelConfig = {
],
],
},
sections.titleControls,
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['color_scheme'],
[showValueControl],
[showLegendControl],
[
{
name: 'x_axis_title',
config: {
type: 'TextControl',
label: t('X Axis Title'),
renderTrigger: true,
default: '',
description: t('Changing this control takes effect instantly'),
},
},
],
[
{
name: 'x_axis_format',
config: {
type: 'SelectControl',
freeForm: true,
label: t('X Axis Format'),
renderTrigger: true,
default: 'SMART_NUMBER',
choices: D3_FORMAT_OPTIONS,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],
[
{
name: 'y_axis_title',
config: {
type: 'TextControl',
label: t('Y Axis Title'),
renderTrigger: true,
default: '',
description: t('Changing this control takes effect instantly'),
},
},
],
[
{
name: 'y_axis_format',
config: {
type: 'SelectControl',
freeForm: true,
label: t('Y Axis Format'),
renderTrigger: true,
default: 'SMART_NUMBER',
choices: D3_FORMAT_OPTIONS,
description: `${D3_FORMAT_DOCS} ${D3_NUMBER_FORMAT_DESCRIPTION_VALUES_TEXT}`,
},
},
],
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
CategoricalColorNamespace,
NumberFormats,
getColumnLabel,
getNumberFormatter,
getValueFormatter,
tooltipHtml,
} from '@superset-ui/core';
import { HistogramChartProps, HistogramTransformedProps } from './types';
Expand All @@ -41,6 +41,7 @@ export default function transformProps(
const refs: Refs = {};
let focusedSeries: number | undefined;
const {
datasource: { currencyFormats = {}, columnFormats = {} },
formData,
height,
hooks,
Expand All @@ -58,19 +59,33 @@ export default function transformProps(
showLegend,
showValue,
sliceId,
xAxisFormat,
xAxisTitle,
yAxisTitle,
yAxisFormat,
} = formData;
const { data } = queriesData[0];
const colorFn = CategoricalColorNamespace.getScale(colorScheme);
const formatter = getNumberFormatter(
normalize ? NumberFormats.FLOAT_2_POINT : NumberFormats.INTEGER,
);

const formatter = (format: string) =>
getValueFormatter(
column,
currencyFormats,
columnFormats,
format,
undefined,
);
const xAxisFormatter = formatter(xAxisFormat);
const yAxisFormatter = formatter(yAxisFormat);

const percentFormatter = getPercentFormatter(NumberFormats.PERCENT_2_POINT);
const groupbySet = new Set(groupby);
const xAxisData: string[] = Object.keys(data[0]).filter(
key => !groupbySet.has(key),
);
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 barSeries: BarSeriesOption[] = data.map(datum => {
const seriesName =
groupby.length > 0
Expand All @@ -91,7 +106,7 @@ export default function transformProps(
position: 'top',
formatter: params => {
const { value } = params;
return formatter.format(value as number);
return yAxisFormatter.format(value as number);
},
},
};
Expand All @@ -108,7 +123,7 @@ export default function transformProps(
const title = params[0].name;
const rows = params.map(param => {
const { marker, seriesName, value } = param;
return [`${marker}${seriesName}`, formatter.format(value as number)];
return [`${marker}${seriesName}`, yAxisFormatter.format(value as number)];
});
if (groupby.length > 0) {
const total = params.reduce(
Expand All @@ -122,7 +137,7 @@ export default function transformProps(
),
);
}
const totalRow = ['Total', formatter.format(total)];
const totalRow = ['Total', yAxisFormatter.format(total)];
if (!normalize) {
totalRow.push(percentFormatter.format(1));
}
Expand Down Expand Up @@ -159,7 +174,7 @@ export default function transformProps(
type: 'value',
nameLocation: 'middle',
axisLabel: {
formatter: (value: number) => formatter.format(value),
formatter: (value: number) => yAxisFormatter.format(value),
},
},
series: barSeries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export type HistogramFormData = QueryFormData & {
sliceId: number;
showLegend: boolean;
showValue: boolean;
xAxisFormat: string;
xAxisTitle: string;
yAxisFormat: string;
yAxisTitle: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ensureIsArray,
GenericDataType,
getCustomFormatter,
getMetricLabel,
getNumberFormatter,
getXAxisLabel,
isDefined,
Expand Down Expand Up @@ -291,12 +292,20 @@ export default function transformProps(
const showValueIndexesB = extractShowValueIndexes(rawSeriesB, {
stack,
});

const metricsLabels = metrics
.map(metric => getMetricLabel(metric, undefined, undefined, verboseMap))
.filter((label): label is string => label !== undefined);
const metricsLabelsB = metricsB.map((metric: QueryFormMetric) =>
getMetricLabel(metric, undefined, undefined, verboseMap),
);

const { totalStackedValues, thresholdValues } = extractDataTotalValues(
rebasedDataA,
{
stack,
percentageThreshold,
xAxisCol: xAxisLabel,
metricsLabels,
},
);
const {
Expand All @@ -305,7 +314,7 @@ export default function transformProps(
} = extractDataTotalValues(rebasedDataB, {
stack: Boolean(stackB),
percentageThreshold,
xAxisCol: xAxisLabel,
metricsLabels: metricsLabelsB,
});

annotationLayers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,18 @@ export default function transformProps(
) {
xAxisLabel = verboseMap[xAxisLabel];
}
const metricsLabels = metrics
.map(metric => getMetricLabel(metric, undefined, undefined, verboseMap))
.filter((label): label is string => label !== undefined);
const isHorizontal = orientation === OrientationType.Horizontal;

const { totalStackedValues, thresholdValues } = extractDataTotalValues(
rebasedData,
{
stack,
percentageThreshold,
xAxisCol: xAxisLabel,
legendState,
metricsLabels,
},
);
const extraMetricLabels = extractExtraMetrics(chartProps.rawFormData).map(
Expand Down Expand Up @@ -296,7 +300,6 @@ export default function transformProps(
const entryName = String(entry.name || '');
const seriesName = inverted[entryName] || entryName;
const colorScaleKey = getOriginalSeries(seriesName, array);

const transformedSeries = transformSeries(
entry,
colorScale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ export function extractDataTotalValues(
opts: {
stack: StackType;
percentageThreshold: number;
xAxisCol: string;
legendState?: LegendState;
metricsLabels: string[];
},
): {
totalStackedValues: number[];
thresholdValues: number[];
} {
const totalStackedValues: number[] = [];
const thresholdValues: number[] = [];
const { stack, percentageThreshold, xAxisCol, legendState } = opts;
const { stack, percentageThreshold, legendState, metricsLabels } = opts;
if (stack) {
data.forEach(datum => {
const values = Object.keys(datum).reduce((prev, curr) => {
if (curr === xAxisCol) {
if (!metricsLabels.includes(curr)) {
return prev;
}
if (legendState && !legendState[curr]) {
Expand Down
Loading

0 comments on commit 90843e1

Please sign in to comment.