Skip to content

Commit

Permalink
fix maxYValue
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcharlebois committed Nov 10, 2017
1 parent bb103e4 commit 226d24d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/ChartJS/widgets/LineChart/LineChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

<properties>
<!-- Appearance -->
<!-- <property key="maxYValue" type="string" required="true" defaultValue="0">
<property key="maxYValue" type="string" required="false" defaultValue="">
<caption>Maximum Y Value</caption>
<category>Appearance</category>
<description>The Maximum Y value on the chart</description>
</property> -->
<description>The Maximum Y value on the chart. Leave empty to set to the max value in your dataset</description>
</property>
<property key="width" type="integer" required="true" defaultValue="500">
<caption>Width</caption>
<category>Appearance</category>
Expand Down
30 changes: 17 additions & 13 deletions src/ChartJS/widgets/LineChart/widget/LineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ define([
} else {
//logger.debug("stacked:" + this.isStacked);

var ticksOptions = {
fontFamily: this._font,
beginAtZero: this.scaleBeginAtZero,
display: this.scaleShowLabels,
callback: lang.hitch(this, function(value) {
var round = parseInt(this.roundY);
if (!isNaN(round) && round >= 0) {
return Number(value).toFixed(round);
}
return value;
})
};
if (this.maxYValue) {
ticksOptions.max = this.maxYValue * 1;
}

var chartProperties = {
type: this._chartType,
data: data,
Expand All @@ -147,19 +163,7 @@ define([
color: this.scaleGridLineColor,
lineWidth: this.scaleLineWidth
},
ticks: {
// max: (this.maxYValue ? this.maxYValue * 1 : false), //CC
fontFamily: this._font,
beginAtZero: this.scaleBeginAtZero,
display: this.scaleShowLabels,
callback: lang.hitch(this, function(value) {
var round = parseInt(this.roundY);
if (!isNaN(round) && round >= 0) {
return Number(value).toFixed(round);
}
return value;
})
}
ticks: ticksOptions
}],
xAxes: [{
display: this.scaleShow,
Expand Down
Binary file modified test/[Test] ChartJS.mpr
Binary file not shown.
Binary file modified test/widgets/ChartJS.mpk
Binary file not shown.

0 comments on commit 226d24d

Please sign in to comment.