Skip to content

Commit 9ce97e0

Browse files
author
Jelte Lagendijk
committed
Add Show dot option on Linechart, fix #71
1 parent 5254c72 commit 9ce97e0

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/ChartJS/widgets/LineChart/LineChart.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,15 @@
296296
<category>Settings Line Chart</category>
297297
<description>Tension of the bezier curve between points. (This is usually around 0.4 or lower)</description>
298298
</property>
299+
<property key="pointDot" type="boolean" required="true" defaultValue="true">
300+
<caption>Show dot</caption>
301+
<category>Data Point</category>
302+
<description>Show dots on a data point.</description>
303+
</property>
299304
<property key="pointRadius" type="integer" required="true" defaultValue="3">
300305
<caption>Dot radius</caption>
301306
<category>Data Point</category>
302-
<description>Radius of each point dot in pixels. Set to zero to disable dots</description>
307+
<description>Radius of each point dot in pixels</description>
303308
</property>
304309
<property key="pointBorderWidth" type="integer" required="true" defaultValue="1">
305310
<caption>Dot stroke width</caption>

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ define([
1515

1616
_processData : function () {
1717
logger.debug(this.id + "._processData");
18+
1819
var sets = [],
1920
points = null,
2021
set = {
@@ -79,7 +80,6 @@ define([
7980
_bezier = 0.4;
8081
}
8182

82-
8383
_set = {
8484
label : (this.scaleShowLabelsBottom === true) ? label : "",
8585
backgroundColor: (this.seriesColorReduceOpacity) ? this._hexToRgb(color, "0.2") : color,
@@ -111,10 +111,8 @@ define([
111111
},
112112

113113
_createChart : function (data) {
114-
115114
logger.debug(this.id + "._createChart");
116115

117-
118116
if (this._chart) {
119117
this._chart.stop();
120118
this._chart.data.datasets = data.datasets;
@@ -123,6 +121,7 @@ define([
123121
this._chart.bindEvents(); // tooltips otherwise won't work
124122
} else {
125123
logger.debug("stacked:" + this.isStacked);
124+
126125
this._chart = new this._chartJS(this._ctx, {
127126
type: "line",
128127
data: data,
@@ -172,15 +171,15 @@ define([
172171
labels : { fontFamily : this._font }
173172
},
174173
elements: {
175-
176174
point: {
177-
radius : this.pointRadius,
178-
borderWidth : this.pointBorderWidth,
175+
radius : this.pointDot ? this.pointRadius : 0,
176+
borderWidth : this.pointDot ? this.pointBorderWidth : 0,
179177
hitRadius : this.pointHitRadius,
180178
hoverRadius : this.pointHoverRadius,
181179
hoverBorderWidth : this.pointHoverBorderWidth
182180
}
183181
},
182+
184183
//Boolean - Whether to show labels on the scale
185184
scaleShowLabels : this.scaleShowLabels,
186185

@@ -231,7 +230,6 @@ define([
231230
}
232231
});
233232

234-
235233
this.connect(window, "resize", lang.hitch(this, function () {
236234
this._resize();
237235
}));

test/widgets/ChartJS.mpk

25 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)