Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ChartJS",
"version": "3.2.0",
"version": "3.3.0",
"description": "This widget is a wrapper for the ChartJS library and you can use it to visualize your aggregated data.",
"license": "Apache License, Version 2",
"author": "Mendix",
Expand Down Expand Up @@ -30,4 +30,4 @@
"scripts": {
"test": "grunt test"
}
}
}
20 changes: 20 additions & 0 deletions src/ChartJS/widgets/BarChart/BarChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@
<category>Appearance</category>
<description>Initial width of the chart canvas, will be ignored when responsive property is set to 'Yes'</description>
</property>
<property key="xLabel" type="string" required="false" defaultValue="">
<caption>X-axis label</caption>
<category>Appearance</category>
<description>Label to show on the X-axis. Leave empty for no label</description>
</property>
<property key="yLabel" type="string" required="false" defaultValue="">
<caption>Y-axis label</caption>
<category>Appearance</category>
<description>Label to show on the Y-axis. Leave empty for no label</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="height" type="integer" required="true" defaultValue="250">
<caption>Height</caption>
<category>Appearance</category>
Expand Down
25 changes: 25 additions & 0 deletions src/ChartJS/widgets/BarChart/widget/BarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,31 @@ define([
type: "bar",
data: data,
options: {
title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},
scales : {
xAxes: [{
scaleLabel: {
display: (this.xLabel !== "") ? true : false,
labelString: (this.xLabel !== "") ? this.xLabel : "",
fontFamily: this._font
},
ticks : { fontFamily: this._font, }
}],
yAxes: [{
scaleLabel: {
display: (this.yLabel !== "") ? true : false,
labelString: (this.yLabel !== "") ? this.yLabel : "",
fontFamily: this._font
},
ticks : { fontFamily: this._font, }
}],

},

responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
Expand Down
10 changes: 10 additions & 0 deletions src/ChartJS/widgets/DoughnutChart/DoughnutChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<category>Appearance</category>
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
<caption>Responsive animation duration</caption>
<category>Appearance</category>
Expand Down
6 changes: 6 additions & 0 deletions src/ChartJS/widgets/DoughnutChart/widget/DoughnutChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ define([
type: "doughnut",
data: this._createDataSets(data),
options: {
title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},

responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
Expand Down
20 changes: 20 additions & 0 deletions src/ChartJS/widgets/LineChart/LineChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
<category>Appearance</category>
<description>Initial width of the chart canvas, will be ignored when responsive property is set to 'Yes'</description>
</property>
<property key="xLabel" type="string" required="false" defaultValue="">
<caption>X-axis label</caption>
<category>Appearance</category>
<description>Label to show on the X-axis. Leave empty for no label</description>
</property>
<property key="yLabel" type="string" required="false" defaultValue="">
<caption>Y-axis label</caption>
<category>Appearance</category>
<description>Label to show on the Y-axis. Leave empty for no label</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="isStacked" type="boolean" required="true" defaultValue="false">
<caption>Stacked</caption>
<category>Appearance</category>
Expand Down
60 changes: 36 additions & 24 deletions src/ChartJS/widgets/LineChart/widget/LineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,46 @@ define([
this._chart.update(1000);
this._chart.bindEvents(); // tooltips otherwise won't work
} else {
logger.debug("stacked:" + this.isStacked);
logger.debug("stacked:" + this.isStacked);
this._chart = new this._chartJS(this._ctx, {
type: "line",
data: data,
options: {

title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},
scales : {
yAxes: [{
//If stacked is set to true, the Y-axis needs to be stacked for it to work
stacked: this.isStacked,
scaleLabel: {
display: (this.yLabel !== "") ? true : false,
labelString: (this.yLabel !== "") ? this.yLabel : "",
fontFamily: this._font
},
ticks : { fontFamily: this._font,
callback: lang.hitch(this, function(value){
var round = parseInt(this.roundY);
if (!isNaN(round) && round >= 0) {
return Number(value).toFixed(round);
}
return value;
}) }
}],
xAxes: [{
scaleLabel: {
display: (this.xLabel !== "") ? true : false,
labelString: (this.xLabel !== "") ? this.xLabel : "",
fontFamily: this._font
},
type: "category",
id: "x-axis-0",
ticks : { fontFamily: this._font, }
}]
},
responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
tooltips : {
Expand Down Expand Up @@ -193,28 +227,6 @@ define([
// Custom tooltip?
customTooltips : false, //lang.hitch(this, this.customTooltip)

scales: {
xAxes: [{
type: "category",
id: "x-axis-0"
}],
yAxes: [{
//If stacked is set to true, the Y-axis needs to be stacked for it to work
stacked: this.isStacked,
ticks:{
callback: lang.hitch(this, function(value){
var round = parseInt(this.roundY);
if (!isNaN(round) && round >= 0) {
return Number(value).toFixed(round);
}
return value;
})
},
type: "linear",
id: "y-axis-0"
}],
}

}
});

Expand Down
10 changes: 10 additions & 0 deletions src/ChartJS/widgets/PieChart/PieChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
<category>Appearance</category>
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
<caption>Responsive animation duration</caption>
<category>Appearance</category>
Expand Down
6 changes: 6 additions & 0 deletions src/ChartJS/widgets/PieChart/widget/PieChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ define([
type: "pie",
data: this._createDataSets(data),
options: {
title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},

responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
Expand Down
10 changes: 10 additions & 0 deletions src/ChartJS/widgets/PolarChart/PolarChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<category>Appearance</category>
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
<caption>Responsive animation duration</caption>
<category>Appearance</category>
Expand Down
6 changes: 6 additions & 0 deletions src/ChartJS/widgets/PolarChart/widget/PolarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ define([
type: "polarArea",
data: this._createDataSets(data),
options: {
title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},

responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
Expand Down
10 changes: 10 additions & 0 deletions src/ChartJS/widgets/RadarChart/RadarChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<category>Appearance</category>
<description>Font used in the chart legend. Default (or empty) = Helvetica Neue</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="responsiveAnimationDuration" type="integer" required="true" defaultValue="0">
<caption>Responsive animation duration</caption>
<category>Appearance</category>
Expand Down
6 changes: 6 additions & 0 deletions src/ChartJS/widgets/RadarChart/widget/RadarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ define([
type: "radar",
data: data,
options: {
title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},

responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
Expand Down
20 changes: 20 additions & 0 deletions src/ChartJS/widgets/StackedBarChart/StackedBarChart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@
<category>Appearance</category>
<description>Initial height of the chart canvas, will be ignored when responsive property is set to 'Yes'</description>
</property>
<property key="xLabel" type="string" required="false" defaultValue="">
<caption>X-axis label</caption>
<category>Appearance</category>
<description>Label to show on the X-axis. Leave empty for no label</description>
</property>
<property key="yLabel" type="string" required="false" defaultValue="">
<caption>Y-axis label</caption>
<category>Appearance</category>
<description>Label to show on the Y-axis. Leave empty for no label</description>
</property>
<property key="chartTitle" type="string" required="false" defaultValue="">
<caption>Title</caption>
<category>Appearance</category>
<description>The title of the chart. Will be shown above the chart. Leave empty for no title</description>
</property>
<property key="titleSize" type="integer" required="true" defaultValue="12">
<caption>Title font-size</caption>
<category>Appearance</category>
<description>The size of the chart title. Default is 12</description>
</property>
<property key="labelFont" type="string" required="true" defaultValue="Helvetica Neue">
<caption>Font</caption>
<category>Appearance</category>
Expand Down
49 changes: 32 additions & 17 deletions src/ChartJS/widgets/StackedBarChart/widget/StackedBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,38 @@ define([
type: "bar",
data: data,
options: {

title: {
display: (this.chartTitle !== "") ? true : false,
text: (this.chartTitle !== "") ? this.chartTitle : "",
fontFamily: this._font,
fontSize: this.titleSize
},
scales: {
xAxes: [{
stacked: true,
scaleLabel: {
display: (this.xLabel !== "") ? true : false,
labelString: (this.xLabel !== "") ? this.xLabel : "",
fontFamily: this._font
},
ticks: {
fontFamily :this._font
//beginAtZero: true
}
}],
yAxes: [{
stacked: true,
scaleLabel: {
display: (this.yLabel !== "") ? true : false,
labelString: (this.yLabel !== "") ? this.yLabel : "",
fontFamily: this._font
},
ticks: {
fontFamily: this._font
//suggestedMax: 10
}
}]
},
responsive : this.responsive,
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
tooltips : {
Expand Down Expand Up @@ -169,22 +200,6 @@ define([

// Custom tooltip?
customTooltips : false, //lang.hitch(this, this.customTooltip)

scales: {
xAxes: [{
stacked: true,
ticks: {
//beginAtZero: true
}
}],
yAxes: [{
stacked: true,
ticks: {
//suggestedMax: 10
}
}]
}

}
});
}
Expand Down
Loading