mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(echarts): prevent plain legend clipping in dashboards (#38675)
This commit is contained in:
committed by
GitHub
parent
3fb903fdc6
commit
12aca72074
@@ -19,8 +19,10 @@
|
||||
import {
|
||||
AnnotationStyle,
|
||||
AnnotationType,
|
||||
AnnotationSourceType,
|
||||
DataRecord,
|
||||
FormulaAnnotationLayer,
|
||||
IntervalAnnotationLayer,
|
||||
VizType,
|
||||
ChartDataResponseResult,
|
||||
} from '@superset-ui/core';
|
||||
@@ -366,6 +368,67 @@ test('legend margin: right orientation sets grid.right correctly', () => {
|
||||
expect((transformed.echartOptions.grid as any).right).toEqual(270);
|
||||
});
|
||||
|
||||
test('should exclude unnamed annotation helper series from legend data', () => {
|
||||
const interval: IntervalAnnotationLayer = {
|
||||
annotationType: AnnotationType.Interval,
|
||||
name: 'My Interval',
|
||||
show: true,
|
||||
showLabel: true,
|
||||
sourceType: AnnotationSourceType.Table,
|
||||
titleColumn: '',
|
||||
timeColumn: 'start',
|
||||
intervalEndColumn: 'end',
|
||||
descriptionColumns: [],
|
||||
style: AnnotationStyle.Dashed,
|
||||
value: 2,
|
||||
};
|
||||
|
||||
const annotationData = {
|
||||
'My Interval': {
|
||||
columns: ['start', 'end', 'title'],
|
||||
records: [
|
||||
{
|
||||
start: 2000,
|
||||
end: 3000,
|
||||
title: 'My Title',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const chartProps = createEchartsTimeseriesTestChartProps<
|
||||
EchartsMixedTimeseriesFormData,
|
||||
EchartsMixedTimeseriesProps
|
||||
>({
|
||||
...MIXED_TIMESERIES_CHART_PROPS_DEFAULTS,
|
||||
defaultQueriesData: [],
|
||||
formData: {
|
||||
...formData,
|
||||
annotationLayers: [interval],
|
||||
showLegend: true,
|
||||
showQueryIdentifiers: true,
|
||||
},
|
||||
queriesData: [
|
||||
createTestQueryData(defaultQueryRows, {
|
||||
label_map: defaultLabelMap,
|
||||
annotation_data: annotationData,
|
||||
}),
|
||||
createTestQueryData(defaultQueryRows, {
|
||||
label_map: defaultLabelMap,
|
||||
annotation_data: annotationData,
|
||||
}),
|
||||
],
|
||||
});
|
||||
const transformed = transformProps(chartProps);
|
||||
|
||||
expect((transformed.echartOptions.legend as any).data).toEqual([
|
||||
'sum__num (Query A), girl',
|
||||
'sum__num (Query A), boy',
|
||||
'sum__num (Query B), girl',
|
||||
'sum__num (Query B), boy',
|
||||
]);
|
||||
});
|
||||
|
||||
test('should add a formula annotation when X-axis column has dataset-level label', () => {
|
||||
const formula: FormulaAnnotationLayer = {
|
||||
name: 'My Formula',
|
||||
|
||||
Reference in New Issue
Block a user