Skip to content

Commit 226d24d

Browse files
committed
fix maxYValue
1 parent bb103e4 commit 226d24d

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

src/ChartJS/widgets/LineChart/LineChart.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
<properties>
1111
<!-- Appearance -->
12-
<!-- <property key="maxYValue" type="string" required="true" defaultValue="0">
12+
<property key="maxYValue" type="string" required="false" defaultValue="">
1313
<caption>Maximum Y Value</caption>
1414
<category>Appearance</category>
15-
<description>The Maximum Y value on the chart</description>
16-
</property> -->
15+
<description>The Maximum Y value on the chart. Leave empty to set to the max value in your dataset</description>
16+
</property>
1717
<property key="width" type="integer" required="true" defaultValue="500">
1818
<caption>Width</caption>
1919
<category>Appearance</category>

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ define([
127127
} else {
128128
//logger.debug("stacked:" + this.isStacked);
129129

130+
var ticksOptions = {
131+
fontFamily: this._font,
132+
beginAtZero: this.scaleBeginAtZero,
133+
display: this.scaleShowLabels,
134+
callback: lang.hitch(this, function(value) {
135+
var round = parseInt(this.roundY);
136+
if (!isNaN(round) && round >= 0) {
137+
return Number(value).toFixed(round);
138+
}
139+
return value;
140+
})
141+
};
142+
if (this.maxYValue) {
143+
ticksOptions.max = this.maxYValue * 1;
144+
}
145+
130146
var chartProperties = {
131147
type: this._chartType,
132148
data: data,
@@ -147,19 +163,7 @@ define([
147163
color: this.scaleGridLineColor,
148164
lineWidth: this.scaleLineWidth
149165
},
150-
ticks: {
151-
// max: (this.maxYValue ? this.maxYValue * 1 : false), //CC
152-
fontFamily: this._font,
153-
beginAtZero: this.scaleBeginAtZero,
154-
display: this.scaleShowLabels,
155-
callback: lang.hitch(this, function(value) {
156-
var round = parseInt(this.roundY);
157-
if (!isNaN(round) && round >= 0) {
158-
return Number(value).toFixed(round);
159-
}
160-
return value;
161-
})
162-
}
166+
ticks: ticksOptions
163167
}],
164168
xAxes: [{
165169
display: this.scaleShow,

test/[Test] ChartJS.mpr

0 Bytes
Binary file not shown.

test/widgets/ChartJS.mpk

7 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)