@stklcode/chartist-plugin-tooltips 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +234 -0
- package/dist/chartist-plugin-tooltip.cjs +2 -0
- package/dist/chartist-plugin-tooltip.cjs.map +1 -0
- package/dist/chartist-plugin-tooltip.css +1 -0
- package/dist/chartist-plugin-tooltip.css.map +1 -0
- package/dist/chartist-plugin-tooltip.d.ts +59 -0
- package/dist/chartist-plugin-tooltip.d.ts.map +1 -0
- package/dist/chartist-plugin-tooltip.js +2 -0
- package/dist/chartist-plugin-tooltip.js.map +1 -0
- package/dist/chartist-plugin-tooltip.umd.js +2 -0
- package/dist/chartist-plugin-tooltip.umd.js.map +1 -0
- package/package.json +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stefan Kalscheuer
|
|
4
|
+
Copyright (c) 2015-2025 Lukas Arnold
|
|
5
|
+
Copyright (c) 2015 Markus Padourek
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Tooltips for Chartist
|
|
2
|
+
[](https://www.npmjs.com/package/@stklcode/chartist-plugin-tooltips)
|
|
3
|
+
|
|
4
|
+
This plugin provides quick and easy tooltips for your [Chartist](https://github.com/chartist-js/chartist#readme) charts.
|
|
5
|
+
It's published on npm as [@stklcode/chartist-plugin-tooltips](https://www.npmjs.com/package/@stklcode/chartist-plugin-tooltips).
|
|
6
|
+
|
|
7
|
+
## Configuration Options
|
|
8
|
+
|
|
9
|
+
The following options can be configured when the plugin is loaded.
|
|
10
|
+
Their default values are as shown.
|
|
11
|
+
|
|
12
|
+
```javascript
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
// Tooltip offset in pixels
|
|
15
|
+
tooltipOffset: { x: 0,y: -20 },
|
|
16
|
+
|
|
17
|
+
// Custom function to generate tooltip HTML ( (meta, value) => html )
|
|
18
|
+
tooltipFnc: undefined,
|
|
19
|
+
|
|
20
|
+
// Custom function to generate tooltip text ( value => text )
|
|
21
|
+
transformTooltipTextFnc: undefined, // Accepts function
|
|
22
|
+
|
|
23
|
+
// Add class(es) to the tooltip wrapper (string or array of strings)
|
|
24
|
+
class: undefined,
|
|
25
|
+
|
|
26
|
+
// If true, the tooltips will not follow mouse movement and be anchored to the target point or bar
|
|
27
|
+
anchorToPoint: false,
|
|
28
|
+
|
|
29
|
+
// Appends tooltips to body instead of chart container,
|
|
30
|
+
appendToBody: true,
|
|
31
|
+
|
|
32
|
+
// Should the meta content be parsed as HTML?
|
|
33
|
+
metaIsHTML: false,
|
|
34
|
+
|
|
35
|
+
// Custom point class to append tooltips to (uses Chartist's default point class if not specified)
|
|
36
|
+
pointClass: undefined
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Sample Usage
|
|
41
|
+
|
|
42
|
+
### 1. Install the plugin
|
|
43
|
+
|
|
44
|
+
`yarn add @stklcode/chartist-plugin-tooltip`
|
|
45
|
+
|
|
46
|
+
### 2. Include JS
|
|
47
|
+
|
|
48
|
+
Include the JavaScript script file of the plugin either using one of two options:
|
|
49
|
+
|
|
50
|
+
1. Include it using a `<script>` tag:
|
|
51
|
+
```html
|
|
52
|
+
<script src="node_modules/chartist/dist/index.umd.js"></script>
|
|
53
|
+
<script src="node_modules/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.umd.js"></script>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
const chart = new Chartist.LineChart('.ct-chart', data, {
|
|
57
|
+
plugins: [
|
|
58
|
+
ChartistPluginTooltip
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. Include it using an import:
|
|
66
|
+
```javascript
|
|
67
|
+
import { LineChart } from 'chartist';
|
|
68
|
+
import ChartistTooltip from 'chartist-plugin-tooltip';
|
|
69
|
+
|
|
70
|
+
const chart = new LineChart('.ct-chart', data, {
|
|
71
|
+
plugins: [
|
|
72
|
+
ChartistPluginTooltip
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. Include CSS
|
|
78
|
+
Include the two CSS files in your project:
|
|
79
|
+
- `node_modules/chartist/dist/index.css`
|
|
80
|
+
- `node_modules/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.css`
|
|
81
|
+
|
|
82
|
+
Either using one of two options:
|
|
83
|
+
1. Include them in the `<head>` of your HTML file
|
|
84
|
+
```html
|
|
85
|
+
<link rel="stylesheet" href="node_modules/chartist/dist/index.css">
|
|
86
|
+
<link rel="stylesheet" href="node_modules/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.css">
|
|
87
|
+
```
|
|
88
|
+
2. Include them as [Webpack](https://webpack.js.org/loaders/style-loader/) CSS imports
|
|
89
|
+
```javascript
|
|
90
|
+
import 'chartist/dist/index.css';
|
|
91
|
+
import 'chartist-plugin-tooltip/dist/chartist-plugin-tooltip.css';
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 4. Configure Labels
|
|
95
|
+
|
|
96
|
+
Without a descriptive text:
|
|
97
|
+
```javascript
|
|
98
|
+
const chart = new Chartist.LineChart('.ct-chart', {
|
|
99
|
+
labels: [1, 2, 3, 4, 5, 6, 7],
|
|
100
|
+
series: [
|
|
101
|
+
[1, 5, 3, 4, 6, 2, 3],
|
|
102
|
+
[2, 4, 2, 5, 4, 3, 6]
|
|
103
|
+
]
|
|
104
|
+
}, {
|
|
105
|
+
plugins: [
|
|
106
|
+
ChartistPluginTooltip
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
With a descriptive text:
|
|
112
|
+
```javascript
|
|
113
|
+
const chart = new Chartist.LineChart('.ct-chart', {
|
|
114
|
+
labels: [1, 2, 3],
|
|
115
|
+
series: [
|
|
116
|
+
[
|
|
117
|
+
{meta: 'description', value: 1},
|
|
118
|
+
{meta: 'description', value: 5},
|
|
119
|
+
{meta: 'description', value: 3}
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
{meta: 'other description', value: 2},
|
|
123
|
+
{meta: 'other description', value: 4},
|
|
124
|
+
{meta: 'other description', value: 2}
|
|
125
|
+
]
|
|
126
|
+
]
|
|
127
|
+
}, {
|
|
128
|
+
plugins: [
|
|
129
|
+
ChartistPluginTooltip
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
With a custom formatted descriptive text:
|
|
135
|
+
```javascript
|
|
136
|
+
var chart = new Chartist.LineChart('.ct-chart', {
|
|
137
|
+
labels: [1, 2, 3],
|
|
138
|
+
series: [
|
|
139
|
+
[
|
|
140
|
+
{meta: 'description', value: 1},
|
|
141
|
+
{meta: 'description', value: 5},
|
|
142
|
+
{meta: 'description', value: 3}
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
{meta: 'other description', value: 2},
|
|
146
|
+
{meta: 'other description', value: 4},
|
|
147
|
+
{meta: 'other description', value: 2}
|
|
148
|
+
]
|
|
149
|
+
]
|
|
150
|
+
}, {
|
|
151
|
+
plugins: [
|
|
152
|
+
[
|
|
153
|
+
ChartistPluginTooltip,
|
|
154
|
+
{
|
|
155
|
+
transformTooltipTextFnc: (value) => `${value} $`,
|
|
156
|
+
class: ['class1', 'class2'],
|
|
157
|
+
appendToBody: true
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
If you change the CSS properties of the tooltip, you shouldn't change the `display` property,
|
|
165
|
+
otherwise the tooltip may be incorrectly positioned.
|
|
166
|
+
|
|
167
|
+
## Custom Point Element
|
|
168
|
+
|
|
169
|
+
This guide is a bit outdated and may not work with new versions of the plugin.
|
|
170
|
+
|
|
171
|
+
In Chartist, you can replace the default point element with a custom element.
|
|
172
|
+
There is a pretty [demo](https://gionkunz.github.io/chartist-js/examples.html#example-line-modify-drawing)
|
|
173
|
+
which uses events to replace the default point graphics.
|
|
174
|
+
If you want the tooltip to work fine with a new element, you need to include two more properties to your custom element:
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
'ct:value': data.value.y,
|
|
178
|
+
'ct:meta': data.meta,
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
And you have to add the following CSS rule to the new element by using the `style` option
|
|
182
|
+
or by adding this rule to your css class:
|
|
183
|
+
|
|
184
|
+
```css
|
|
185
|
+
pointer-events: all !important;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
(If you want to read more about, why you have to add this css rule take a look at [chartist-plugin-tooltip#72](https://github.com/tmmdata/chartist-plugin-tooltip/pull/72))
|
|
189
|
+
|
|
190
|
+
So the final code could look like this. Here is a [live demo](https://jsfiddle.net/9gzqnrd8/9/)
|
|
191
|
+
```javascript
|
|
192
|
+
chart.on('draw', (data) => {
|
|
193
|
+
// If the draw event was triggered from drawing a point on the line chart
|
|
194
|
+
if (data.type === 'point') {
|
|
195
|
+
// We are creating a new path SVG element that draws a triangle around the point coordinates
|
|
196
|
+
|
|
197
|
+
const circle = new Chartist.Svg('circle', {
|
|
198
|
+
cx: [data.x],
|
|
199
|
+
cy: [data.y],
|
|
200
|
+
r: [5],
|
|
201
|
+
'ct:value': data.value.y,
|
|
202
|
+
'ct:meta': data.meta,
|
|
203
|
+
style: 'pointer-events: all !important',
|
|
204
|
+
class: 'my-cool-point',
|
|
205
|
+
}, 'ct-area');
|
|
206
|
+
|
|
207
|
+
// With data.element we get the Chartist SVG wrapper and we can replace the original point drawn by Chartist with our newly created triangle
|
|
208
|
+
data.element.replace(circle);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
plugins: [
|
|
215
|
+
[
|
|
216
|
+
ChartistPluginTooltip,
|
|
217
|
+
{
|
|
218
|
+
appendToBody: true,
|
|
219
|
+
pointClass: 'my-cool-point'
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
]
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Credits
|
|
226
|
+
|
|
227
|
+
This repository is a fork of "chartist-plugin-tooltip-updated" ([lukbukkit/chartist-plugin-tooltip](https://github.com/lukbukkit/chartist-plugin-tooltip))
|
|
228
|
+
which was itself a fork of the original "chartist-plugin-tooltips" ([gionkunz/chartist-plugin-tooltip](https://github.com/gionkunz/chartist-plugin-tooltip)).
|
|
229
|
+
|
|
230
|
+
Many thanks to the authors and all contributors for their great work.
|
|
231
|
+
|
|
232
|
+
Both projects are no longer maintained.
|
|
233
|
+
Please do not expect any major functional updates here either (PRs welcome though), mainly smaller maintenance updates
|
|
234
|
+
to keep things running.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("chartist");function e(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}}),e.default=t,Object.freeze(e)}var o=e(t);module.exports=function(e,n){const s={tooltipOffset:{x:0,y:-20},anchorToPoint:!1,appendToBody:!0,class:void 0,pointClass:"ct-point",tooltipFnc:void 0,transformTooltipTextFnc:void 0,metaIsHTML:!1},i=o.extend({},s,n);let a=i.pointClass||"";e instanceof t.BarChart?a="ct-bar":e instanceof t.PieChart&&(a=e.options.donut?"ct-slice-donut":"ct-slice-pie");const l=e.container;let r,c=!1,p=l.offsetParent;{let t;t=i.appendToBody?document.querySelector(".chartist-tooltip"):l.querySelector(".chartist-tooltip"),t||(t=document.createElement("div"),t.className=i.class?"chartist-tooltip "+i.class:"chartist-tooltip",i.appendToBody?document.body.appendChild(t):l.appendChild(t)),r=t}let f=r.offsetHeight,d=r.offsetWidth;function u(t){f=f||r.offsetHeight,d=d||r.offsetWidth;const e=-d/2+i.tooltipOffset.x,o=-f+i.tooltipOffset.y,n=i.anchorToPoint&&t.target.x2&&t.target.y2;if(i.appendToBody)if(n){const n=l.getBoundingClientRect(),s=t.target.x2.baseVal.value+n.left+window.scrollX,i=t.target.y2.baseVal.value+n.top+window.scrollY;r.style.left=s+e+"px",r.style.top=i+o+"px"}else r.style.left=t.pageX+e+"px",r.style.top=t.pageY+o+"px";else{const s=p.getBoundingClientRect(),i=-s.left-window.scrollX+e,a=-s.top-window.scrollY+o;if(n){const e=l.getBoundingClientRect(),o=t.target.x2.baseVal.value+e.left+window.scrollX,n=t.target.y2.baseVal.value+e.top+window.scrollY;r.style.left=o+i+"px",r.style.top=n+a+"px"}else r.style.left=t.pageX+i+"px",r.style.top=t.pageY+a+"px"}}function g(t){c=!1,t.classList.remove("tooltip-show")}g(r),l.addEventListener("mouseover",n=>{if(!n.target.classList.contains(a))return;const s=n.target;let g="",y="";e instanceof o.BarChart&&(y=s.parentNode.getAttribute("ct:meta")||s.parentNode.getAttribute("ct:series-name")||"");let h=s.getAttribute("ct:meta")||y||"";const m=!!h;let x=s.getAttribute("ct:value")||"";if(i.transformTooltipTextFnc&&"function"==typeof i.transformTooltipTextFnc&&(x=i.transformTooltipTextFnc(x)),i.tooltipFnc&&"function"==typeof i.tooltipFnc)g=i.tooltipFnc(h,x);else{if(i.metaIsHTML){const t=document.createElement("textarea");t.innerHTML=h,h=t.value}if(h='<span class="chartist-tooltip-meta">'+h+"</span>",m)g+=h+"<br>";else if(e instanceof t.PieChart){const t=function(t,e){do{t=t.nextSibling}while(t&&!t.classList.contains(e));return t}(s,"ct-label");t&&(g+=((b=t).innerText||b.textContent)+"<br>")}x&&(x='<span class="chartist-tooltip-value">'+x+"</span>",g+=x)}var b;r&&g&&(r.innerHTML=g,f=r.offsetHeight,d=r.offsetWidth,i.appendToBody||(p=l.offsetParent),"absolute"!==r.style.display&&(r.style.display="absolute"),u(n),function(t){c=!0,t.classList.add("tooltip-show")}(r),f=r.offsetHeight,d=r.offsetWidth)}),l.addEventListener("mouseout",()=>{g(r)}),l.addEventListener("mousemove",t=>{!i.anchorToPoint&&c&&u(t)})};
|
|
2
|
+
//# sourceMappingURL=chartist-plugin-tooltip.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartist-plugin-tooltip.cjs","sources":["../src/src/scripts/chartist-plugin-tooltip.ts"],"sourcesContent":[null],"names":["chart","options","defaultOptions","tooltipOffset","x","y","anchorToPoint","appendToBody","class","undefined","pointClass","tooltipFnc","transformTooltipTextFnc","metaIsHTML","$options","Chartist","extend","tooltipSelector","BarChart","PieChart","donut","chartElem","container","toolTip","toolTipIsShown","tooltipOffsetParent","offsetParent","tt","document","querySelector","createElement","className","body","appendChild","height","offsetHeight","width","offsetWidth","setPosition","event","offsetX","offsetY","anchor","target","x2","y2","box","getBoundingClientRect","left","baseVal","value","window","scrollX","top","scrollY","style","pageX","pageY","offsetBox","allOffsetLeft","allOffsetTop","hide","element","classList","remove","addEventListener","contains","point","tooltipText","seriesName","parentNode","getAttribute","meta","hasMeta","txt","innerHTML","label","nextSibling","next","innerText","textContent","display","add","show"],"mappings":"kUA4Dc,SACZA,EACAC,GAEA,MAAMC,EAAiB,CACrBC,cAAe,CACbC,EAAG,EACHC,GAAG,IAELC,eAAe,EACfC,cAAc,EACdC,WAAOC,EACPC,WAAY,WACZC,gBAAYF,EACZG,6BAAyBH,EACzBI,YAAY,GAGRC,EAAWC,EAASC,OAAO,CAAA,EAAId,EAAgBD,GAGrD,IAAIgB,EAAkBH,EAASJ,YAAc,GACzCV,aAAiBkB,EAAAA,SACnBD,EAAkB,SACTjB,aAAiBmB,EAAAA,WAGxBF,EADGjB,EAAcC,QAAQmB,MACP,iBAEA,gBAItB,MAAMC,EAAarB,EAAcsB,UACjC,IAEIC,EAFAC,GAAiB,EACjBC,EAAsBJ,EAAUK,aAGpC,CACE,IAAIC,EAGFA,EAFEb,EAASP,aAENqB,SAASC,cAAc,qBAGvBR,EAAUQ,cAAc,qBAE1BF,IACHA,EAAKC,SAASE,cAAc,OAC5BH,EAAGI,UAAYjB,EAASN,MACpB,oBAAsBM,EAASN,MAC/B,mBACAM,EAASP,aACXqB,SAASI,KAAKC,YAAYN,GAE1BN,EAAUY,YAAYN,IAG1BJ,EAAUI,CACZ,CAEA,IAAIO,EAASX,EAAQY,aACjBC,EAAQb,EAAQc,YA+FpB,SAASC,EAAYC,GACnBL,EAASA,GAAUX,EAAQY,aAC3BC,EAAQA,GAASb,EAAQc,YACzB,MAAMG,GAAWJ,EAAQ,EAAItB,EAASX,cAAcC,EAC9CqC,GAAWP,EAASpB,EAASX,cAAcE,EAE3CqC,EACJ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AU4C,iBAAiB,WAAY,KACrCJ,EAAKtC,KAGPF,EAAU4C,iBAAiB,YAAc1B,KAClCzB,EAASR,eAAiBkB,GAC7Bc,EAAYC,IAkGlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.chartist-tooltip{position:absolute;display:inline-block;opacity:0;min-width:5em;padding:.5em;background:#f4c63d;color:#453d3f;font-family:Oxygen,Helvetica,Arial,sans-serif;font-weight:700;text-align:center;pointer-events:none;z-index:1;transition:opacity .2s linear}.chartist-tooltip::before{content:"";position:absolute;top:100%;left:50%;width:0;height:0;margin-left:-15px;border:15px solid rgba(0,0,0,0);border-top-color:#f4c63d}.chartist-tooltip.tooltip-show{opacity:1}.ct-area,.ct-line{pointer-events:none}/*# sourceMappingURL=chartist-plugin-tooltip.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../src/styles/chartist-plugin-tooltip.scss"],"names":[],"mappings":"AAGA,kBACE,kBACA,qBACA,UACA,cACA,aACA,WATiB,QAUjB,MAToB,QAUpB,8CACA,gBACA,kBACA,oBACA,UACA,8BAEA,0BACE,WACA,kBACA,SACA,SACA,QACA,SACA,kBACA,gCACA,iBA3Be,QA8BjB,+BACE,UAIJ,kBAEE","file":"chartist-plugin-tooltip.css"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseChart } from 'chartist';
|
|
2
|
+
/**
|
|
3
|
+
* Tooltip plugin options.
|
|
4
|
+
*/
|
|
5
|
+
export interface Options {
|
|
6
|
+
/**
|
|
7
|
+
* Tooltip offset in px.
|
|
8
|
+
* Default: x 0, y -20
|
|
9
|
+
*/
|
|
10
|
+
tooltipOffset: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* If set true, the tooltips will not follow mouse movement and be anchored to the target point or bar.
|
|
16
|
+
*/
|
|
17
|
+
anchorToPoint: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Append tooltip container to body (default: true)
|
|
20
|
+
*/
|
|
21
|
+
appendToBody: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Add custom class(es) to the tooltip.
|
|
24
|
+
* Can be a single class "my-class" or a list ["class-1", "class-2"].
|
|
25
|
+
*/
|
|
26
|
+
class?: string | string[];
|
|
27
|
+
/**
|
|
28
|
+
* Custom point class to append tooltips to.
|
|
29
|
+
* If none is specified, the default class will be used depending on the chart type (e.g. "ct-point" for line charts).
|
|
30
|
+
*/
|
|
31
|
+
pointClass: string;
|
|
32
|
+
/**
|
|
33
|
+
* Custom function to generate tooltip (entire HTML markup).
|
|
34
|
+
*
|
|
35
|
+
* @param meta Point's meta value.
|
|
36
|
+
* @param value Point's value.
|
|
37
|
+
* @returns Tooltip markup.
|
|
38
|
+
*/
|
|
39
|
+
tooltipFnc?: (meta: string, value: string) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Custom function to generate tooltip text (content only).
|
|
42
|
+
*
|
|
43
|
+
* @param value Point's value.
|
|
44
|
+
* @returns Tooltip text.
|
|
45
|
+
*/
|
|
46
|
+
transformTooltipTextFnc?: (value: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Should the meta content be parsed as HTML (true) or plain text (false, default)
|
|
49
|
+
*/
|
|
50
|
+
metaIsHTML: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Chartist.js plugin to display a data label on top of the points in a line chart.
|
|
54
|
+
*
|
|
55
|
+
* @param chart Chart object
|
|
56
|
+
* @param options Plugin options
|
|
57
|
+
*/
|
|
58
|
+
export default function ChartistPluginTooltip<T extends BaseChart<any>>(chart: T, options?: Partial<Options>): void;
|
|
59
|
+
//# sourceMappingURL=chartist-plugin-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartist-plugin-tooltip.d.ts","sourceRoot":"","sources":["../src/scripts/chartist-plugin-tooltip.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,SAAS,EAAY,MAAM,UAAU,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,aAAa,EAAE;QACb,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACrD;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EACpE,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GACzB,IAAI,CAmPN"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as t from"chartist";import{BarChart as e,PieChart as o}from"chartist";function s(s,n){const i={tooltipOffset:{x:0,y:-20},anchorToPoint:!1,appendToBody:!0,class:void 0,pointClass:"ct-point",tooltipFnc:void 0,transformTooltipTextFnc:void 0,metaIsHTML:!1},a=t.extend({},i,n);let l=a.pointClass||"";s instanceof e?l="ct-bar":s instanceof o&&(l=s.options.donut?"ct-slice-donut":"ct-slice-pie");const c=s.container;let r,p=!1,f=c.offsetParent;{let t;t=a.appendToBody?document.querySelector(".chartist-tooltip"):c.querySelector(".chartist-tooltip"),t||(t=document.createElement("div"),t.className=a.class?"chartist-tooltip "+a.class:"chartist-tooltip",a.appendToBody?document.body.appendChild(t):c.appendChild(t)),r=t}let d=r.offsetHeight,u=r.offsetWidth;function g(t){d=d||r.offsetHeight,u=u||r.offsetWidth;const e=-u/2+a.tooltipOffset.x,o=-d+a.tooltipOffset.y,s=a.anchorToPoint&&t.target.x2&&t.target.y2;if(a.appendToBody)if(s){const s=c.getBoundingClientRect(),n=t.target.x2.baseVal.value+s.left+window.scrollX,i=t.target.y2.baseVal.value+s.top+window.scrollY;r.style.left=n+e+"px",r.style.top=i+o+"px"}else r.style.left=t.pageX+e+"px",r.style.top=t.pageY+o+"px";else{const n=f.getBoundingClientRect(),i=-n.left-window.scrollX+e,a=-n.top-window.scrollY+o;if(s){const e=c.getBoundingClientRect(),o=t.target.x2.baseVal.value+e.left+window.scrollX,s=t.target.y2.baseVal.value+e.top+window.scrollY;r.style.left=o+i+"px",r.style.top=s+a+"px"}else r.style.left=t.pageX+i+"px",r.style.top=t.pageY+a+"px"}}function y(t){p=!1,t.classList.remove("tooltip-show")}y(r),c.addEventListener("mouseover",e=>{if(!e.target.classList.contains(l))return;const n=e.target;let i="",y="";s instanceof t.BarChart&&(y=n.parentNode.getAttribute("ct:meta")||n.parentNode.getAttribute("ct:series-name")||"");let m=n.getAttribute("ct:meta")||y||"";const h=!!m;let x=n.getAttribute("ct:value")||"";if(a.transformTooltipTextFnc&&"function"==typeof a.transformTooltipTextFnc&&(x=a.transformTooltipTextFnc(x)),a.tooltipFnc&&"function"==typeof a.tooltipFnc)i=a.tooltipFnc(m,x);else{if(a.metaIsHTML){const t=document.createElement("textarea");t.innerHTML=m,m=t.value}if(m='<span class="chartist-tooltip-meta">'+m+"</span>",h)i+=m+"<br>";else if(s instanceof o){const t=function(t,e){do{t=t.nextSibling}while(t&&!t.classList.contains(e));return t}(n,"ct-label");t&&(i+=((T=t).innerText||T.textContent)+"<br>")}x&&(x='<span class="chartist-tooltip-value">'+x+"</span>",i+=x)}var T;r&&i&&(r.innerHTML=i,d=r.offsetHeight,u=r.offsetWidth,a.appendToBody||(f=c.offsetParent),"absolute"!==r.style.display&&(r.style.display="absolute"),g(e),function(t){p=!0,t.classList.add("tooltip-show")}(r),d=r.offsetHeight,u=r.offsetWidth)}),c.addEventListener("mouseout",()=>{y(r)}),c.addEventListener("mousemove",t=>{!a.anchorToPoint&&p&&g(t)})}export{s as default};
|
|
2
|
+
//# sourceMappingURL=chartist-plugin-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartist-plugin-tooltip.js","sources":["../src/src/scripts/chartist-plugin-tooltip.ts"],"sourcesContent":[null],"names":["ChartistPluginTooltip","chart","options","defaultOptions","tooltipOffset","x","y","anchorToPoint","appendToBody","class","undefined","pointClass","tooltipFnc","transformTooltipTextFnc","metaIsHTML","$options","Chartist","extend","tooltipSelector","BarChart","PieChart","donut","chartElem","container","toolTip","toolTipIsShown","tooltipOffsetParent","offsetParent","tt","document","querySelector","createElement","className","body","appendChild","height","offsetHeight","width","offsetWidth","setPosition","event","offsetX","offsetY","anchor","target","x2","y2","box","getBoundingClientRect","left","baseVal","value","window","scrollX","top","scrollY","style","pageX","pageY","offsetBox","allOffsetLeft","allOffsetTop","hide","element","classList","remove","addEventListener","contains","point","tooltipText","seriesName","parentNode","getAttribute","meta","hasMeta","txt","innerHTML","label","nextSibling","next","innerText","textContent","display","add","show"],"mappings":"6EA4Dc,SAAUA,EACtBC,EACAC,GAEA,MAAMC,EAAiB,CACrBC,cAAe,CACbC,EAAG,EACHC,GAAG,IAELC,eAAe,EACfC,cAAc,EACdC,WAAOC,EACPC,WAAY,WACZC,gBAAYF,EACZG,6BAAyBH,EACzBI,YAAY,GAGRC,EAAWC,EAASC,OAAO,CAAA,EAAId,EAAgBD,GAGrD,IAAIgB,EAAkBH,EAASJ,YAAc,GACzCV,aAAiBkB,EACnBD,EAAkB,SACTjB,aAAiBmB,IAGxBF,EADGjB,EAAcC,QAAQmB,MACP,iBAEA,gBAItB,MAAMC,EAAarB,EAAcsB,UACjC,IAEIC,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AAO+B,CACT,CA/HoBgB,CAAKX,EAAO,YACtBS,IACFR,KAqIMN,EArIcc,GAsIXG,WAAajB,EAAQkB,aAtID,OAEjC,CAEI9B,IACFA,EAAQ,wCAA0CA,EAAQ,UAC1DkB,GAAelB,EAEnB,CA6HF,IAAcY,EA3HRvC,GAAW6C,IACb7C,EAAQoD,UAAYP,EAGpBlC,EAASX,EAAQY,aACjBC,EAAQb,EAAQc,YAEXvB,EAASP,eACZkB,EAAsBJ,EAAUK,cAEJ,aAA1BH,EAAQgC,MAAM0B,UAChB1D,EAAQgC,MAAM0B,QAAU,YAE1B3C,EAAYC,GA2EhB,SAAcuB,GACZtC,GAAiB,EACjBsC,EAAQC,UAAUmB,IAAI,eACxB,CA7EIC,CAAK5D,GAGLW,EAASX,EAAQY,aACjBC,EAAQb,EAAQc,eAIpBhB,EAAU4C,iBAAiB,WAAY,KACrCJ,EAAKtC,KAGPF,EAAU4C,iBAAiB,YAAc1B,KAClCzB,EAASR,eAAiBkB,GAC7Bc,EAAYC,IAkGlB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("chartist")):"function"==typeof define&&define.amd?define(["chartist"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).ChartistPluginTooltip=e(t.Chartist)}(this,function(t){"use strict";function e(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}}),e.default=t,Object.freeze(e)}var o=e(t);return function(e,n){const i={tooltipOffset:{x:0,y:-20},anchorToPoint:!1,appendToBody:!0,class:void 0,pointClass:"ct-point",tooltipFnc:void 0,transformTooltipTextFnc:void 0,metaIsHTML:!1},s=o.extend({},i,n);let a=s.pointClass||"";e instanceof t.BarChart?a="ct-bar":e instanceof t.PieChart&&(a=e.options.donut?"ct-slice-donut":"ct-slice-pie");const l=e.container;let r,c=!1,f=l.offsetParent;{let t;t=s.appendToBody?document.querySelector(".chartist-tooltip"):l.querySelector(".chartist-tooltip"),t||(t=document.createElement("div"),t.className=s.class?"chartist-tooltip "+s.class:"chartist-tooltip",s.appendToBody?document.body.appendChild(t):l.appendChild(t)),r=t}let p=r.offsetHeight,d=r.offsetWidth;function u(t){p=p||r.offsetHeight,d=d||r.offsetWidth;const e=-d/2+s.tooltipOffset.x,o=-p+s.tooltipOffset.y,n=s.anchorToPoint&&t.target.x2&&t.target.y2;if(s.appendToBody)if(n){const n=l.getBoundingClientRect(),i=t.target.x2.baseVal.value+n.left+window.scrollX,s=t.target.y2.baseVal.value+n.top+window.scrollY;r.style.left=i+e+"px",r.style.top=s+o+"px"}else r.style.left=t.pageX+e+"px",r.style.top=t.pageY+o+"px";else{const i=f.getBoundingClientRect(),s=-i.left-window.scrollX+e,a=-i.top-window.scrollY+o;if(n){const e=l.getBoundingClientRect(),o=t.target.x2.baseVal.value+e.left+window.scrollX,n=t.target.y2.baseVal.value+e.top+window.scrollY;r.style.left=o+s+"px",r.style.top=n+a+"px"}else r.style.left=t.pageX+s+"px",r.style.top=t.pageY+a+"px"}}function h(t){c=!1,t.classList.remove("tooltip-show")}h(r),l.addEventListener("mouseover",n=>{if(!n.target.classList.contains(a))return;const i=n.target;let h="",y="";e instanceof o.BarChart&&(y=i.parentNode.getAttribute("ct:meta")||i.parentNode.getAttribute("ct:series-name")||"");let g=i.getAttribute("ct:meta")||y||"";const m=!!g;let b=i.getAttribute("ct:value")||"";if(s.transformTooltipTextFnc&&"function"==typeof s.transformTooltipTextFnc&&(b=s.transformTooltipTextFnc(b)),s.tooltipFnc&&"function"==typeof s.tooltipFnc)h=s.tooltipFnc(g,b);else{if(s.metaIsHTML){const t=document.createElement("textarea");t.innerHTML=g,g=t.value}if(g='<span class="chartist-tooltip-meta">'+g+"</span>",m)h+=g+"<br>";else if(e instanceof t.PieChart){const t=function(t,e){do{t=t.nextSibling}while(t&&!t.classList.contains(e));return t}(i,"ct-label");t&&(h+=((x=t).innerText||x.textContent)+"<br>")}b&&(b='<span class="chartist-tooltip-value">'+b+"</span>",h+=b)}var x;r&&h&&(r.innerHTML=h,p=r.offsetHeight,d=r.offsetWidth,s.appendToBody||(f=l.offsetParent),"absolute"!==r.style.display&&(r.style.display="absolute"),u(n),function(t){c=!0,t.classList.add("tooltip-show")}(r),p=r.offsetHeight,d=r.offsetWidth)}),l.addEventListener("mouseout",()=>{h(r)}),l.addEventListener("mousemove",t=>{!s.anchorToPoint&&c&&u(t)})}});
|
|
2
|
+
//# sourceMappingURL=chartist-plugin-tooltip.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartist-plugin-tooltip.umd.js","sources":["../src/src/scripts/chartist-plugin-tooltip.ts"],"sourcesContent":[null],"names":["chart","options","defaultOptions","tooltipOffset","x","y","anchorToPoint","appendToBody","class","undefined","pointClass","tooltipFnc","transformTooltipTextFnc","metaIsHTML","$options","Chartist","extend","tooltipSelector","BarChart","PieChart","donut","chartElem","container","toolTip","toolTipIsShown","tooltipOffsetParent","offsetParent","tt","document","querySelector","createElement","className","body","appendChild","height","offsetHeight","width","offsetWidth","setPosition","event","offsetX","offsetY","anchor","target","x2","y2","box","getBoundingClientRect","left","baseVal","value","window","scrollX","top","scrollY","style","pageX","pageY","offsetBox","allOffsetLeft","allOffsetTop","hide","element","classList","remove","addEventListener","contains","point","tooltipText","seriesName","parentNode","getAttribute","meta","hasMeta","txt","innerHTML","label","nextSibling","next","innerText","textContent","display","add","show"],"mappings":"mjBA4Dc,SACZA,EACAC,GAEA,MAAMC,EAAiB,CACrBC,cAAe,CACbC,EAAG,EACHC,GAAG,IAELC,eAAe,EACfC,cAAc,EACdC,WAAOC,EACPC,WAAY,WACZC,gBAAYF,EACZG,6BAAyBH,EACzBI,YAAY,GAGRC,EAAWC,EAASC,OAAO,CAAA,EAAId,EAAgBD,GAGrD,IAAIgB,EAAkBH,EAASJ,YAAc,GAC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AAO,YACjB,GAAIxE,aAAiBmB,EAAAA,SAAU,CAGpC,MAAMyD,EA0HZ,SAAcd,EAAsB/B,GAClC,GACE+B,EAAUA,EAAQe,kBACXf,IAAYA,EAAQC,UAAUG,SAASnC,IAChD,OAAO+B,CACT,CA/HoBgB,CAAKX,EAAO,YACtBS,IACFR,KAqIMN,EArIcc,GAsIXG,WAAajB,EAAQkB,aAtID,OAEjC,CAEI9B,IACFA,EAAQ,wCAA0CA,EAAQ,UAC1DkB,GAAelB,EAEnB,CA6HF,IAAcY,EA3HRvC,GAAW6C,IACb7C,EAAQoD,UAAYP,EAGpBlC,EAASX,EAAQY,aACjBC,EAAQb,EAAQc,YAEXvB,EAASP,eACZkB,EAAsBJ,EAAUK,cAEJ,aAA1BH,EAAQgC,MAAM0B,UAChB1D,EAAQgC,MAAM0B,QAAU,YAE1B3C,EAAYC,GA2EhB,SAAcuB,GACZtC,GAAiB,EACjBsC,EAAQC,UAAUmB,IAAI,eACxB,CA7EIC,CAAK5D,GAGLW,EAASX,EAAQY,aACjBC,EAAQb,EAAQc,eAIpBhB,EAAU4C,iBAAiB,WAAY,KACrCJ,EAAKtC,KAGPF,EAAU4C,iBAAiB,YAAc1B,KAClCzB,EAASR,eAAiBkB,GAC7Bc,EAAYC,IAkGlB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stklcode/chartist-plugin-tooltips",
|
|
3
|
+
"description": "ToolTips Plugin for Chartist.js",
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
|
+
"author": "Stefan Kalscheuer & LukBukkit & Markus Padourek",
|
|
6
|
+
"homepage": "https://github.com/stklcode/chartist-plugin-tooltip",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/stklcode/chartist-plugin-tooltip.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/stklcode/chartist-plugin-tooltip/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"chartist",
|
|
16
|
+
"plugin",
|
|
17
|
+
"tooltip"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"package.json",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"main": "./src/scripts/chartist-plugin-tooltip.ts",
|
|
26
|
+
"types": "./dist/chartist-plugin-tooltip.d.ts",
|
|
27
|
+
"style": "./dist/chartist-plugin-tooltip.css",
|
|
28
|
+
"browser": "./dist/chartist-plugin-tooltip.js",
|
|
29
|
+
"unpkg": "./dist/chartist-plugin-tooltip.umd.js",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"main": "./dist/chartist-plugin-tooltip.cjs",
|
|
32
|
+
"module": "./dist/chartist-plugin-tooltip.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"require": "./dist/chartist-plugin-tooltip.cjs",
|
|
36
|
+
"import": "./dist/chartist-plugin-tooltip.js"
|
|
37
|
+
},
|
|
38
|
+
"./dist/*": "./dist/*"
|
|
39
|
+
},
|
|
40
|
+
"directory": "package"
|
|
41
|
+
},
|
|
42
|
+
"licenses": [
|
|
43
|
+
{
|
|
44
|
+
"type": "MIT",
|
|
45
|
+
"url": "https://github.com/stklcode/chartist-plugin-tooltip/blob/main/LICENSE"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"chartist": "^1.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@eslint/js": "^10.0.1",
|
|
53
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
54
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
55
|
+
"copyfiles": "^2.4.1",
|
|
56
|
+
"del": "^8.0.1",
|
|
57
|
+
"del-cli": "^7.0.0",
|
|
58
|
+
"eslint": "^10.1.0",
|
|
59
|
+
"eslint-config-prettier": "^10.1.8",
|
|
60
|
+
"eslint-plugin-jsdoc": "^62.8.0",
|
|
61
|
+
"globals": "^17.4.0",
|
|
62
|
+
"minify": "^15.2.0",
|
|
63
|
+
"prettier": "^3.8.1",
|
|
64
|
+
"rollup": "^4.60.0",
|
|
65
|
+
"sass": "^1.98.0",
|
|
66
|
+
"stylelint": "^17.5.0",
|
|
67
|
+
"stylelint-config-standard-scss": "^17.0.0",
|
|
68
|
+
"stylelint-scss": "^7.0.0",
|
|
69
|
+
"terser": "^5.46.1",
|
|
70
|
+
"tslib": "^2.8.1",
|
|
71
|
+
"typescript": "^5.9.3",
|
|
72
|
+
"typescript-eslint": "^8.57.1"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"clean": "del ./dist ./.tmp",
|
|
76
|
+
"build": "yarn clean && yarn build:styles && yarn build:scripts",
|
|
77
|
+
"build:scripts": "rollup -c",
|
|
78
|
+
"build:styles": "sass --style compressed src/styles:dist",
|
|
79
|
+
"format": "prettier --write 'src/**/*.ts'",
|
|
80
|
+
"lint": "yarn lint:scripts && yarn lint:styles",
|
|
81
|
+
"lint:scripts": "eslint 'src/scripts/**/*.ts'",
|
|
82
|
+
"lint:styles": "stylelint 'src/styles/**/*.scss'"
|
|
83
|
+
},
|
|
84
|
+
"license": "MIT"
|
|
85
|
+
}
|