Skip to content

Commit 51abdb1

Browse files
committed
Udated build.
2 parents 0f23d3c + 5d9c215 commit 51abdb1

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,30 @@ var defaultOptions = {
1717

1818
`bower install chartist-plugin-tooltip --save`
1919

20-
```javascript
20+
With descriptive text:
21+
```js
22+
var chart = new Chartist.Line('.ct-chart', {
23+
labels: [1, 2, 3],
24+
series: [
25+
[
26+
{meta: 'description', value: 1 },
27+
{meta: 'description', value: 5},
28+
{meta: 'description', value: 3}
29+
],
30+
[
31+
{meta: 'other description', value: 2},
32+
{meta: 'other description', value: 4},
33+
{meta: 'other description', value: 2}
34+
]
35+
}, {
36+
plugins: [
37+
Chartist.plugins.tooltip()
38+
]
39+
});
40+
```
41+
42+
without:
43+
```js
2144
var chart = new Chartist.Line('.ct-chart', {
2245
labels: [1, 2, 3, 4, 5, 6, 7],
2346
series: [

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.4",
3+
"version": "0.0.5",
44
"main": [
55
"./dist/chartist-plugin-tooltip.min.js"
66
],

dist/chartist-plugin-tooltip.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'use strict';
2424

2525
var defaultOptions = {
26+
currency: null
2627
// showTooltips: true,
2728
// tooltipEvents: ['mousemove', 'touchstart', 'touchmove'],
2829
// labelClass: 'ct-label',
@@ -36,11 +37,11 @@
3637
Chartist.plugins = Chartist.plugins || {};
3738
Chartist.plugins.tooltip = function(options) {
3839

39-
// options = Chartist.extend({}, defaultOptions, options);
40+
options = Chartist.extend({}, defaultOptions, options);
4041

4142
return function tooltip(chart) {
4243
var tooltipSelector = '.ct-point';
43-
if(chart instanceof Chartist.Bar) {
44+
if (chart instanceof Chartist.Bar) {
4445
tooltipSelector = '.ct-bar';
4546
}
4647
var $chart = $(chart.container);
@@ -57,7 +58,11 @@
5758
tooltipText += $point.attr('ct:meta') + '<br>';
5859
}
5960

60-
tooltipText += $point.attr('ct:value')
61+
var value = $point.attr('ct:value');
62+
if (options.currency) {
63+
value = options.currency + value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
64+
}
65+
tooltipText += value;
6166

6267
$toolTip.html(tooltipText).show();
6368
});

dist/chartist-plugin-tooltip.min.js

Lines changed: 2 additions & 2 deletions
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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "chartist-plugin-tooltip",
33
"description": "Point Labels Plugin for Chartist.js",
4-
"version": "0.0.4",
4+
"version": "0.0.5",
55
"author": "Markus Padourek",
66
"homepage": "https://github.com/Globegitter/chartist-plugin-tooltip",
77
"repository": {

0 commit comments

Comments
 (0)