diff --git a/builder/index.html b/builder/index.html index 26cb02c..6eb48a0 100755 --- a/builder/index.html +++ b/builder/index.html @@ -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'] diff --git a/smoothie.d.ts b/smoothie.d.ts index 2fb52f2..cd452bd 100644 --- a/smoothie.d.ts +++ b/smoothie.d.ts @@ -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 SmoothieChart's interpolation option. + */ + interpolation?: "linear" | "step" | "bezier"; tooltipLabel?: string; } @@ -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' interpolation. Defaults to "bezier". */ + interpolation?: ITimeSeriesPresentationOptions['interpolation']; /** Optional function to format time stamps for bottom of chart. You may use SmoothieChart.timeFormatter, or your own/ */ timestampFormatter?: (date: Date) => string; horizontalLines?: IHorizontalLine[]; diff --git a/smoothie.js b/smoothie.js index 5b16254..5fc3f3c 100644 --- a/smoothie.js +++ b/smoothie.js @@ -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) { @@ -465,6 +466,7 @@ * lineWidth: 1, * strokeStyle: '#ffffff', * fillStyle: undefined, + * interpolation: undefined; * tooltipLabel: undefined * } * @@ -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);