mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Extending definition of scales (#39318)
Allowing ChartScales, LinearScale, LogarithmicScale and TimeScale as value for scales property of ChartOptions.
This commit is contained in:
committed by
Wesley Wigham
parent
a151389bac
commit
ff522b12c1
@@ -1,4 +1,4 @@
|
||||
import { BorderWidth, Chart, ChartData, Point, ChartColor } from 'chart.js';
|
||||
import { BorderWidth, Chart, Point, ChartColor } from 'chart.js';
|
||||
|
||||
// alternative:
|
||||
// import chartjs = require('chart.js');
|
||||
@@ -241,3 +241,41 @@ const chartWithScriptedOptions = new Chart(new CanvasRenderingContext2D(), {
|
||||
}],
|
||||
}
|
||||
});
|
||||
|
||||
// linear scale
|
||||
const linearScaleChart: Chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
datasets: [{
|
||||
backgroundColor: '#000',
|
||||
borderColor: '#f00',
|
||||
data: [],
|
||||
type: 'line',
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
displayFormats: {
|
||||
month: 'MMM YYYY',
|
||||
},
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
distribution: 'series',
|
||||
ticks: {
|
||||
source: 'data',
|
||||
autoSkip: true
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Closing price ($)'
|
||||
}
|
||||
}]
|
||||
},
|
||||
tooltips: {
|
||||
intersect: false,
|
||||
mode: 'index',
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -249,7 +249,7 @@ declare namespace Chart {
|
||||
elements?: ChartElementsOptions;
|
||||
layout?: ChartLayoutOptions;
|
||||
scale?: RadialLinearScale;
|
||||
scales?: ChartScales;
|
||||
scales?: ChartScales | LinearScale | LogarithmicScale | TimeScale;
|
||||
showLines?: boolean;
|
||||
spanGaps?: boolean;
|
||||
cutoutPercentage?: number;
|
||||
|
||||
Reference in New Issue
Block a user