Content-Length: 273310 | pFad | http://github.com/fnando/sparkline/commit/b30e7cc7b0af8c78265f4ede05984bd5a60f726e

63 Fix x coord calculation. · fnando/sparkline@b30e7cc · GitHub
Skip to content

Commit b30e7cc

Browse files
committed
Fix x coord calculation.
1 parent 0800db6 commit b30e7cc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sparkline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function sparkline(svg, entries, options) {
9393
const lastItemIndex = entriesCount - 1;
9494

9595
// Calculate the X coord base step.
96-
const offset = Math.round((width - spotDiameter) / lastItemIndex);
96+
const offset = width / entriesCount;
9797

9898
// Hold all datapoints, which is whatever we got as the entry plus
9999
// x/y coords and the index.
@@ -104,7 +104,7 @@ export function sparkline(svg, entries, options) {
104104
let pathCoords = `M${spotDiameter} ${pathY}`;
105105

106106
values.forEach((value, index) => {
107-
const x = (index === lastItemIndex) ? width : index * offset + spotDiameter;
107+
const x = index * offset + spotDiameter;
108108
const y = getY(max, height, strokeWidth + spotRadius, value);
109109

110110
datapoints.push(Object.assign({}, entries[index], {

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/b30e7cc7b0af8c78265f4ede05984bd5a60f726e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy