mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
@types/chart.js: added missing legendCallback to ChartOptions
This commit is contained in:
@@ -5,8 +5,8 @@ import { Chart, ChartData, Point } from "chart.js";
|
||||
// => chartjs.Chart
|
||||
|
||||
const plugin = {
|
||||
afterDraw: (chartInstance: Chart, easing: string, options?: any) => {
|
||||
}
|
||||
afterDraw: (chartInstance: Chart, easing: string, options?: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const chart: Chart = new Chart(new CanvasRenderingContext2D(), {
|
||||
@@ -82,6 +82,18 @@ if (chart.chartArea) {
|
||||
console.log(chart.chartArea.left);
|
||||
}
|
||||
|
||||
// Testing custom legends
|
||||
chart.config.options = {
|
||||
...chart.config.options,
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
legendCallback: () => 'legend replacement'
|
||||
};
|
||||
chart.update();
|
||||
const customLegend = chart.generateLegend();
|
||||
console.log(customLegend === 'legend replacement');
|
||||
|
||||
// Testing radial chart
|
||||
const tickOptions: Chart.LinearTickOptions = {
|
||||
max: 100,
|
||||
@@ -107,14 +119,14 @@ const chartConfig: Chart.ChartConfiguration = {
|
||||
data: {
|
||||
labels: ['#apples', '#pears', '#apricots', '#acorns', '#amigas', "#orics"],
|
||||
datasets: [{
|
||||
label: "test",
|
||||
lineTension: 0.15,
|
||||
data: [1, 1, 2, 3, 5],
|
||||
backgroundColor: '#37738353',
|
||||
borderColor: '#37738353',
|
||||
borderWidth: 3,
|
||||
fill: true
|
||||
}]
|
||||
label: "test",
|
||||
lineTension: 0.15,
|
||||
data: [1, 1, 2, 3, 5],
|
||||
backgroundColor: '#37738353',
|
||||
borderColor: '#37738353',
|
||||
borderWidth: 3,
|
||||
fill: true
|
||||
}]
|
||||
},
|
||||
options: radarChartOptions
|
||||
};
|
||||
|
||||
Vendored
+2
@@ -14,6 +14,7 @@
|
||||
// Francesco Benedetto <https://github.com/frabnt>
|
||||
// Alexandros Dorodoulis <https://github.com/alexdor>
|
||||
// Manuel Heidrich <https://github.com/mahnuh>
|
||||
// Conrad Holtzhausen <https://github.com/Conrad777>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -264,6 +265,7 @@ declare namespace Chart {
|
||||
aspectRatio?: number;
|
||||
maintainAspectRatio?: boolean;
|
||||
events?: string[];
|
||||
legendCallback?(chart: Chart): string;
|
||||
onHover?(this: Chart, event: MouseEvent, activeElements: Array<{}>): any;
|
||||
onClick?(event?: MouseEvent, activeElements?: Array<{}>): any;
|
||||
onResize?(this: Chart, newSize: ChartSize): void;
|
||||
|
||||
Reference in New Issue
Block a user