Merge branch 'feature/SUPPORT-8717_default_label_color' into test/SUPPORT-8717_default_label_color
This commit is contained in:
commit
66a7880ff8
1 changed files with 15 additions and 11 deletions
|
|
@ -10,7 +10,6 @@ import {Chart} from "chart.js";
|
|||
import {
|
||||
ChartLabelModel
|
||||
} from "../../../../generated/ervu_business_metrics/model/chart/round/label/ChartLabelModel";
|
||||
import {Font} from "../../../../generated/ervu_business_metrics/model/Font";
|
||||
import {ChartLabelFormatter} from "./formatters/ChartLabelFormatter";
|
||||
import {ChartPlugin} from "./ChartPlugin";
|
||||
import {ChartUtils} from "../ChartUtils";
|
||||
|
|
@ -20,16 +19,17 @@ import {ErvuChartV2} from "../ErvuChartV2";
|
|||
export class DoughnutCenterLabelsPlugin extends Behavior implements ChartPlugin {
|
||||
@Visible('false')
|
||||
public id: string = 'doughnut-center-labels';
|
||||
|
||||
public formatters: ChartLabelFormatter[] = [];
|
||||
|
||||
@ColorEditor()
|
||||
public defaultColor: string = 'rgb(0, 0, 0)';
|
||||
@AdvancedProperty()
|
||||
public defaultFont: Font = {
|
||||
family: ChartFontFamily.SANS_SERIF,
|
||||
weight: '500',
|
||||
size: 14
|
||||
}
|
||||
public defaultFontFamily: string = ChartFontFamily.SANS_SERIF;
|
||||
@AdvancedProperty()
|
||||
public formatters: ChartLabelFormatter[] = [];
|
||||
public defaultFontWeight: string = '500';
|
||||
@AdvancedProperty()
|
||||
public defaultFontSize: number = 14;
|
||||
|
||||
beforeDatasetsDraw(chart: Chart, args?: { cancellable: true }, options?: any): void {
|
||||
if (!chart.data || !chart.data.datasets || !(<any>chart.data).centerLabels
|
||||
|
|
@ -111,12 +111,16 @@ export class DoughnutCenterLabelsPlugin extends Behavior implements ChartPlugin
|
|||
label.color = label.color ? label.color : this.defaultColor;
|
||||
|
||||
if (label.font) {
|
||||
label.font.family = label.font.family ? label.font.family : this.defaultFont.family;
|
||||
label.font.weight = label.font.weight ? label.font.weight : this.defaultFont.weight;
|
||||
label.font.size = label.font.size ? label.font.size : this.defaultFont.size;
|
||||
label.font.family = label.font.family ? label.font.family : this.defaultFontFamily;
|
||||
label.font.weight = label.font.weight ? label.font.weight : this.defaultFontWeight;
|
||||
label.font.size = label.font.size ? label.font.size : this.defaultFontSize;
|
||||
}
|
||||
else {
|
||||
label.font = this.defaultFont;
|
||||
label.font = {
|
||||
family: this.defaultFontFamily,
|
||||
weight: this.defaultFontWeight,
|
||||
size: this.defaultFontSize
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue