Skip to content

Commit 2327027

Browse files
author
Jelte Lagendijk
committed
Fix issues with Begin at zero, fix #72 and partial #67
1 parent 082427d commit 2327027

File tree

6 files changed

+38
-23
lines changed

6 files changed

+38
-23
lines changed

src/ChartJS/widgets/BarChart/widget/BarChart.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ define([
130130
labelString: (this.yLabel !== "") ? this.yLabel : "",
131131
fontFamily: this._font
132132
},
133-
ticks : { fontFamily: this._font, }
133+
ticks : {
134+
fontFamily: this._font,
135+
beginAtZero: this.scaleBeginAtZero
136+
}
134137
}],
135138

136139
},
@@ -148,9 +151,6 @@ define([
148151
//Boolean - Whether to show labels on the scale
149152
scaleShowLabels : this.scaleShowLabels,
150153

151-
//Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
152-
scaleBeginAtZero : this.scaleBeginAtZero,
153-
154154
//Boolean - Whether grid lines are shown across the chart
155155
scaleShowGridLines : this.scaleShowGridLines,
156156

src/ChartJS/widgets/LineChart/widget/LineChart.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,17 @@ define([
141141
labelString: (this.yLabel !== "") ? this.yLabel : "",
142142
fontFamily: this._font
143143
},
144-
ticks : { fontFamily: this._font,
145-
callback: lang.hitch(this, function(value){
146-
var round = parseInt(this.roundY);
147-
if (!isNaN(round) && round >= 0) {
148-
return Number(value).toFixed(round);
149-
}
150-
return value;
151-
}) }
144+
ticks : {
145+
fontFamily: this._font,
146+
beginAtZero: this.scaleBeginAtZero,
147+
callback: lang.hitch(this, function(value){
148+
var round = parseInt(this.roundY);
149+
if (!isNaN(round) && round >= 0) {
150+
return Number(value).toFixed(round);
151+
}
152+
return value;
153+
})
154+
}
152155
}],
153156
xAxes: [{
154157
scaleLabel: {

src/ChartJS/widgets/PolarChart/widget/PolarChart.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,23 @@ define([
113113
display: this.showLegend,
114114
labels : { fontFamily : this._font }
115115
},
116+
scale: {
117+
ticks: {
118+
yAxes: [{
119+
ticks: {
120+
fontFamily: this._font,
121+
beginAtZero: this.scaleBeginAtZero
122+
}
123+
}]
124+
}
125+
},
116126

117127
//Boolean - Show a backdrop to the scale label
118128
scaleShowLabelBackdrop : this.polarScaleShowLabelBackdrop,
119129

120130
//String - The colour of the label backdrop
121131
scaleBackdropColor : this.polarScaleBackdropColor,
122132

123-
// Boolean - Whether the scale should begin at zero
124-
scaleBeginAtZero : this.polarScaleBeginAtZero,
125-
126133
//Number - The backdrop padding above & below the label in pixels
127134
scaleBackdropPaddingY : this.polarScaleBackdropPaddingY,
128135

src/ChartJS/widgets/RadarChart/widget/RadarChart.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ define([
129129
labels : { fontFamily : this._font }
130130
},
131131

132+
scale: {
133+
ticks: {
134+
yAxes: [{
135+
ticks: {
136+
fontFamily: this._font,
137+
beginAtZero: this.scaleBeginAtZero
138+
}
139+
}]
140+
}
141+
},
142+
132143
//Boolean - Whether to show lines for each scale point
133144
scaleShowLine : this.scaleShowLine,
134145

@@ -138,9 +149,6 @@ define([
138149
//Boolean - Whether to show labels on the scale
139150
scaleShowLabels : this.scaleShowLabels,
140151

141-
// Boolean - Whether the scale should begin at zero
142-
scaleBeginAtZero : this.scaleBeginAtZero,
143-
144152
//String - Colour of the angle line
145153
angleLineColor : this.angleLineColor,
146154

src/ChartJS/widgets/StackedBarChart/widget/StackedBarChart.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ define([
138138
fontFamily: this._font
139139
},
140140
ticks: {
141-
fontFamily: this._font
142-
//suggestedMax: 10
141+
fontFamily: this._font,
142+
beginAtZero: this.scaleBeginAtZero
143143
}
144144
}]
145145
},
@@ -158,9 +158,6 @@ define([
158158
//Boolean - Whether to show labels on the scale
159159
scaleShowLabels : this.scaleShowLabels,
160160

161-
//Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
162-
scaleBeginAtZero : this.scaleBeginAtZero,
163-
164161
//Boolean - Whether grid lines are shown across the chart
165162
scaleShowGridLines : this.scaleShowGridLines,
166163

test/widgets/ChartJS.mpk

64 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)