Skip to content

Commit 77724c6

Browse files
authored
Added x axis labels rotation (#245)
* Added x axis labels rotation * PR changes * Fixed bugs related to axis title and label rotation
1 parent 422c08b commit 77724c6

5 files changed

Lines changed: 257 additions & 109 deletions

File tree

capabilities.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@
180180
"type": {
181181
"bool": true
182182
}
183+
},
184+
"labelOrientationMode": {
185+
"type": {
186+
"text": true
187+
},
188+
"suppressFormatPainterCopy": true
183189
}
184190
}
185191
},

src/streamGraphSettingsModel.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ILocalizationManager = powerbi.extensibility.ILocalizationManager;
33

44
import { formattingSettings } from "powerbi-visuals-utils-formattingmodel";
55
import { legendInterfaces } from "powerbi-visuals-utils-chartutils";
6-
import { DataOrder, DataOffset } from "./utils";
6+
import { DataOrder, DataOffset,LabelOrientationMode } from "./utils";
77
import { StreamGraphSeries } from "./dataInterfaces";
88
import LegendPosition = legendInterfaces.LegendPosition;
99

@@ -31,6 +31,11 @@ const dataOffsetOptions : IEnumMemberWithDisplayNameKey[] = [
3131
{value : DataOffset[DataOffset.Expand], displayName : "Expand", key: "Visual_DataOffset_Expand"}
3232
];
3333

34+
const labelOrientationModeOptions : IEnumMemberWithDisplayNameKey[] = [
35+
{value : LabelOrientationMode[LabelOrientationMode.Default], displayName : "Default (Auto)", key: "Visual_LabelOrientation_Default"},
36+
{value : LabelOrientationMode[LabelOrientationMode.ForceRotate], displayName : "Force Rotate", key: "Visual_LabelOrientation_ForceRotate"}
37+
];
38+
3439
export class BaseFontCardSettings extends Card {
3540
public fontFamily: formattingSettings.FontPicker;
3641
public fontSize: formattingSettings.NumUpDown;
@@ -59,7 +64,7 @@ export class BaseFontCardSettings extends Card {
5964
},
6065
maxValue: {
6166
type: powerbi.visuals.ValidatorType.Max,
62-
value: 60,
67+
value: 30,
6368
}
6469
}
6570
});
@@ -114,14 +119,19 @@ class AxisTitleGroup extends BaseFontCardSettings {
114119
}
115120

116121
class AxisOptionsGroup extends BaseFontCardSettings {
117-
constructor(settingName: string, useHighPrecision: boolean = false){
122+
constructor(settingName: string, useHighPrecision: boolean = false, showLabelOrientation: boolean = false){
118123
super();
119124

120125
this.name = `optionsGroup${settingName}`;
121126
this.displayNameKey = `Visual_Values`;
122127
this.topLevelSlice = this.show;
123128

124-
this.slices = [...(useHighPrecision ? [this.highPrecision] : []), this.font, this.labelColor];
129+
this.slices = [
130+
...(useHighPrecision ? [this.highPrecision] : []),
131+
this.font,
132+
this.labelColor,
133+
...(showLabelOrientation ? [this.labelOrientationMode] : [])
134+
];
125135
}
126136

127137
public show = new formattingSettings.ToggleSwitch({
@@ -144,6 +154,14 @@ class AxisOptionsGroup extends BaseFontCardSettings {
144154
displayNameKey: "Visual_HighPrecision",
145155
value: false,
146156
});
157+
158+
public labelOrientationMode = new formattingSettings.ItemDropdown({
159+
items: labelOrientationModeOptions,
160+
value: labelOrientationModeOptions[0],
161+
displayName: "Label Orientation",
162+
displayNameKey: "Visual_LabelOrientation",
163+
name: "labelOrientationMode"
164+
});
147165
}
148166

149167
export class GeneralCardSettings extends Card {
@@ -184,13 +202,13 @@ export class BaseAxisCardSettings extends CompositeCard {
184202
public options: AxisOptionsGroup;
185203
public groups: Group[];
186204

187-
constructor(name: string, displayNameKey: string, useHighPrecision: boolean = false){
205+
constructor(name: string, displayNameKey: string, useHighPrecision: boolean = false, showLabelOrientation: boolean = false){
188206
super();
189207

190208
this.name = name;
191209
this.displayNameKey = displayNameKey;
192210
this.title = new AxisTitleGroup(name);
193-
this.options = new AxisOptionsGroup(name, useHighPrecision);
211+
this.options = new AxisOptionsGroup(name, useHighPrecision, showLabelOrientation);
194212
this.groups = [this.options, this.title];
195213
}
196214
}
@@ -360,7 +378,7 @@ export class StreamCardSettings extends CompositeCard {
360378

361379
export class StreamGraphSettingsModel extends Model {
362380
general = new GeneralCardSettings();
363-
categoryAxis = new BaseAxisCardSettings("categoryAxis", "Visual_XAxis");
381+
categoryAxis = new BaseAxisCardSettings("categoryAxis", "Visual_XAxis", false, true);
364382
valueAxis = new BaseAxisCardSettings("valueAxis", "Visual_YAxis", true);
365383
legend = new LegendCardSettings();
366384
dataLabels = new DataLabelsCardSettings();
@@ -379,6 +397,7 @@ export class StreamGraphSettingsModel extends Model {
379397
public setLocalizedOptions(localizationManager: ILocalizationManager) {
380398
this.setLocalizedDisplayName(dataOrderOptions, localizationManager);
381399
this.setLocalizedDisplayName(dataOffsetOptions, localizationManager);
400+
this.setLocalizedDisplayName(labelOrientationModeOptions, localizationManager);
382401
}
383402

384403
private setLocalizedDisplayName(options: IEnumMemberWithDisplayNameKey[], localizationManager: ILocalizationManager) {

src/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ export enum DataOffset {
5353
Silhouette = 1,
5454
Expand = 2
5555
}
56+
57+
export enum LabelOrientationMode {
58+
Default = 0,
59+
ForceRotate = 1
60+
}

0 commit comments

Comments
 (0)