Skip to content

Commit eb52995

Browse files
committed
add maxYvalue property
1 parent 021f06e commit eb52995

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

src/ChartJS/widgets/LineChart/LineChart.xml

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

1010
<properties>
1111
<!-- Appearance -->
12+
<property key="maxYValue" type="string" required="true" defaultValue="0">
13+
<caption>Maximum Y Value</caption>
14+
<category>Appearance</category>
15+
<description>The Maximum Y value on the chart</description>
16+
</property>
1217
<property key="width" type="integer" required="true" defaultValue="500">
1318
<caption>Width</caption>
1419
<category>Appearance</category>

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

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ define([
44
"dojo/_base/lang",
55
"dojo/query",
66
"dojo/on"
7-
], function (declare, Core, lang, domQuery, on) {
7+
], function(declare, Core, lang, domQuery, on) {
88
"use strict";
99

10-
return declare("ChartJS.widgets.LineChart.widget.LineChart", [ Core ], {
10+
return declare("ChartJS.widgets.LineChart.widget.LineChart", [Core], {
1111

1212
_chartType: "line",
1313

14-
_processData : function () {
14+
_processData: function() {
1515
logger.debug(this.id + "._processData");
1616

1717
var sets = [],
1818
points = null,
1919
set = {
20-
points : []
20+
points: []
2121
},
2222
xlabels = [],
2323
xlabelsSet = false,
@@ -86,23 +86,23 @@ define([
8686
}
8787

8888
_set = {
89-
label : (this.scaleShowLabelsBottom === true) ? label : "",
89+
label: (this.scaleShowLabelsBottom === true) ? label : "",
9090
backgroundColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.2") : color,
9191
borderColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.5") : color,
9292
pointColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.8") : color,
9393
pointBorderColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.8") : color,
9494
pointHoverBackgroundColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.75") : highlightcolor,
9595
pointHoverBorderColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(highlightcolor, "1") : highlightcolor,
96-
data : points,
96+
data: points,
9797
fill: this.seriescolorfilled,
98-
tension : this.bezierCurve ? _bezier : 0
98+
tension: this.bezierCurve ? _bezier : 0
9999

100100
};
101101
this._chartData.datasets.push(_set);
102102
this._activeDatasets.push({
103-
dataset : _set,
104-
idx : j,
105-
active : true
103+
dataset: _set,
104+
idx: j,
105+
active: true
106106
});
107107
}
108108
this._chartData.labels = xlabels;
@@ -115,7 +115,7 @@ define([
115115
this._createLegend(false);
116116
},
117117

118-
_createChart : function (data) {
118+
_createChart: function(data) {
119119
logger.debug(this.id + "._createChart");
120120

121121
if (this._chart) {
@@ -132,7 +132,7 @@ define([
132132
data: data,
133133
options: this._chartOptions({
134134

135-
scales : {
135+
scales: {
136136
yAxes: [{
137137
display: this.scaleShow,
138138
//If stacked is set to true, the Y-axis needs to be stacked for it to work
@@ -147,17 +147,18 @@ define([
147147
color: this.scaleGridLineColor,
148148
lineWidth: this.scaleLineWidth
149149
},
150-
ticks : {
150+
ticks: {
151+
max: this.maxYValue * 1, //CC
151152
fontFamily: this._font,
152153
beginAtZero: this.scaleBeginAtZero,
153154
display: this.scaleShowLabels,
154-
callback: lang.hitch(this, function(value){
155-
var round = parseInt(this.roundY);
156-
if (!isNaN(round) && round >= 0) {
157-
return Number(value).toFixed(round);
158-
}
159-
return value;
160-
})
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+
})
161162
}
162163
}],
163164
xAxes: [{
@@ -174,7 +175,7 @@ define([
174175
},
175176
type: "category",
176177
id: "x-axis-0",
177-
ticks : {
178+
ticks: {
178179
display: this.scaleShowLabelsBottom,
179180
fontFamily: this._font,
180181
maxTicksLimit: this.maxTickSize > 0 ? this.maxTickSize : null
@@ -184,33 +185,33 @@ define([
184185

185186
elements: {
186187
point: {
187-
radius : this.pointDot ? this.pointRadius : 0,
188-
borderWidth : this.pointDot ? this.pointBorderWidth : 0,
189-
hitRadius : this.pointHitRadius,
190-
hoverRadius : this.pointHoverRadius,
191-
hoverBorderWidth : this.pointHoverBorderWidth
188+
radius: this.pointDot ? this.pointRadius : 0,
189+
borderWidth: this.pointDot ? this.pointBorderWidth : 0,
190+
hitRadius: this.pointHitRadius,
191+
hoverRadius: this.pointHoverRadius,
192+
hoverBorderWidth: this.pointHoverBorderWidth
192193
}
193194
},
194195

195196
//Boolean - Whether or not to render as a stacked chart
196-
stacked : this.isStacked,
197+
stacked: this.isStacked,
197198

198199
//Boolean - Whether to show a stroke for datasets
199-
datasetStroke : this.datasetStroke,
200+
datasetStroke: this.datasetStroke,
200201

201202
//Number - Pixel width of dataset stroke
202-
datasetStrokeWidth : this.datasetStrokeWidth,
203+
datasetStrokeWidth: this.datasetStrokeWidth,
203204

204205
//Boolean - Whether to fill the dataset with a colour
205-
datasetFill : this.datasetFill,
206+
datasetFill: this.datasetFill,
206207

207-
legendCallback : this._legendCallback,
208+
legendCallback: this._legendCallback,
208209

209210
//The scale line width
210-
scaleLineWidth : this.scaleLineWidth,
211+
scaleLineWidth: this.scaleLineWidth,
211212

212213
//The scale line color
213-
scaleLineColor : this.scaleLineColor
214+
scaleLineColor: this.scaleLineColor
214215
})
215216
};
216217

@@ -220,7 +221,7 @@ define([
220221

221222
this._chart = new this._chartJS(this._ctx, chartProperties);
222223

223-
this.connect(window, "resize", lang.hitch(this, function () {
224+
this.connect(window, "resize", lang.hitch(this, function() {
224225
this._resize();
225226
}));
226227

@@ -234,4 +235,4 @@ define([
234235
});
235236
});
236237

237-
require(["ChartJS/widgets/LineChart/widget/LineChart"]);
238+
require(["ChartJS/widgets/LineChart/widget/LineChart"]);

test/widgets/ChartJS.mpk

-1.01 KB
Binary file not shown.

0 commit comments

Comments
 (0)