Skip to content

Commit 3e9b470

Browse files
author
Jelte Lagendijk
committed
Merge branch 'Mcpoowl-master'
2 parents c2a7ded + 78c7cc0 commit 3e9b470

File tree

18 files changed

+221
-45
lines changed

18 files changed

+221
-45
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ChartJS",
3-
"version": "3.2.0",
3+
"version": "3.3.0",
44
"description": "This widget is a wrapper for the ChartJS library and you can use it to visualize your aggregated data.",
55
"license": "Apache License, Version 2",
66
"author": "Mendix",
@@ -30,4 +30,4 @@
3030
"scripts": {
3131
"test": "grunt test"
3232
}
33-
}
33+
}

src/ChartJS/widgets/BarChart/BarChart.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@
1212
<category>Appearance</category>
1313
<description>Initial width of the chart canvas, will be ignored when responsive property is set to 'Yes'</description>
1414
</property>
15+
<property key="xLabel" type="string" required="false" defaultValue="">
16+
<caption>X-axis label</caption>
17+
<category>Appearance</category>
18+
<description>Label to show on the X-axis. Leave empty for no label</description>
19+
</property>
20+
<property key="yLabel" type="string" required="false" defaultValue="">
21+
<caption>Y-axis label</caption>
22+
<category>Appearance</category>
23+
<description>Label to show on the Y-axis. Leave empty for no label</description>
24+
</property>
25+
<property key="chartTitle" type="string" required="false" defaultValue="">
26+
<caption>Title</caption>
27+
<category>Appearance</category>
28+
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
29+
</property>
30+
<property key="titleSize" type="integer" required="true" defaultValue="12">
31+
<caption>Title font-size</caption>
32+
<category>Appearance</category>
33+
<description>The size of the chart title. Default is 12</description>
34+
</property>
1535
<property key="height" type="integer" required="true" defaultValue="250">
1636
<caption>Height</caption>
1737
<category>Appearance</category>

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,31 @@ define([
108108
type: "bar",
109109
data: data,
110110
options: {
111+
title: {
112+
display: (this.chartTitle !== "") ? true : false,
113+
text: (this.chartTitle !== "") ? this.chartTitle : "",
114+
fontFamily: this._font,
115+
fontSize: this.titleSize
116+
},
117+
scales : {
118+
xAxes: [{
119+
scaleLabel: {
120+
display: (this.xLabel !== "") ? true : false,
121+
labelString: (this.xLabel !== "") ? this.xLabel : "",
122+
fontFamily: this._font
123+
},
124+
ticks : { fontFamily: this._font, }
125+
}],
126+
yAxes: [{
127+
scaleLabel: {
128+
display: (this.yLabel !== "") ? true : false,
129+
labelString: (this.yLabel !== "") ? this.yLabel : "",
130+
fontFamily: this._font
131+
},
132+
ticks : { fontFamily: this._font, }
133+
}],
134+
135+
},
111136

112137
responsive : this.responsive,
113138
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),

src/ChartJS/widgets/DoughnutChart/DoughnutChart.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
<category>Appearance</category>
2323
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
2424
</property>
25+
<property key="chartTitle" type="string" required="false" defaultValue="">
26+
<caption>Title</caption>
27+
<category>Appearance</category>
28+
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
29+
</property>
30+
<property key="titleSize" type="integer" required="true" defaultValue="12">
31+
<caption>Title font-size</caption>
32+
<category>Appearance</category>
33+
<description>The size of the chart title. Default is 12</description>
34+
</property>
2535
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
2636
<caption>Responsive animation duration</caption>
2737
<category>Appearance</category>

src/ChartJS/widgets/DoughnutChart/widget/DoughnutChart.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ define([
9999
type: "doughnut",
100100
data: this._createDataSets(data),
101101
options: {
102+
title: {
103+
display: (this.chartTitle !== "") ? true : false,
104+
text: (this.chartTitle !== "") ? this.chartTitle : "",
105+
fontFamily: this._font,
106+
fontSize: this.titleSize
107+
},
102108

103109
responsive : this.responsive,
104110
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),

src/ChartJS/widgets/LineChart/LineChart.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@
1414
<category>Appearance</category>
1515
<description>Initial width of the chart canvas, will be ignored when responsive property is set to 'Yes'</description>
1616
</property>
17+
<property key="xLabel" type="string" required="false" defaultValue="">
18+
<caption>X-axis label</caption>
19+
<category>Appearance</category>
20+
<description>Label to show on the X-axis. Leave empty for no label</description>
21+
</property>
22+
<property key="yLabel" type="string" required="false" defaultValue="">
23+
<caption>Y-axis label</caption>
24+
<category>Appearance</category>
25+
<description>Label to show on the Y-axis. Leave empty for no label</description>
26+
</property>
27+
<property key="chartTitle" type="string" required="false" defaultValue="">
28+
<caption>Title</caption>
29+
<category>Appearance</category>
30+
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
31+
</property>
32+
<property key="titleSize" type="integer" required="true" defaultValue="12">
33+
<caption>Title font-size</caption>
34+
<category>Appearance</category>
35+
<description>The size of the chart title. Default is 12</description>
36+
</property>
1737
<property key="isStacked" type="boolean" required="true" defaultValue="false">
1838
<caption>Stacked</caption>
1939
<category>Appearance</category>

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

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,46 @@ define([
118118
this._chart.update(1000);
119119
this._chart.bindEvents(); // tooltips otherwise won't work
120120
} else {
121-
logger.debug("stacked:" + this.isStacked);
121+
logger.debug("stacked:" + this.isStacked);
122122
this._chart = new this._chartJS(this._ctx, {
123123
type: "line",
124124
data: data,
125125
options: {
126-
126+
title: {
127+
display: (this.chartTitle !== "") ? true : false,
128+
text: (this.chartTitle !== "") ? this.chartTitle : "",
129+
fontFamily: this._font,
130+
fontSize: this.titleSize
131+
},
132+
scales : {
133+
yAxes: [{
134+
//If stacked is set to true, the Y-axis needs to be stacked for it to work
135+
stacked: this.isStacked,
136+
scaleLabel: {
137+
display: (this.yLabel !== "") ? true : false,
138+
labelString: (this.yLabel !== "") ? this.yLabel : "",
139+
fontFamily: this._font
140+
},
141+
ticks : { fontFamily: this._font,
142+
callback: lang.hitch(this, function(value){
143+
var round = parseInt(this.roundY);
144+
if (!isNaN(round) && round >= 0) {
145+
return Number(value).toFixed(round);
146+
}
147+
return value;
148+
}) }
149+
}],
150+
xAxes: [{
151+
scaleLabel: {
152+
display: (this.xLabel !== "") ? true : false,
153+
labelString: (this.xLabel !== "") ? this.xLabel : "",
154+
fontFamily: this._font
155+
},
156+
type: "category",
157+
id: "x-axis-0",
158+
ticks : { fontFamily: this._font, }
159+
}]
160+
},
127161
responsive : this.responsive,
128162
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
129163
tooltips : {
@@ -193,28 +227,6 @@ define([
193227
// Custom tooltip?
194228
customTooltips : false, //lang.hitch(this, this.customTooltip)
195229

196-
scales: {
197-
xAxes: [{
198-
type: "category",
199-
id: "x-axis-0"
200-
}],
201-
yAxes: [{
202-
//If stacked is set to true, the Y-axis needs to be stacked for it to work
203-
stacked: this.isStacked,
204-
ticks:{
205-
callback: lang.hitch(this, function(value){
206-
var round = parseInt(this.roundY);
207-
if (!isNaN(round) && round >= 0) {
208-
return Number(value).toFixed(round);
209-
}
210-
return value;
211-
})
212-
},
213-
type: "linear",
214-
id: "y-axis-0"
215-
}],
216-
}
217-
218230
}
219231
});
220232

src/ChartJS/widgets/PieChart/PieChart.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
<category>Appearance</category>
2626
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
2727
</property>
28+
<property key="chartTitle" type="string" required="false" defaultValue="">
29+
<caption>Title</caption>
30+
<category>Appearance</category>
31+
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
32+
</property>
33+
<property key="titleSize" type="integer" required="true" defaultValue="12">
34+
<caption>Title font-size</caption>
35+
<category>Appearance</category>
36+
<description>The size of the chart title. Default is 12</description>
37+
</property>
2838
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
2939
<caption>Responsive animation duration</caption>
3040
<category>Appearance</category>

src/ChartJS/widgets/PieChart/widget/PieChart.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ define([
9595
type: "pie",
9696
data: this._createDataSets(data),
9797
options: {
98+
title: {
99+
display: (this.chartTitle !== "") ? true : false,
100+
text: (this.chartTitle !== "") ? this.chartTitle : "",
101+
fontFamily: this._font,
102+
fontSize: this.titleSize
103+
},
98104

99105
responsive : this.responsive,
100106
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),

src/ChartJS/widgets/PolarChart/PolarChart.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
<category>Appearance</category>
2323
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
2424
</property>
25+
<property key="chartTitle" type="string" required="false" defaultValue="">
26+
<caption>Title</caption>
27+
<category>Appearance</category>
28+
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
29+
</property>
30+
<property key="titleSize" type="integer" required="true" defaultValue="12">
31+
<caption>Title font-size</caption>
32+
<category>Appearance</category>
33+
<description>The size of the chart title. Default is 12</description>
34+
</property>
2535
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
2636
<caption>Responsive animation duration</caption>
2737
<category>Appearance</category>

0 commit comments

Comments
 (0)