mirror of
https://github.com/apache/superset.git
synced 2026-04-21 09:04:38 +00:00
feat(plugin-chart-echarts): support horizontal bar chart (#19918)
* feat(plugin-chart-echarts): support horizontal bar chart * Update superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx Co-authored-by: Evan Rusackas <evan@preset.io> * Update superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> * Update superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> * Update superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com> * improve controlpanel * default value * fix ut Co-authored-by: Evan Rusackas <evan@preset.io> Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
This commit is contained in:
@@ -53,12 +53,13 @@ export const extractForecastSeriesContexts = (
|
||||
|
||||
export const extractForecastValuesFromTooltipParams = (
|
||||
params: any[],
|
||||
isHorizontal = false,
|
||||
): Record<string, ForecastValue> => {
|
||||
const values: Record<string, ForecastValue> = {};
|
||||
params.forEach(param => {
|
||||
const { marker, seriesId, value } = param;
|
||||
const context = extractForecastSeriesContext(seriesId);
|
||||
const numericValue = (value as [Date, number])[1];
|
||||
const numericValue = isHorizontal ? value[0] : value[1];
|
||||
if (numericValue) {
|
||||
if (!(context.name in values))
|
||||
values[context.name] = {
|
||||
|
||||
@@ -42,9 +42,15 @@ export function extractSeries(
|
||||
fillNeighborValue?: number;
|
||||
xAxis?: string;
|
||||
removeNulls?: boolean;
|
||||
isHorizontal?: boolean;
|
||||
} = {},
|
||||
): SeriesOption[] {
|
||||
const { fillNeighborValue, xAxis = DTTM_ALIAS, removeNulls = false } = opts;
|
||||
const {
|
||||
fillNeighborValue,
|
||||
xAxis = DTTM_ALIAS,
|
||||
removeNulls = false,
|
||||
isHorizontal = false,
|
||||
} = opts;
|
||||
if (data.length === 0) return [];
|
||||
const rows: DataRecord[] = data.map(datum => ({
|
||||
...datum,
|
||||
@@ -69,7 +75,8 @@ export function extractSeries(
|
||||
: row[key],
|
||||
];
|
||||
})
|
||||
.filter(obs => !removeNulls || (obs[0] !== null && obs[1] !== null)),
|
||||
.filter(obs => !removeNulls || (obs[0] !== null && obs[1] !== null))
|
||||
.map(obs => (isHorizontal ? [obs[1], obs[0]] : obs)),
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user