Skip to content

Commit 044e81f

Browse files
committed
Stacked linechart and reduce opacity fix
Added functionality for a stacked Linechart and fixed the reduce opacity option (Setting this option to No didn't do anything
1 parent 798db99 commit 044e81f

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

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
@@ -14,6 +14,11 @@
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="isStacked" type="boolean" required="true" defaultValue="false">
18+
<caption>Stacked</caption>
19+
<category>Appearance</category>
20+
<description>When yes, different dataset will stack on top of eachother on the Y-axis</description>
21+
</property>
1722
<property key="height" type="integer" required="true" defaultValue="250">
1823
<caption>Height</caption>
1924
<category>Appearance</category>

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ define([
8080

8181
_set = {
8282
label : (this.scaleShowLabelsBottom === true) ? label : "",
83-
backgroundColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.2") : this._hexToRgb(color, "0.2"),
83+
backgroundColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.2") : color,
8484
borderColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.5") : color,
8585
pointColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.8") : color,
8686
pointBorderColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.8") : color,
@@ -110,18 +110,25 @@ define([
110110
_createChart : function (data) {
111111
logger.debug(this.id + "._createChart");
112112

113+
113114
if (this._chart) {
114115
this._chart.stop();
115116
this._chart.data.datasets = data.datasets;
116117
this._chart.data.labels = data.labels;
117118
this._chart.update(1000);
118119
this._chart.bindEvents(); // tooltips otherwise won't work
119120
} else {
120-
121+
logger.debug("stacked:" + this.isStacked);
121122
this._chart = new this._chartJS(this._ctx, {
122123
type: "line",
123124
data: data,
124125
options: {
126+
scales : {
127+
yAxes: [{
128+
//If stacked is set to true, the Y-axis needs to be stacked for it to work
129+
stacked: this.isStacked
130+
}]
131+
},
125132

126133
responsive : this.responsive,
127134
responsiveAnimationDuration : (this.responsiveAnimationDuration > 0 ? this.responsiveAnimationDuration : 0),
@@ -151,6 +158,9 @@ define([
151158
//Boolean - Whether to show vertical lines (except Y axis)
152159
scaleShowVerticalLines : this.scaleShowVerticalLines,
153160

161+
//Boolean - Whether or not to render as a stacked chart
162+
stacked : this.isStacked,
163+
154164
//Boolean - Whether to show a dot for each point
155165
pointDot : this.pointDot,
156166

test/widgets/ChartJS.mpk

204 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)