mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #18111 from KentarouTakeda/chart.js
[chart.js]Add properties for some type
This commit is contained in:
@@ -18,11 +18,36 @@ let chart: Chart = new Chart(new CanvasRenderingContext2D(), {
|
||||
]
|
||||
},
|
||||
options: {
|
||||
hover: {
|
||||
intersect: true
|
||||
},
|
||||
tooltips: {
|
||||
filter: data => Number(data.yLabel) > 0,
|
||||
intersect: true,
|
||||
itemSort: (a, b) => Math.random() - 0.5,
|
||||
position: "average",
|
||||
caretPadding: 2,
|
||||
displayColors: true,
|
||||
borderColor: "rgba(0,0,0,0)",
|
||||
borderWidth: 1,
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
ticks: {
|
||||
callback: Math.floor
|
||||
},
|
||||
gridLines: { display: false }
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
chart.update();
|
||||
|
||||
console.log(chart.ctx && chart.ctx.font);
|
||||
console.log(chart.canvas && chart.canvas.tagName);
|
||||
if (chart.chartArea) {
|
||||
console.log(chart.chartArea.top);
|
||||
console.log(chart.chartArea.right);
|
||||
console.log(chart.chartArea.bottom);
|
||||
console.log(chart.chartArea.left);
|
||||
}
|
||||
|
||||
Vendored
+22
-2
@@ -1,7 +1,8 @@
|
||||
// Type definitions for Chart.js 2.4
|
||||
// Type definitions for Chart.js 2.6
|
||||
// Project: https://github.com/nnnick/Chart.js
|
||||
// Definitions by: Alberto Nuti <https://github.com/anuti>
|
||||
// Fabien Lavocat <https://github.com/FabienLavocat>
|
||||
// KentarouTakeda <https://github.com/KentarouTakeda/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -26,6 +27,9 @@ declare class Chart {
|
||||
getElementAtEvent: (e: any) => {};
|
||||
getElementsAtEvent: (e: any) => Array<{}>;
|
||||
getDatasetAtEvent: (e: any) => Array<{}>;
|
||||
ctx: CanvasRenderingContext2D|null;
|
||||
canvas: HTMLCanvasElement|null;
|
||||
chartArea: Chart.ChartArea;
|
||||
static pluginService: PluginServiceStatic;
|
||||
|
||||
static defaults: {
|
||||
@@ -80,6 +84,13 @@ declare namespace Chart {
|
||||
|
||||
type PositionType = 'left' | 'right' | 'top' | 'bottom';
|
||||
|
||||
interface ChartArea {
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
}
|
||||
|
||||
interface ChartLegendItem {
|
||||
text?: string;
|
||||
fillStyle?: string;
|
||||
@@ -191,6 +202,7 @@ declare namespace Chart {
|
||||
enabled?: boolean;
|
||||
custom?(a: any): void;
|
||||
mode?: string;
|
||||
intersect?: boolean;
|
||||
backgroundColor?: ChartColor;
|
||||
titleFontFamily?: string;
|
||||
titleFontSize?: number;
|
||||
@@ -215,11 +227,19 @@ declare namespace Chart {
|
||||
cornerRadius?: number;
|
||||
multiKeyBackground?: string;
|
||||
callbacks?: ChartTooltipCallback;
|
||||
filter?(item: ChartTooltipItem): boolean;
|
||||
itemSort?(itemA: ChartTooltipItem, itemB: ChartTooltipItem): number;
|
||||
position?: "average"|"nearest";
|
||||
caretPadding?: number;
|
||||
displayColors?: boolean;
|
||||
borderColor?: ChartColor;
|
||||
borderWidth?: number;
|
||||
}
|
||||
|
||||
interface ChartHoverOptions {
|
||||
mode?: string;
|
||||
animationDuration?: number;
|
||||
intersect?: boolean;
|
||||
onHover?(active: any): void;
|
||||
}
|
||||
|
||||
@@ -307,7 +327,7 @@ declare namespace Chart {
|
||||
|
||||
interface TickOptions {
|
||||
autoSkip?: boolean;
|
||||
callback?(value: any, index: any, values: any): string;
|
||||
callback?(value: any, index: any, values: any): string|number;
|
||||
display?: boolean;
|
||||
fontColor?: ChartColor;
|
||||
fontFamily?: string;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Reference in New Issue
Block a user