Skip to content

Commit

Permalink
chore: Moves xAxisLabelRotation to shared controls (apache#26212)
Browse files Browse the repository at this point in the history
(cherry picked from commit 005cf59)
  • Loading branch information
michael-s-molina authored and josedev-union committed Jan 22, 2024
1 parent 2f1a6b4 commit 1a1f37e
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import { DEFAULT_LEGEND_FORM_DATA } from '../constants';
import { defaultXAxis } from '../defaults';
import { EchartsBubbleFormData } from './types';

export const DEFAULT_FORM_DATA: Partial<EchartsBubbleFormData> = {
Expand All @@ -29,7 +30,7 @@ export const DEFAULT_FORM_DATA: Partial<EchartsBubbleFormData> = {
truncateXAxis: false,
truncateYAxis: false,
yAxisBounds: [null, null],
xAxisLabelRotation: 0,
xAxisLabelRotation: defaultXAxis.xAxisLabelRotation,
opacity: 0.6,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ import {
} from '@superset-ui/chart-controls';

import { DEFAULT_FORM_DATA } from './constants';
import { legendSection, truncateXAxis, xAxisBounds } from '../controls';
import {
legendSection,
truncateXAxis,
xAxisBounds,
xAxisLabelRotation,
} from '../controls';
import { defaultYAxis } from '../defaults';

const { logAxis, truncateYAxis, yAxisBounds, xAxisLabelRotation, opacity } =
DEFAULT_FORM_DATA;
const { logAxis, truncateYAxis, yAxisBounds, opacity } = DEFAULT_FORM_DATA;

const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -127,27 +132,7 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
[
{
name: 'x_axis_title_margin',
Expand Down Expand Up @@ -212,7 +197,7 @@ const config: ControlPanelConfig = {
[0, '0°'],
[45, '45°'],
],
default: xAxisLabelRotation,
default: defaultYAxis.yAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import {

import { DEFAULT_FORM_DATA } from './types';
import { EchartsTimeseriesSeriesType } from '../Timeseries/types';
import { legendSection, richTooltipSection } from '../controls';
import {
legendSection,
richTooltipSection,
xAxisLabelRotation,
} from '../controls';

const {
area,
Expand All @@ -49,7 +53,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
yAxisIndex,
} = DEFAULT_FORM_DATA;

Expand Down Expand Up @@ -314,27 +317,7 @@ const config: ControlPanelConfig = {
...legendSection,
[<ControlSubSectionHeader>{t('X Axis')}</ControlSubSectionHeader>],
['x_axis_time_format'],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
richTooltipSection,
seriesOrderSection,
percentageThresholdControl,
xAxisLabelRotation,
truncateXAxis,
xAxisBounds,
} from '../../controls';
Expand All @@ -53,7 +54,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
} = DEFAULT_FORM_DATA;
const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -193,27 +193,7 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
showValueSection,
truncateXAxis,
xAxisBounds,
xAxisLabelRotation,
} from '../../../controls';

import { OrientationType } from '../../types';
Expand All @@ -51,7 +52,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
orientation,
} = DEFAULT_FORM_DATA;

Expand Down Expand Up @@ -165,22 +165,9 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
],
[
{
name: 'xAxisLabelRotation',
name: xAxisLabelRotation.name,
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
...xAxisLabelRotation.config,
visibility: ({ controls }: ControlPanelsContainerProps) =>
isXAxis ? isVertical(controls) : isHorizontal(controls),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
showValueSection,
truncateXAxis,
xAxisBounds,
xAxisLabelRotation,
} from '../../../controls';

const {
Expand All @@ -54,7 +55,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
} = DEFAULT_FORM_DATA;
const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -181,27 +181,7 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
showValueSection,
truncateXAxis,
xAxisBounds,
xAxisLabelRotation,
} from '../../../controls';

const {
Expand All @@ -50,7 +51,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
} = DEFAULT_FORM_DATA;
const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -124,27 +124,7 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
// eslint-disable-next-line react/jsx-key
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
showValueSectionWithoutStack,
truncateXAxis,
xAxisBounds,
xAxisLabelRotation,
} from '../../../controls';

const {
Expand All @@ -50,7 +51,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
} = DEFAULT_FORM_DATA;
const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -123,27 +123,7 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
// eslint-disable-next-line react/jsx-key
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
showValueSection,
truncateXAxis,
xAxisBounds,
xAxisLabelRotation,
} from '../../controls';

const {
Expand All @@ -50,7 +51,6 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
} = DEFAULT_FORM_DATA;
const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -175,27 +175,7 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
[90, '90°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t(
'Input field supports custom rotation. e.g. 30 for 30°',
),
},
},
],
[xAxisLabelRotation],
...richTooltipSection,
// eslint-disable-next-line react/jsx-key
[<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
Expand Down
Loading

0 comments on commit 1a1f37e

Please sign in to comment.