Merge branch 'feature/SUPPORT-8717_default_label_color' into test/SUPPORT-8717_default_label_color
This commit is contained in:
commit
f8052d675a
2 changed files with 31 additions and 27 deletions
|
|
@ -11,10 +11,10 @@ import ru.cg.webbpm.modules.standard_annotations.editor.ColorEditor;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractRoundLabelConfiguration implements RoundLabelConfiguration {
|
public abstract class AbstractRoundLabelConfiguration implements RoundLabelConfiguration {
|
||||||
|
|
||||||
public Font font = Font.of("sans-serif", "500", 14);
|
public Font font;
|
||||||
|
|
||||||
@ColorEditor
|
@ColorEditor
|
||||||
public String color = "#FFFFFF";
|
public String color;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChartLabelModel getLabelModel(LoadOptions loadOptions) {
|
public ChartLabelModel getLabelModel(LoadOptions loadOptions) {
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,39 @@
|
||||||
import {ChartPlugin} from "./ChartPlugin";
|
import {
|
||||||
|
AdvancedProperty,
|
||||||
|
AnalyticalScope,
|
||||||
|
Behavior,
|
||||||
|
ChartFontFamily,
|
||||||
|
ColorEditor,
|
||||||
|
Visible
|
||||||
|
} from "@webbpm/base-package";
|
||||||
import {Chart} from "chart.js";
|
import {Chart} from "chart.js";
|
||||||
import {
|
import {
|
||||||
ChartLabelModel
|
ChartLabelModel
|
||||||
} from "../../../../generated/ervu_business_metrics/model/chart/round/label/ChartLabelModel";
|
} from "../../../../generated/ervu_business_metrics/model/chart/round/label/ChartLabelModel";
|
||||||
import {ChartUtils} from "../ChartUtils";
|
import {Font} from "../../../../generated/ervu_business_metrics/model/Font";
|
||||||
import {AnalyticalScope, Behavior, ChartFontFamily, Visible} from "@webbpm/base-package";
|
|
||||||
import {ErvuChartV2} from "../ErvuChartV2";
|
|
||||||
import {ChartLabelFormatter} from "./formatters/ChartLabelFormatter";
|
import {ChartLabelFormatter} from "./formatters/ChartLabelFormatter";
|
||||||
|
import {ChartPlugin} from "./ChartPlugin";
|
||||||
|
import {ChartUtils} from "../ChartUtils";
|
||||||
|
import {ErvuChartV2} from "../ErvuChartV2";
|
||||||
|
|
||||||
@AnalyticalScope(ErvuChartV2)
|
@AnalyticalScope(ErvuChartV2)
|
||||||
export class DoughnutCenterLabelsPlugin extends Behavior implements ChartPlugin {
|
export class DoughnutCenterLabelsPlugin extends Behavior implements ChartPlugin {
|
||||||
public static readonly ID = 'doughnut-center-labels';
|
|
||||||
private static readonly DEFAULTS = {
|
|
||||||
color: 'rgb(255, 255, 255)',
|
|
||||||
font: {
|
|
||||||
family: ChartFontFamily.SANS_SERIF,
|
|
||||||
weight: '500',
|
|
||||||
size: 14
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Visible('false')
|
@Visible('false')
|
||||||
public id: string = DoughnutCenterLabelsPlugin.ID;
|
public id: string = 'doughnut-center-labels';
|
||||||
|
@ColorEditor()
|
||||||
|
public defaultColor: string = 'rgb(0, 0, 0)';
|
||||||
|
@AdvancedProperty()
|
||||||
|
public defaultFont: Font = {
|
||||||
|
family: ChartFontFamily.SANS_SERIF,
|
||||||
|
weight: '500',
|
||||||
|
size: 14
|
||||||
|
}
|
||||||
|
@AdvancedProperty()
|
||||||
public formatters: ChartLabelFormatter[] = [];
|
public formatters: ChartLabelFormatter[] = [];
|
||||||
|
|
||||||
beforeDatasetsDraw(chart: Chart, args?: { cancellable: true }, options?: any): void {
|
beforeDatasetsDraw(chart: Chart, args?: { cancellable: true }, options?: any): void {
|
||||||
if (!chart.data || !chart.data.datasets || !(<any>chart.data).centerLabels || ChartUtils.isEmpty(chart)) {
|
if (!chart.data || !chart.data.datasets || !(<any>chart.data).centerLabels
|
||||||
|
|| ChartUtils.isEmpty(chart)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,18 +108,15 @@ export class DoughnutCenterLabelsPlugin extends Behavior implements ChartPlugin
|
||||||
formatter.format(label, labels, index);
|
formatter.format(label, labels, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
label.color = label.color ? label.color : DoughnutCenterLabelsPlugin.DEFAULTS.color;
|
label.color = label.color ? label.color : this.defaultColor;
|
||||||
|
|
||||||
if (label.font) {
|
if (label.font) {
|
||||||
label.font.family =
|
label.font.family = label.font.family ? label.font.family : this.defaultFont.family;
|
||||||
label.font.family ? label.font.family : DoughnutCenterLabelsPlugin.DEFAULTS.font.family;
|
label.font.weight = label.font.weight ? label.font.weight : this.defaultFont.weight;
|
||||||
label.font.weight =
|
label.font.size = label.font.size ? label.font.size : this.defaultFont.size;
|
||||||
label.font.weight ? label.font.weight : DoughnutCenterLabelsPlugin.DEFAULTS.font.weight;
|
|
||||||
label.font.size =
|
|
||||||
label.font.size ? label.font.size : DoughnutCenterLabelsPlugin.DEFAULTS.font.size;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
label.font = DoughnutCenterLabelsPlugin.DEFAULTS.font
|
label.font = this.defaultFont;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue