Content-Length: 390922 | pFad | http://github.com/fnando/sparkline/commit/9af1e74e36f5c84f03745a662fccf1dede6f573b

24 Add class name to both line and fill area. · fnando/sparkline@9af1e74 · GitHub
Skip to content

Commit 9af1e74

Browse files
committed
Add class name to both line and fill area.
1 parent 0c0d7e1 commit 9af1e74

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ You can change the colors by either setting the attributes directly to the SVG e
7070
.sparkline--cursor {
7171
stroke: orange;
7272
}
73+
74+
/* style fill area and line colors using specific class name */
75+
.sparkline--fill {
76+
fill: rgba(255, 0, 0, .3);
77+
}
78+
79+
.sparkline--line {
80+
stroke: red;
81+
}
7382
```
7483

7584
## Examples
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
exports['renders svg with array of numbers and default options 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M4 26 L 4 26 L 27 7.67 L 50 18.67 L 73 11.33 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path d=\"M4 26 L 4 26 L 27 7.67 L 50 18.67 L 73 11.33 L 96 4\" fill=\"none\"></path></svg>"
1+
exports['renders svg with array of numbers and default options 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M4 26 L 4 26 L 27 7.67 L 50 18.67 L 73 11.33 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M4 26 L 4 26 L 27 7.67 L 50 18.67 L 73 11.33 L 96 4\" fill=\"none\"></path></svg>"
22

33
exports['renders svg for empty values array 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"></svg>"
44

55
exports['renders svg for 1-item array 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"></svg>"
66

7-
exports['renders interactive svg 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M4 26 L 4 26 L 50 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path d=\"M4 26 L 4 26 L 50 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"-1000\" x2=\"-1000\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"-1000\" cy=\"-1000\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
7+
exports['renders interactive svg 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M4 26 L 4 26 L 50 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M4 26 L 4 26 L 50 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"-1000\" x2=\"-1000\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"-1000\" cy=\"-1000\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
88

9-
exports['renders svg with custom cursor 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M4 15 L 4 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path d=\"M4 15 L 4 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"4\" x2=\"4\" y1=\"0\" y2=\"30\" stroke-width=\"3\"></line><circle class=\"sparkline--spot\" cx=\"4\" cy=\"15\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
9+
exports['renders svg with custom cursor 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M4 15 L 4 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M4 15 L 4 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"4\" x2=\"4\" y1=\"0\" y2=\"30\" stroke-width=\"3\"></line><circle class=\"sparkline--spot\" cx=\"4\" cy=\"15\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
1010

11-
exports['renders svg with custom spot 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M6 15 L 6 15 L 94 5 V 30 L 6 30 Z\" stroke=\"none\"></path><path d=\"M6 15 L 6 15 L 94 5\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"6\" x2=\"6\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"6\" cy=\"15\" r=\"3\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
11+
exports['renders svg with custom spot 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M6 15 L 6 15 L 94 5 V 30 L 6 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M6 15 L 6 15 L 94 5\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"6\" x2=\"6\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"6\" cy=\"15\" r=\"3\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
1212

13-
exports['updates interactive svg when mouse moves 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M4 26 L 4 26 L 50 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path d=\"M4 26 L 4 26 L 50 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"96\" x2=\"96\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"96\" cy=\"4\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
13+
exports['updates interactive svg when mouse moves 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M4 26 L 4 26 L 50 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M4 26 L 4 26 L 50 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"96\" x2=\"96\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"96\" cy=\"4\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
1414

15-
exports['renders interactive svg based on the nearest edge 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M4 15 L 4 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path d=\"M4 15 L 4 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"4\" x2=\"4\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"4\" cy=\"15\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
15+
exports['renders interactive svg based on the nearest edge 1'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M4 15 L 4 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M4 15 L 4 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"4\" x2=\"4\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"4\" cy=\"15\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
1616

17-
exports['renders interactive svg based on the nearest edge 2'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path d=\"M4 15 L 4 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path d=\"M4 15 L 4 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"96\" x2=\"96\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"96\" cy=\"4\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
17+
exports['renders interactive svg based on the nearest edge 2'] = "<svg width=\"100\" height=\"30\" stroke-width=\"2\"><path class=\"sparkline--fill\" d=\"M4 15 L 4 15 L 96 4 V 30 L 4 30 Z\" stroke=\"none\"></path><path class=\"sparkline--line\" d=\"M4 15 L 4 15 L 96 4\" fill=\"none\"></path><line class=\"sparkline--cursor\" x1=\"96\" x2=\"96\" y1=\"0\" y2=\"30\" stroke-width=\"2\"></line><circle class=\"sparkline--spot\" cx=\"96\" cy=\"4\" r=\"2\"></circle><rect width=\"100\" height=\"30\" style=\"fill: transparent; stroke: transparent\" class=\"sparkline--interaction-layer\"></rect></svg>"
1818

src/sparkline.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ export function sparkline(svg, entries, options) {
114114
});
115115

116116
const path = buildElement("path", {
117+
class: "sparkline--line",
117118
d: pathCoords,
118119
fill: "none"
119120
});
120121

121122
let fillCoords = `${pathCoords} V ${fullHeight} L ${spotDiameter} ${fullHeight} Z`;
122123

123124
const fill = buildElement("path", {
125+
class: "sparkline--fill",
124126
d: fillCoords,
125127
stroke: "none"
126128
});

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/fnando/sparkline/commit/9af1e74e36f5c84f03745a662fccf1dede6f573b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy