Skip to content

Commit

Permalink
feat(YAxis): add transposeNameText prop
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenOutman committed Jun 16, 2022
1 parent 29e9602 commit 1db822a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/components/YAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ export type YAxisProps = Omit<YAXisComponentOption, 'axisLine' | 'axisLabel' | '
axisLine?: YAXisComponentOption['axisLine'] | boolean;
axisLabel?: YAXisComponentOption['axisLabel'] | boolean | AxisLabelFormatter;
splitLine?: YAXisComponentOption['splitLine'] | boolean;

/**
* When nameLocation="middle",
* whether to transpose the axis name text into vertical direction.
*
* @default true
*/
transposeNameText?: boolean;
};

function YAxis(_: YAxisProps) {
Expand Down
12 changes: 8 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as echarts from 'echarts/core';
import { TitleComponent } from 'echarts/components';
import { symbols } from './constants';
import { ChartComponentProps } from './ECharts';
import type { YAxisProps } from './components/YAxis';

echarts.use([TitleComponent]);

Expand Down Expand Up @@ -256,19 +257,22 @@ const createOptions = {
option.xAxis.push(xAxisOption);
}
},
[symbols.yAxis](option: any, props: any, _: any) {
[symbols.yAxis](option: any, props: YAxisProps, _: any) {
function getOption() {
const { name, axisLabel, splitLine, ...rest } = props;
const { name, axisLabel, splitLine, transposeNameText = true, ...rest } = props;

return _merge(
{
nameRotate: 0,
name: name && rest.nameLocation === 'middle' ? name.split('').join('\n') : name,
name,
nameTextStyle: {
fontSize: 12,
color: '#575757'
}
},
(name && rest.nameLocation === 'middle' && transposeNameText) ? {
nameRotate: 0,
name: name.split('').join('\n')
} : {},
typeof splitLine !== 'undefined'
? {
splitLine: _merge(
Expand Down

0 comments on commit 1db822a

Please sign in to comment.