Skip to content

Commit

Permalink
Update line dash type, calculation, docs (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert authored Nov 28, 2024
1 parent 1fd433e commit 48298e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion smoothie.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export interface ITimeSeriesOptions {
export interface ITimeSeriesPresentationOptions {
strokeStyle?: string;
/**
* As per https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
* Only supported for charts using fixed axes and linear interpolation.
*/
lineDash?: [number, number];
lineDash?: number[];
fillStyle?: string;
lineWidth?: number;
/**
Expand Down
2 changes: 1 addition & 1 deletion smoothie.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
this.lineDashOffset = Number((removedLineLength + this.lineDashOffset).toFixed(2));

// Reset lineDashOffset to zero where possible.
const totalDashLength = lineDash[0] + lineDash[1];
const totalDashLength = lineDash.reduce((acc, curr) => acc + curr, 0);
if (this.lineDashOffset % totalDashLength === 0) {
this.lineDashOffset = 0;
}
Expand Down

0 comments on commit 48298e7

Please sign in to comment.