Merge branch 'test/SUPPORT-8732' into ervu/tmp_makets

* test/SUPPORT-8732:
  SUPPORT-8732: test for 2 feature: border radius and shadow bars
  SUPPORT-8732: adding shadow bar setting
  SUPPORT-8732: define border radius feature
This commit is contained in:
Фоат Саляхов 2024-12-13 15:09:57 +03:00
commit 933012b72f
5 changed files with 139 additions and 5 deletions

View file

@ -19,8 +19,8 @@ import {
} from "@webbpm/base-package";
import {ChartLegendSettings} from "./model/ChartLegendSettings";
import {ChartBarSettings} from "./model/ChartBarSettings";
import {DatasetsCommon} from "./model/DatasetsCommon";
import {ChartPlugin} from "./plugin/ChartPlugin";
import {DoughnutCenterLabelsPlugin} from "./plugin/DoughnutCenterLabelsPlugin";
import {ChartUtils} from "./ChartUtils";
@Component({
@ -45,6 +45,7 @@ export class ErvuChartV2 extends Control implements Filterable {
public scales: ChartScaleSettings[];
public bars: ChartBarSettings;
public datasetsCommon: DatasetsCommon;
@NotNull()
public loadOnStart: boolean = true;
@ -277,7 +278,58 @@ export class ErvuChartV2 extends Control implements Filterable {
if (this.bars) {
chartOptions.scales = chartOptions.scales ? chartOptions.scales : {};
chartOptions.scales.x = this.bars.x;
chartOptions.scales.y = this.bars.y
chartOptions.scales.y = this.bars.y;
// shadow bar treatment must be before border radius treatment
if (this.bars.shadowBar && chartConfig.data.datasets &&
chartConfig.data.datasets.length > 0) {
const shadowBarStack: string = this.bars.shadowBar;
let datasets = chartConfig.data.datasets;
const shadowBarIndex = datasets.findIndex(element => element.stack === shadowBarStack);
if (shadowBarIndex > -1) {
const shadowBar = datasets[shadowBarIndex];
const stacks: string[] = [];
datasets.forEach((element, index) => {
let stack: string = element.stack;
if (stack) {
if (stack !== shadowBarStack && stacks.includes(stack)) {
stacks.push(stack);
}
}
else {
stack = shadowBarStack + index;
element.stack = stack;
stacks.push(stack);
}
});
datasets.splice(shadowBarIndex, 1);
stacks.forEach(value => {
const cloneShadowBar = {...shadowBar};
cloneShadowBar.stack = value;
datasets.push(cloneShadowBar);
});
}
}
}
if (this.datasetsCommon && chartConfig.data.datasets &&
chartConfig.data.datasets.length > 0) {
// border radius treatment
if (this.datasetsCommon.borderRadiusNumber
|| (this.datasetsCommon.borderRadius &&
(this.datasetsCommon.borderRadius.topLeft ||
this.datasetsCommon.borderRadius.topRight ||
this.datasetsCommon.borderRadius.bottomLeft ||
this.datasetsCommon.borderRadius.bottomRight))) {
const borderRadiusNumber: number = this.datasetsCommon.borderRadiusNumber;
chartConfig.data.datasets.forEach(dataset => dataset.borderRadius =
borderRadiusNumber ? borderRadiusNumber : this.datasetsCommon.borderRadius);
}
}
chartConfig.tooltips = {

View file

@ -0,0 +1,8 @@
import {BorderRadius as ChartBorderRadius} from "chart.js";
export class BorderRadius implements ChartBorderRadius {
public topLeft: number;
public topRight: number;
public bottomLeft: number;
public bottomRight: number;
}

View file

@ -1,6 +1,7 @@
import {AxisSettings} from "./AxisSettings";
export class ChartBarSettings {
public shadowBar: string;
public x: AxisSettings;
public y: AxisSettings;
}
}

View file

@ -0,0 +1,8 @@
import {Visible} from "@webbpm/base-package";
import {BorderRadius} from "./BorderRadius";
export class DatasetsCommon {
public borderRadiusNumber: number;
@Visible("borderRadiusNumber == null")
public borderRadius: BorderRadius;
}

View file

@ -2464,7 +2464,6 @@
<componentRootId>f0b30a65-2e61-4c6f-ae48-0f8b36d9e7cd</componentRootId>
<name>ГК Первый ряд</name>
<container>true</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered>
<scripts id="bf098f19-480e-44e4-9084-aa42955c4d0f">
<properties>
@ -2489,7 +2488,6 @@
<componentRootId>ed7170fb-6ca4-4f7d-8e11-f4c1805a881f</componentRootId>
<name>ВК Изменения сведений из ГИР ВУ</name>
<container>true</container>
<expanded>false</expanded>
<childrenReordered>false</childrenReordered>
<scripts id="bf098f19-480e-44e4-9084-aa42955c4d0f">
<properties>
@ -3141,6 +3139,48 @@
<expanded>false</expanded>
</value>
</item>
<item id="cdf0bfeb-b9ea-416b-aa25-67edc5d05766" removed="false">
<value>
<complex>
<entry>
<key>backgroundColor</key>
<value>
<simple>"#F2F2F2FF"</simple>
</value>
</entry>
<entry>
<key>chartType</key>
<value>
<simple>"BAR"</simple>
</value>
</entry>
<entry>
<key>dataColumn</key>
<value>
<simple>{"schema":"registration_change_address","table":"change_data_from_gir_vu","entity":"change_data_from_gir_vu","name":"count_all"}</simple>
</value>
</entry>
<entry>
<key>dataLabel</key>
<value>
<simple>"all"</simple>
</value>
</entry>
<entry>
<key>labelColumn</key>
<value>
<simple>{"schema":"registration_change_address","table":"change_data_from_gir_vu","entity":"change_data_from_gir_vu","name":"count_all"}</simple>
</value>
</entry>
<entry>
<key>stack</key>
<value>
<simple>"bar 100%"</simple>
</value>
</entry>
</complex>
</value>
</item>
</value>
</entry>
</complex>
@ -3173,6 +3213,12 @@
<value>
<complex>
<entry>
<key>shadowBar</key>
<value>
<simple>"bar 100%"</simple>
</value>
</entry>
<entry>
<key>x</key>
<value>
<complex>
@ -3195,6 +3241,12 @@
</complex>
</value>
</entry>
<entry>
<key>stacked</key>
<value>
<simple>false</simple>
</value>
</entry>
<entry>
<key>ticks</key>
<value>
@ -3248,6 +3300,19 @@
</value>
</entry>
</complex>
</value>
</entry>
</complex>
</value>
</entry>
<entry>
<key>datasetsCommon</key>
<value>
<complex>
<entry>
<key>borderRadiusNumber</key>
<value>
<simple>50.0</simple>
</value>
</entry>
</complex>