Skip to content

Commit 28bf73a

Browse files
committed
Only show meta in tooltip if it exists.
1 parent 3ebeab4 commit 28bf73a

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chartist-plugin-tooltip",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"main": [
55
"./dist/chartist-plugin-tooltip.min.js"
66
],

dist/chartist-plugin-tooltip.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@
5050
.hide();
5151

5252
$chart.on('mouseenter', tooltipSelector, function() {
53-
var $point = Ember.$(this),
54-
value = $point.attr('ct:value'),
55-
seriesName = $point.attr('ct:meta');
56-
$toolTip.html(seriesName + '<br>' + value).show();
53+
var $point = Ember.$(this);
54+
var tooltipText = '';
55+
56+
if ($point.attr('ct:meta')) {
57+
tooltipText += $point.attr('ct:meta') + '<br>';
58+
}
59+
60+
tooltipText += $point.attr('ct:value')
61+
62+
$toolTip.html(tooltipText).show();
5763
});
5864

5965
$chart.on('mouseleave', tooltipSelector, function() {

dist/chartist-plugin-tooltip.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/chartist-plugin-tooltip.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/scripts/chartist-plugin-tooltip.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@
3434
.hide();
3535

3636
$chart.on('mouseenter', tooltipSelector, function() {
37-
var $point = Ember.$(this),
38-
value = $point.attr('ct:value'),
39-
seriesName = $point.attr('ct:meta');
40-
$toolTip.html(seriesName + '<br>' + value).show();
37+
var $point = Ember.$(this);
38+
var tooltipText = '';
39+
40+
if ($point.attr('ct:meta')) {
41+
tooltipText += $point.attr('ct:meta') + '<br>';
42+
}
43+
44+
tooltipText += $point.attr('ct:value')
45+
46+
$toolTip.html(tooltipText).show();
4147
});
4248

4349
$chart.on('mouseleave', tooltipSelector, function() {

0 commit comments

Comments
 (0)