🤖 Merge PR #44275 @types/chart.js - add number array chart data type by @awilson9

* add number array chart data type

* remove newline

* linting

* syntax error
This commit is contained in:
awilson9 2020-04-28 00:08:00 -07:00 committed by GitHub
parent d562e5ee9f
commit 7d19d6ff87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 1 deletions

View File

@ -458,3 +458,49 @@ const timeLabelsChartData: Chart.ChartData = {
const event = new MouseEvent('click');
chart.getElementsAtEvent(event);
chart.getElementsAtXAxis(event);
// Number array chart data
const chartWithNumberArrayData: Chart = new Chart(ctx, {
type: 'bar',
data: {
datasets: [{
backgroundColor: '#000',
borderColor: '#f00',
data: [
[1, 2],
[3, 4],
[5, 6]
],
type: 'line',
}]
},
options: {
scales: {
displayFormats: {
month: 'MMM YYYY',
},
xAxes: [{
type: 'time',
distribution: 'series',
ticks: {
source: 'data',
autoSkip: true,
sampleSize: 1,
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Closing price ($)'
},
afterBuildTicks: (scale, ticks) => {
return [Math.max(...ticks), 10, Math.min(...ticks)];
}
}]
},
tooltips: {
intersect: false,
mode: 'index',
}
}
});

View File

@ -654,7 +654,7 @@ declare namespace Chart {
borderJoinStyle?: 'bevel' | 'round' | 'miter';
borderSkipped?: PositionType | PositionType[] | Scriptable<PositionType>;
categoryPercentage?: number;
data?: Array<number | null | undefined> | ChartPoint[];
data?: Array<number | null | undefined | number[]> | ChartPoint[];
fill?: boolean | number | string;
hitRadius?: number | number[] | Scriptable<number>;
hoverBackgroundColor?: ChartColor | ChartColor[] | Scriptable<ChartColor>;