};
}
-export interface Defaults extends CoreChartOptions<ChartType>, ElementChartOptions, PluginChartOptions<ChartType> {
+export interface Defaults extends CoreChartOptions<ChartType>, ElementChartOptions<ChartType>, PluginChartOptions<ChartType> {
scale: ScaleOptionsByType;
scales: {
export type Overrides = {
[key in ChartType]:
CoreChartOptions<key> &
- ElementChartOptions &
+ ElementChartOptions<key> &
PluginChartOptions<key> &
DatasetChartOptions<ChartType> &
ScaleChartOptions<key> &
new (cfg: AnyObject): BarElement;
};
-export interface ElementOptionsByType {
- arc: ArcOptions & ArcHoverOptions;
- bar: BarOptions & BarHoverOptions;
- line: LineOptions & LineHoverOptions;
- point: PointOptions & PointHoverOptions;
-}
-export interface ElementChartOptions {
- elements: Partial<ElementOptionsByType>;
+export interface ElementOptionsByType<TType extends ChartType> {
+ arc: ScriptableAndArrayOptions<ArcOptions & ArcHoverOptions, ScriptableContext<TType>>;
+ bar: ScriptableAndArrayOptions<BarOptions & BarHoverOptions, ScriptableContext<TType>>;
+ line: ScriptableAndArrayOptions<LineOptions & LineHoverOptions, ScriptableContext<TType>>;
+ point: ScriptableAndArrayOptions<PointOptions & PointHoverOptions, ScriptableContext<TType>>;
}
+export type ElementChartOptions<TType extends ChartType = ChartType> = {
+ elements: ElementOptionsByType<TType>
+};
+
export class BasePlatform {
/**
* Called at chart construction time, returns a context2d instance implementing
export type ChartOptions<TType extends ChartType = ChartType> = DeepPartial<
CoreChartOptions<TType> &
- ElementChartOptions &
+ ElementChartOptions<TType> &
PluginChartOptions<TType> &
DatasetChartOptions<TType> &
ScaleChartOptions<TType> &
--- /dev/null
+import { Chart } from '../../index.esm';
+
+const chart = new Chart('id', {
+ type: 'line',
+ data: {
+ labels: [],
+ datasets: []
+ },
+ options: {
+ elements: {
+ line: {
+ borderWidth: () => 2,
+ },
+ point: {
+ pointStyle: (ctx) => 'star',
+ }
+ }
+ }
+});
+
+const chart2 = new Chart('id', {
+ type: 'bar',
+ data: {
+ labels: [],
+ datasets: []
+ },
+ options: {
+ elements: {
+ bar: {
+ borderWidth: (ctx) => 2,
+ }
+ }
+ }
+});
+
+const chart3 = new Chart('id', {
+ type: 'doughnut',
+ data: {
+ labels: [],
+ datasets: []
+ },
+ options: {
+ elements: {
+ arc: {
+ borderWidth: (ctx) => 3,
+ }
+ }
+ }
+});