Skip to content

Commit 1c8ff93

Browse files
committed
feature(chart): set range for value axis
1 parent bea6755 commit 1c8ff93

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/helper/modify-chart-helper.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ChartBubble,
66
ChartSlot,
77
ChartCategory,
8-
ChartSeries, ChartPoint,
8+
ChartSeries, ChartPoint, ChartAxisRange,
99
} from '../types/chart-types';
1010
import { vd } from './general-helper';
1111
import {XmlHelper} from './xml-helper';
@@ -193,4 +193,19 @@ export default class ModifyChartHelper {
193193

194194
// XmlHelper.dump(chart)
195195
};
196+
197+
static setAxisRange = (range: ChartAxisRange) => (
198+
chart: XMLDocument,
199+
): void => {
200+
const axis = chart.getElementsByTagName('c:valAx')[range.axisIndex || 0]
201+
if(!axis) return
202+
203+
const scaling = axis.getElementsByTagName('c:scaling')[0]
204+
205+
scaling.getElementsByTagName('c:min')[0]
206+
.setAttribute('val', String(range.min))
207+
scaling.getElementsByTagName('c:max')[0]
208+
.setAttribute('val', String(range.max))
209+
}
210+
196211
}

src/types/chart-types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ export type ChartSlot = {
7171
tag?: string;
7272
isStrRef?: boolean;
7373
};
74+
export type ChartAxisRange = {
75+
axisIndex?: number;
76+
min:number;
77+
max:number;
78+
}

0 commit comments

Comments
 (0)