mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[chart.js] Updated type of borderWidth in ChartDataSets. (#38176)
This commit is contained in:
parent
84b802ed6d
commit
2c1824785a
@ -1,4 +1,4 @@
|
||||
import { Chart, ChartData, Point, ChartColor } from 'chart.js';
|
||||
import { BorderWidth, Chart, ChartData, Point, ChartColor } from 'chart.js';
|
||||
|
||||
// alternative:
|
||||
// import chartjs = require('chart.js');
|
||||
@ -14,7 +14,7 @@ const chart: Chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
plugins: [plugin, plugin],
|
||||
data: {
|
||||
labels: ['group 1'],
|
||||
labels: ['group 1', 'group 2'],
|
||||
datasets: [
|
||||
{
|
||||
backgroundColor: '#000000',
|
||||
@ -24,6 +24,12 @@ const chart: Chart = new Chart(ctx, {
|
||||
label: 'test',
|
||||
data: [1, null, 3],
|
||||
},
|
||||
{
|
||||
backgroundColor: '#ff0000',
|
||||
borderWidth: { top: 1, right: 1, bottom: 0, left: 1 },
|
||||
label: 'test',
|
||||
data: [1, 3, 5],
|
||||
}
|
||||
],
|
||||
},
|
||||
options: {
|
||||
@ -197,6 +203,12 @@ const chartWithScriptedOptions = new Chart(new CanvasRenderingContext2D(), {
|
||||
return "black";
|
||||
}
|
||||
return value > 3 ? "red" : "green";
|
||||
},
|
||||
borderWidth: ({ dataset, dataIndex }): BorderWidth => {
|
||||
if (dataset === undefined || dataset.data === undefined || dataIndex === undefined) {
|
||||
return 1;
|
||||
}
|
||||
return { top: 1, right: 1, bottom: 0, left: 1 };
|
||||
}
|
||||
}],
|
||||
}
|
||||
|
||||
10
types/chart.js/index.d.ts
vendored
10
types/chart.js/index.d.ts
vendored
@ -138,6 +138,8 @@ declare namespace Chart {
|
||||
|
||||
type BorderAlignment = 'center' | 'inner';
|
||||
|
||||
type BorderWidth = number | { [key in PositionType]?: number };
|
||||
|
||||
interface ChartArea {
|
||||
top: number;
|
||||
right: number;
|
||||
@ -218,9 +220,9 @@ declare namespace Chart {
|
||||
datasets?: ChartDataSets[];
|
||||
}
|
||||
|
||||
interface RadialChartOptions extends ChartOptions {
|
||||
scale?: RadialLinearScale;
|
||||
}
|
||||
interface RadialChartOptions extends ChartOptions {
|
||||
scale?: RadialLinearScale;
|
||||
}
|
||||
|
||||
interface ChartSize {
|
||||
height: number;
|
||||
@ -537,7 +539,7 @@ declare namespace Chart {
|
||||
cubicInterpolationMode?: 'default' | 'monotone';
|
||||
backgroundColor?: ChartColor | ChartColor[] | Scriptable<ChartColor>;
|
||||
borderAlign?: BorderAlignment | BorderAlignment[] | Scriptable<BorderAlignment>;
|
||||
borderWidth?: number | number[] | Scriptable<number>;
|
||||
borderWidth?: BorderWidth | BorderWidth[] | Scriptable<BorderWidth>;
|
||||
borderColor?: ChartColor | ChartColor[] | Scriptable<ChartColor>;
|
||||
borderCapStyle?: 'butt' | 'round' | 'square';
|
||||
borderDash?: number[];
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": false
|
||||
"ban-types": false,
|
||||
"indent": [true, "spaces", 4]
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user