Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
feat(plugin-chart-echarts): subject Add option to rotate label defaul…
Browse files Browse the repository at this point in the history
… 45 (#921)
  • Loading branch information
maloun96 authored Feb 8, 2021
1 parent ca2d2f5 commit a7daa91
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/plugin-chart-echarts/src/Timeseries/controlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const {
truncateYAxis,
yAxisBounds,
zoomable,
xAxisLabelRotation,
} = DEFAULT_FORM_DATA;

const config: ControlPanelConfig = {
Expand Down Expand Up @@ -338,6 +339,24 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'xAxisLabelRotation',
config: {
type: 'SelectControl',
freeForm: true,
clearable: false,
label: t('Rotate x axis label'),
choices: [
[0, '0°'],
[45, '45°'],
],
default: xAxisLabelRotation,
renderTrigger: true,
description: t('Input field supports custom rotation. e.g. 30 for 30°'),
},
},
],
// eslint-disable-next-line react/jsx-key
[<h1 className="section-header">{t('Tooltip')}</h1>],
[
Expand Down
2 changes: 2 additions & 0 deletions plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function transformProps(chartProps: ChartProps): EchartsProps {
timeGrainSqla,
zoomable,
richTooltip,
xAxisLabelRotation,
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };

const colorScale = CategoricalColorNamespace.getScale(colorScheme as string);
Expand Down Expand Up @@ -154,6 +155,7 @@ export default function transformProps(chartProps: ChartProps): EchartsProps {
showMinLabel: xAxisShowMinLabel,
showMaxLabel: xAxisShowMaxLabel,
formatter: xAxisFormatter,
rotate: xAxisLabelRotation,
},
},
yAxis: {
Expand Down
2 changes: 2 additions & 0 deletions plugins/plugin-chart-echarts/src/Timeseries/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type EchartsTimeseriesFormData = {
yAxisBounds: [number | undefined | null, number | undefined | null];
zoomable: boolean;
richTooltip: boolean;
xAxisLabelRotation: number;
} & EchartsLegendFormData;

export const DEFAULT_FORM_DATA: EchartsTimeseriesFormData = {
Expand Down Expand Up @@ -90,4 +91,5 @@ export const DEFAULT_FORM_DATA: EchartsTimeseriesFormData = {
xAxisShowMaxLabel: true,
zoomable: false,
richTooltip: true,
xAxisLabelRotation: 45,
};

1 comment on commit a7daa91

@vercel
Copy link

@vercel vercel bot commented on a7daa91 Feb 8, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.