Merge pull request #19525 from mernen/update-chartjs

chart.js: add missing features and improve types
This commit is contained in:
Nathan Shively-Sanders
2017-09-05 15:36:21 -07:00
committed by GitHub

View File

@@ -4,15 +4,14 @@
// Fabien Lavocat <https://github.com/FabienLavocat>
// KentarouTakeda <https://github.com/KentarouTakeda>
// Larry Bahr <https://github.com/larrybahr>
// Daniel Luz <https://github.com/mernen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
declare class Chart {
static readonly Chart: typeof Chart;
constructor(
context: string | JQuery | CanvasRenderingContext2D | HTMLCanvasElement | string[] | CanvasRenderingContext2D[] | HTMLCanvasElement[],
context: string | CanvasRenderingContext2D | HTMLCanvasElement | ArrayLike<CanvasRenderingContext2D | HTMLCanvasElement>,
options: Chart.ChartConfiguration
);
config: Chart.ChartConfiguration;
@@ -83,6 +82,8 @@ declare namespace Chart {
type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear';
type PointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle';
type PositionType = 'left' | 'right' | 'top' | 'bottom';
interface ChartArea {
@@ -175,7 +176,7 @@ declare namespace Chart {
interface ChartTitleOptions {
display?: boolean;
position?: string;
position?: PositionType;
fullWdith?: boolean;
fontSize?: number;
fontFamily?: string;
@@ -187,10 +188,12 @@ declare namespace Chart {
interface ChartLegendOptions {
display?: boolean;
position?: string;
position?: PositionType;
fullWidth?: boolean;
onClick?(event: any, legendItem: any): void;
onClick?(event: MouseEvent, legendItem: ChartLegendItem): void;
onHover?(event: MouseEvent, legendItem: ChartLegendItem): void;
labels?: ChartLegendLabelOptions;
reverse?: boolean;
}
interface ChartLegendLabelOptions {
@@ -293,7 +296,7 @@ declare namespace Chart {
interface ChartPointOptions {
radius?: number;
pointStyle?: string;
pointStyle?: PointStyle;
backgroundColor?: ChartColor;
borderWidth?: number;
borderColor?: ChartColor;
@@ -332,6 +335,7 @@ declare namespace Chart {
interface TickOptions {
autoSkip?: boolean;
autoSkipPadding?: boolean;
callback?(value: any, index: any, values: any): string|number;
display?: boolean;
fontColor?: ChartColor;
@@ -386,7 +390,7 @@ declare namespace Chart {
type ChartColor = string | CanvasGradient | CanvasPattern | string[];
interface ChartDataSets {
cubicInterpolationMode?: string;
cubicInterpolationMode?: 'default' | 'monotone';
backgroundColor?: ChartColor | ChartColor[];
borderWidth?: number;
borderColor?: ChartColor;
@@ -394,10 +398,15 @@ declare namespace Chart {
borderDash?: number[];
borderDashOffset?: number;
borderJoinStyle?: string;
borderSkipped?: PositionType;
data?: number[] | ChartPoint[];
fill?: boolean;
fill?: boolean | number | string;
hoverBackgroundColor?: string | string[];
hoverBorderColor?: string | string[];
hoverBorderWidth?: number | number[];
label?: string;
lineTension?: number;
steppedLine?: 'before' | 'after' | boolean;
pointBorderColor?: ChartColor | ChartColor[];
pointBackgroundColor?: ChartColor | ChartColor[];
pointBorderWidth?: number | number[];
@@ -407,14 +416,15 @@ declare namespace Chart {
pointHoverBackgroundColor?: ChartColor | ChartColor[];
pointHoverBorderColor?: ChartColor | ChartColor[];
pointHoverBorderWidth?: number | number[];
pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[];
pointStyle?: PointStyle | HTMLImageElement | Array<PointStyle | HTMLImageElement>;
xAxisID?: string;
yAxisID?: string;
type?: string;
hidden?: boolean;
hideInLegendAndTooltip?: boolean;
showLine?: boolean;
stack?: string;
spanGaps?: string;
spanGaps?: boolean;
}
interface ChartScales {