Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineDash and 0-width lines #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions smoothie.js
Expand Up @@ -671,13 +671,21 @@
var timeSeries = this.seriesSet[d].timeSeries,
dataSet = timeSeries.data,
seriesOptions = this.seriesSet[d].options;

if (seriesOptions.lineWidth === 0) {
context.restore();
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you continue here, then the call to dropOldData call below is skipped too, and the data will build up indefinitely in the time series object.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch... in fact i've already changed it a bit, as the "lineDash" property doesn't gets saved in the context.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also prohibit using a line width of zero and a fill style in order to have a filled curve with no line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that would be the effect.

Just changed it to the line 783 where it makes more sense (i was setting lineWidth to 0 and stroke was still there). That should solve the problem of having 0 width lines with fillStyles.

}

// Delete old data that's moved off the left of the chart.
timeSeries.dropOldData(oldestValidTime, chartOptions.maxDataSetLength);

// Set style for this dataSet.
context.lineWidth = seriesOptions.lineWidth;
context.strokeStyle = seriesOptions.strokeStyle;
if (typeof(seriesOptions.lineDash) !== "undefined") {
context.setLineDash(seriesOptions.lineDash);
}
// Draw the line...
context.beginPath();
// Retain lastX, lastY for calculating the control points of bezier curves.
Expand Down