From b779873b3f98b30e42d68d837a6533f4c4a7a882 Mon Sep 17 00:00:00 2001 From: Matt Gibbs Date: Tue, 12 Jan 2016 16:24:28 -0500 Subject: [PATCH] Expanding Chartist Type Definitions --- chartist/chartist-tests.ts | 19 +++++++++++++++++++ chartist/chartist.d.ts | 26 ++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/chartist/chartist-tests.ts b/chartist/chartist-tests.ts index 0a5072c6a..6d44922ac 100644 --- a/chartist/chartist-tests.ts +++ b/chartist/chartist-tests.ts @@ -168,3 +168,22 @@ new Chartist.Bar('.ct-chart', { seriesBarDistance: 15 }] ]); + +new Chartist.Pie('.ct-chart', { + series: [{ + value: 20, + name: 'Series 1', + className: 'my-custom-class-one', + meta: 'Meta One' + }, { + value: 10, + name: 'Series 2', + className: 'my-custom-class-two', + meta: 'Meta Two' + }, { + value: 70, + name: 'Series 3', + className: 'my-custom-class-three', + meta: 'Meta Three' + }] +}); \ No newline at end of file diff --git a/chartist/chartist.d.ts b/chartist/chartist.d.ts index 9381aaff0..4c0e787b8 100644 --- a/chartist/chartist.d.ts +++ b/chartist/chartist.d.ts @@ -18,9 +18,25 @@ declare module Chartist { 1: T; } + // data formats are not well documented on all the ways they can be passed to the constructors + // this definition gives some intellisense, but does not protect the user from misuse + // TODO: come in and tidy this up and make it fit better + interface IChartistData { + labels?: Array; + series: Array | Array | Array>; + } + + interface IChartistSeriesData { + name: string; + value?: number; + data?: Array; + className?: string; + meta?: string; // I assume this could probably be a number as well? + } + interface IChartistBase { container: any; - data: Object; + data: IChartistData; defaultOptions: T; options: T; responsiveOptions: Array>; @@ -55,15 +71,15 @@ declare module Chartist { } interface IChartistPieChart extends IChartistBase { - new (target: any, data: Object, options?: IPieChartOptions, responsiveOptions?: Array>): IChartistPieChart; + new (target: any, data: IChartistData, options?: IPieChartOptions, responsiveOptions?: Array>): IChartistPieChart; } interface IChartistLineChart extends IChartistBase { - new (target: any, data: Object, options?: ILineChartOptions, responsiveOptions?: Array>): IChartistLineChart; + new (target: any, data: IChartistData, options?: ILineChartOptions, responsiveOptions?: Array>): IChartistLineChart; } interface IChartistBarChart extends IChartistBase { - new (target: any, data: Object, options?: IBarChartOptions, responsiveOptions?: Array>): IChartistBarChart; + new (target: any, data: IChartistData, options?: IBarChartOptions, responsiveOptions?: Array>): IChartistBarChart; } interface IChartOptions { @@ -163,6 +179,7 @@ declare module Chartist { height?: number | string; high?: number; low?: number; + ticks?: Array; onlyInteger?: boolean; chartPadding?: IChartPadding; seriesBarDistance?: number; @@ -217,6 +234,7 @@ declare module Chartist { lineSmooth?: boolean; low?: number; high?: number; + ticks?: Array; chartPadding?: IChartPadding; fullWidth?: boolean; reverseData?: boolean;