Skip to content

Commit

Permalink
Merge pull request #123 from WofWca/per-time-series-interpolation
Browse files Browse the repository at this point in the history
feat: allow setting interpolation per time series
  • Loading branch information
drewnoakes committed Aug 21, 2020
2 parents 62b2062 + 0645ded commit fc5e28e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion builder/index.html
Expand Up @@ -419,7 +419,7 @@
bindColor({target: chart.seriesSet[0].options, name: 'Series fill color', propertyName: 'fillStyle', optional: true, enabled: false, opacity: 0.3});
bindRange({target: chart.seriesSet[0].options, name: 'Series line width', propertyName: 'lineWidth', min: 0.5, max: 5, scale: 10});
bindDropDown({
target: chart.options,
target: chart.seriesSet[0].options,
name: 'Interpolation',
propertyName: 'interpolation',
values: ['bezier', 'linear', 'step']
Expand Down
9 changes: 7 additions & 2 deletions smoothie.d.ts
Expand Up @@ -12,6 +12,11 @@ export interface ITimeSeriesPresentationOptions {
strokeStyle?: string;
fillStyle?: string;
lineWidth?: number;
/**
* Controls how lines are drawn between data points.
* Default value is controlled by <code>SmoothieChart</code>'s <code>interpolation</code> option.
*/
interpolation?: "linear" | "step" | "bezier";
tooltipLabel?: string;
}

Expand Down Expand Up @@ -144,8 +149,8 @@ export interface IChartOptions {
/** Callback function that formats the intermediate y value labels */
yIntermediateFormatter?: (intermediate: number, precision: number) => string;
maxDataSetLength?: number;
/** Controls how lines are drawn between data points. Defaults to "bezier". */
interpolation?: "linear" | "step" | "bezier";
/** Default value for time series presentation options' <code>interpolation</code>. Defaults to "bezier". */
interpolation?: ITimeSeriesPresentationOptions['interpolation'];
/** Optional function to format time stamps for bottom of chart. You may use <code>SmoothieChart.timeFormatter</code>, or your own/ */
timestampFormatter?: (date: Date) => string;
horizontalLines?: IHorizontalLine[];
Expand Down
4 changes: 3 additions & 1 deletion smoothie.js
Expand Up @@ -94,6 +94,7 @@
* Fix bug rendering issue in series fill when using scroll backwards, by @olssonfredrik
* Add title option, by @mesca
* Fix data drop stoppage by rejecting NaNs in append(), by @timdrysdale
* Allow setting interpolation per time series, by @WofWca (#123)
*/

;(function(exports) {
Expand Down Expand Up @@ -465,6 +466,7 @@
* lineWidth: 1,
* strokeStyle: '#ffffff',
* fillStyle: undefined,
* interpolation: undefined;
* tooltipLabel: undefined
* }
* </pre>
Expand Down Expand Up @@ -936,7 +938,7 @@
firstY = y;
context.moveTo(x, y);
} else {
switch (chartOptions.interpolation) {
switch (seriesOptions.interpolation || chartOptions.interpolation) {
case "linear":
case "line": {
context.lineTo(x,y);
Expand Down

0 comments on commit fc5e28e

Please sign in to comment.