diff --git a/README.md b/README.md index e0454a6b9..cfe55b42c 100755 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ List of Definitions * [simple-cw-node](https://github.com/astronaughts/simple-cw-node) (by [vvakame](https://github.com/vvakame)) * [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u)) * [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin)) +* [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley)) * [socket.io](http://socket.io) (by [William Orr](https://github.com/worr)) * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) diff --git a/smoothie/smoothie-tests.ts b/smoothie/smoothie-tests.ts new file mode 100644 index 000000000..8fb75de8d --- /dev/null +++ b/smoothie/smoothie-tests.ts @@ -0,0 +1,32 @@ +/// + +// Smoothie supports browserify +import Smoothie = require('smoothie'); + +var canvas: HTMLCanvasElement = document.createElement('canvas'); + +document.body.appendChild(canvas); + +var series: Smoothie.TimeSeries = new Smoothie.TimeSeries(), + chart: Smoothie.SmoothieChart = new Smoothie.SmoothieChart({ + grid : { + strokeStyle : '#404040' + }, + maxValue : 1, + minValue : 0 +}); + +chart.addTimeSeries(series, { + strokeStyle : '#FFFFFF', + fillStyle : 'rgba(64, 64, 64, 0.25)', + lineWidth : 2 +}); + +var DELAY: number = 500; + +chart.streamTo(canvas, DELAY); +chart.addTimeSeries(series); + +setInterval(() => + series.append(Date.now(), Math.random()), + DELAY); diff --git a/smoothie/smoothie.d.ts b/smoothie/smoothie.d.ts new file mode 100644 index 000000000..d5ba175e9 --- /dev/null +++ b/smoothie/smoothie.d.ts @@ -0,0 +1,66 @@ +// Type definitions for smoothie +// Project: https://github.com/joewalnes/smoothie +// Definitions by: Mike H. Hawley +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "smoothie" { + export class TimeSeries { + constructor(options?: { + resetBoundsInterval?: number; + resetBounds?: boolean + }); + + public resetBounds(): void; + + public append(timestamp: number, value: number, sumRepeatedTimeStampValues?: boolean): void; + + public dropOldData(oldestValidTime: number, maxDataSetLength: number): void; + } + + export class SmoothieChart { + constructor(options?: { + millisPerPixel?: number; + maxValueScale?: number; + interpolation?: string; + scaleSmoothing?: number; + maxDataSetLength?: number; + + grid?: { + fillStyle?: string; + strokeStyle?: string; + lineWidth?: number; + sharpLines?: boolean; + millisPerLine?: number; + verticalSections?: number; + borderVisible?: boolean + }; + + labels?: { + fillStyle?: string; + disabled?: boolean; + fontSize?: number; + fontFamily?: string; + precision?: number + }; + + horizontalLines?: number[] + }); + + public addTimeSeries(timeSeries: TimeSeries, options?: { + lineWidth?: number; + strokeStyle?: string + }): void; + + public removeTimeSeries(timeSeries: TimeSeries): void; + + public streamTo(canvas: HTMLCanvasElement, delayMillis: number): void; + + public start(): void; + public stop(): void; + + public updateValueRange(): void; + public render(canvas?: HTMLCanvasElement, time?: number): void; + } +}