Skip to content

Commit 7fad1a2

Browse files
author
Jelte Lagendijk
committed
Reverting #62, setting rounding on Y-value in Modeler
1 parent 798db99 commit 7fad1a2

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

src/ChartJS/lib/charts.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4685,10 +4685,6 @@
46854685
id: 'x-axis-0'
46864686
}],
46874687
yAxes: [{
4688-
ticks:{
4689-
callback:function(value){
4690-
return Number(value).toFixed(3);
4691-
}},
46924688
type: "linear",
46934689
id: 'y-axis-0'
46944690
}],

src/ChartJS/widgets/Core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define([
6161

6262
startup: function () {
6363
// Uncomment line to start debugging
64-
//logger.level(logger.DEBUG);
64+
logger.level(logger.DEBUG);
6565
logger.debug(this.id + ".startup");
6666

6767
var domNode = null;

src/ChartJS/widgets/LineChart/LineChart.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
<attributeType name="Decimal"/>
163163
</attributeTypes>
164164
</property>
165+
<property key="roundY" type="string" required="true" defaultValue="-1">
166+
<caption>Round Y value</caption>
167+
<category>Data Point</category>
168+
<description>Number of decimals to round the value on the Y-axis. Disable it by setting it to '-1'</description>
169+
</property>
165170
<!-- Behavior -->
166171
<property key="onclickmf" type="microflow" required="false">
167172
<caption>On Click Microflow</caption>

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,26 @@ define([
187187
maintainAspectRatio : this.maintainAspectRatio,
188188

189189
// Custom tooltip?
190-
customTooltips : false //lang.hitch(this, this.customTooltip)
190+
customTooltips : false, //lang.hitch(this, this.customTooltip)
191+
192+
scales: {
193+
xAxes: [{
194+
type: "category",
195+
id: "x-axis-0"
196+
}],
197+
yAxes: [{
198+
ticks:{
199+
callback: lang.hitch(this, function(value){
200+
var round = parseInt(this.roundY);
201+
if (!isNaN(round) && round >= 0) {
202+
return Number(value).toFixed(round);
203+
}
204+
return value;
205+
})},
206+
type: "linear",
207+
id: "y-axis-0"
208+
}],
209+
}
191210

192211
}
193212
});

test/[Test] ChartJS.mpr

10 KB
Binary file not shown.

test/widgets/ChartJS.mpk

153 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)