@datarailsshared/dr_renderer 1.2.462 → 1.3.1-27.merge
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +13 -7
- package/.github/workflows/build-deploy.yml +29 -0
- package/CODEOWNERS +1 -0
- package/package.json +1 -1
- package/src/charts/dr_donut_chart.js +163 -0
- package/src/charts/dr_gauge_categories_summary_chart.js +323 -0
- package/src/charts/dr_gauge_chart.js +179 -130
- package/src/dr-renderer-helpers.js +20 -0
- package/src/dr_chart_tooltip.js +16 -9
- package/src/dr_pivottable.js +27 -3
- package/src/highcharts_renderer.js +350 -303
- package/src/pivot.css +32 -18
- package/src/published_items_renderer.js +6 -6
- package/src/smart_queries_helper.js +96 -0
- package/tests/dr-renderer-helpers.test.js +48 -0
- package/tests/dr_chart_tooltip.test.js +50 -0
- package/tests/dr_gauge_chart.test.js +64 -40
- package/tests/highcharts_renderer.test.js +39 -397
@@ -5,6 +5,7 @@ const { DrChartTooltip } = require("../src/dr_chart_tooltip");
|
|
5
5
|
jest.mock("../src/dr_chart_tooltip"); // Mock the tooltip class
|
6
6
|
|
7
7
|
const mockFormattedValue = "16,549";
|
8
|
+
let disableChartAnimation = false;
|
8
9
|
|
9
10
|
DrGaugeChart.highchartsRenderer = {
|
10
11
|
CHART_TYPES: {
|
@@ -20,6 +21,8 @@ DrGaugeChart.highchartsRenderer = {
|
|
20
21
|
formatValue: jest.fn().mockReturnValue({
|
21
22
|
value: mockFormattedValue,
|
22
23
|
}),
|
24
|
+
disableChartAnimations: jest.fn((value) => disableChartAnimation = value),
|
25
|
+
chartAnimationsDisabled: jest.fn(() => disableChartAnimation),
|
23
26
|
};
|
24
27
|
|
25
28
|
const mockAggregationValue = 1000;
|
@@ -111,19 +114,28 @@ describe("DrGaugeChart", () => {
|
|
111
114
|
chart.render();
|
112
115
|
expect(chart.configChart).toHaveBeenCalled();
|
113
116
|
});
|
117
|
+
|
118
|
+
it("disables chart animations by demand", () => {
|
119
|
+
chart.render();
|
120
|
+
expect(DrGaugeChart.highchartsRenderer.chartAnimationsDisabled).toHaveBeenCalledTimes(2);
|
121
|
+
});
|
114
122
|
});
|
115
123
|
|
116
124
|
describe("isLeftQuarter", () => {
|
117
125
|
it("should check in which quarter the chart value is", () => {
|
118
|
-
expect(chart.isLeftQuarter(20, 100)).toBe(true);
|
119
|
-
expect(chart.isLeftQuarter(20, 30)).toBe(false);
|
120
|
-
expect(chart.isLeftQuarter(20, 20)).toBe(false);
|
121
|
-
expect(chart.isLeftQuarter(100, 200)).toBe(false);
|
122
|
-
expect(chart.isLeftQuarter(99, 200)).toBe(true);
|
126
|
+
expect(chart.isLeftQuarter(20, 100, 0)).toBe(true);
|
127
|
+
expect(chart.isLeftQuarter(20, 30, 0)).toBe(false);
|
128
|
+
expect(chart.isLeftQuarter(20, 20, 0)).toBe(false);
|
129
|
+
expect(chart.isLeftQuarter(100, 200, 0)).toBe(false);
|
130
|
+
expect(chart.isLeftQuarter(99, 200, 0)).toBe(true);
|
131
|
+
|
132
|
+
expect(chart.isLeftQuarter(59, 100, 20)).toBe(true);
|
133
|
+
expect(chart.isLeftQuarter(60, 100, 20)).toBe(false);
|
123
134
|
});
|
124
135
|
|
125
|
-
it("should use default #max
|
136
|
+
it("should use default #max and #min parameters", () => {
|
126
137
|
// Max = 180
|
138
|
+
// Min = 0
|
127
139
|
expect(chart.isLeftQuarter(20)).toBe(true);
|
128
140
|
expect(chart.isLeftQuarter(120)).toBe(false);
|
129
141
|
});
|
@@ -148,13 +160,13 @@ describe("DrGaugeChart", () => {
|
|
148
160
|
title: "Title 1",
|
149
161
|
},
|
150
162
|
{
|
151
|
-
from:
|
163
|
+
from: 200,
|
152
164
|
to: 400,
|
153
165
|
color: "blue",
|
154
166
|
title: "Title 2",
|
155
167
|
},
|
156
168
|
{
|
157
|
-
from:
|
169
|
+
from: 400,
|
158
170
|
to: 800,
|
159
171
|
color: "blue",
|
160
172
|
title: "Title 3",
|
@@ -204,13 +216,13 @@ describe("DrGaugeChart", () => {
|
|
204
216
|
title: "Title 1",
|
205
217
|
},
|
206
218
|
{
|
207
|
-
from:
|
219
|
+
from: 200,
|
208
220
|
to: 400,
|
209
221
|
color: "blue",
|
210
222
|
title: "Title 2",
|
211
223
|
},
|
212
224
|
{
|
213
|
-
from:
|
225
|
+
from: 400,
|
214
226
|
to: 800,
|
215
227
|
color: "blue",
|
216
228
|
title: "Title 3",
|
@@ -260,13 +272,13 @@ describe("DrGaugeChart", () => {
|
|
260
272
|
title: "Title 1",
|
261
273
|
},
|
262
274
|
{
|
263
|
-
from:
|
275
|
+
from: 50,
|
264
276
|
to: 100,
|
265
277
|
color: "blue",
|
266
278
|
title: "Title 2",
|
267
279
|
},
|
268
280
|
{
|
269
|
-
from:
|
281
|
+
from: 100,
|
270
282
|
to: 175,
|
271
283
|
color: "blue",
|
272
284
|
title: "Title 3",
|
@@ -302,7 +314,7 @@ describe("DrGaugeChart", () => {
|
|
302
314
|
describe("createTicks", () => {
|
303
315
|
it("should create a ticks array", () => {
|
304
316
|
expect(
|
305
|
-
|
317
|
+
DrGaugeChart.createTicks(
|
306
318
|
[
|
307
319
|
{
|
308
320
|
to: 100,
|
@@ -325,7 +337,7 @@ describe("DrGaugeChart", () => {
|
|
325
337
|
|
326
338
|
it("should sort and remove duplicates", () => {
|
327
339
|
expect(
|
328
|
-
|
340
|
+
DrGaugeChart.createTicks(
|
329
341
|
[
|
330
342
|
{
|
331
343
|
to: 100,
|
@@ -461,7 +473,7 @@ describe("DrGaugeChart", () => {
|
|
461
473
|
expect(simplifyString(label)).toBe(
|
462
474
|
simplifyString(
|
463
475
|
`<span style="display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 16px;">
|
464
|
-
<span style="font-weight: 600; font-size: 1.
|
476
|
+
<span style="font-weight: 600; font-size: 1.3em; line-height: 1; color: #000">
|
465
477
|
${mockFormattedValue}
|
466
478
|
</span>
|
467
479
|
<span style="font-weight: 500; font-size: 0.875em; line-height: 1; color: #808080;">Current status</span>
|
@@ -486,7 +498,7 @@ describe("DrGaugeChart", () => {
|
|
486
498
|
expect(simplifyString(label)).toBe(
|
487
499
|
simplifyString(
|
488
500
|
`<span style="display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 24px;">
|
489
|
-
<span style="font-weight: 600; font-size: 1.
|
501
|
+
<span style="font-weight: 600; font-size: 1.3em; line-height: 1; color: #000">
|
490
502
|
${mockFormattedValue}
|
491
503
|
<span style="font-size: 0.5833em; font-weight: 600; color: #929292;">(56%)</span>
|
492
504
|
</span>
|
@@ -703,12 +715,12 @@ describe("DrGaugeChart", () => {
|
|
703
715
|
describe("getValue", () => {
|
704
716
|
it("should return aggregator value unledss the total is empty", () => {
|
705
717
|
DrGaugeChart.highchartsRenderer.ptCreateBasicLineSeries.mockReturnValue([]);
|
706
|
-
expect(
|
718
|
+
expect(DrGaugeChart.getValue(mockPivotData, {})).toBe(mockAggregationValue);
|
707
719
|
});
|
708
720
|
|
709
721
|
it("should return value to display", () => {
|
710
722
|
DrGaugeChart.highchartsRenderer.ptCreateBasicLineSeries.mockReturnValue([{ data: [2000] }]);
|
711
|
-
expect(
|
723
|
+
expect(DrGaugeChart.getValue(mockPivotData, {})).toBe(2000);
|
712
724
|
});
|
713
725
|
|
714
726
|
it("should calculate total", () => {
|
@@ -717,7 +729,7 @@ describe("DrGaugeChart", () => {
|
|
717
729
|
{ data: [3000] },
|
718
730
|
{ data: [5000] },
|
719
731
|
]);
|
720
|
-
expect(
|
732
|
+
expect(DrGaugeChart.getValue(mockPivotData, {})).toBe(10000);
|
721
733
|
});
|
722
734
|
});
|
723
735
|
|
@@ -741,14 +753,14 @@ describe("DrGaugeChart", () => {
|
|
741
753
|
};
|
742
754
|
|
743
755
|
it("return a start border position", () => {
|
744
|
-
expect(
|
756
|
+
expect(DrGaugeChart.getBorderPosition(mockChart, mockOptions, "start")).toEqual({
|
745
757
|
x: 170,
|
746
758
|
y: 201,
|
747
759
|
});
|
748
760
|
});
|
749
761
|
|
750
762
|
it("return an end border position", () => {
|
751
|
-
expect(
|
763
|
+
expect(DrGaugeChart.getBorderPosition(mockChart, mockOptions, "end")).toEqual({
|
752
764
|
x: 230,
|
753
765
|
y: 201,
|
754
766
|
});
|
@@ -757,7 +769,7 @@ describe("DrGaugeChart", () => {
|
|
757
769
|
|
758
770
|
describe("createBorder", () => {
|
759
771
|
beforeEach(() => {
|
760
|
-
|
772
|
+
DrGaugeChart.getBorderPosition = jest.fn().mockReturnValue({
|
761
773
|
x: 100,
|
762
774
|
y: 200,
|
763
775
|
});
|
@@ -801,7 +813,7 @@ describe("DrGaugeChart", () => {
|
|
801
813
|
};
|
802
814
|
|
803
815
|
it("should create a start border", () => {
|
804
|
-
|
816
|
+
DrGaugeChart.createBorder(
|
805
817
|
mockChart,
|
806
818
|
{
|
807
819
|
gauge: {
|
@@ -830,7 +842,7 @@ describe("DrGaugeChart", () => {
|
|
830
842
|
});
|
831
843
|
|
832
844
|
it("should create an end border", () => {
|
833
|
-
|
845
|
+
DrGaugeChart.createBorder(
|
834
846
|
mockChart,
|
835
847
|
{
|
836
848
|
gauge: {
|
@@ -986,7 +998,7 @@ describe("DrGaugeChart", () => {
|
|
986
998
|
describe("getValueLabelPosition", () => {
|
987
999
|
it("should return a value label position depends on the pane center and offsets", () => {
|
988
1000
|
expect(
|
989
|
-
|
1001
|
+
DrGaugeChart.getValueLabelPosition(
|
990
1002
|
{
|
991
1003
|
pane: [
|
992
1004
|
{
|
@@ -1008,7 +1020,7 @@ describe("DrGaugeChart", () => {
|
|
1008
1020
|
});
|
1009
1021
|
|
1010
1022
|
expect(
|
1011
|
-
|
1023
|
+
DrGaugeChart.getValueLabelPosition(
|
1012
1024
|
{
|
1013
1025
|
pane: [
|
1014
1026
|
{
|
@@ -1040,7 +1052,7 @@ describe("DrGaugeChart", () => {
|
|
1040
1052
|
|
1041
1053
|
beforeEach(() => {
|
1042
1054
|
chart.formatValueLabel = jest.fn().mockReturnValue("<div>Mock label</div>");
|
1043
|
-
|
1055
|
+
DrGaugeChart.getValueLabelPosition = jest.fn().mockReturnValue({
|
1044
1056
|
x: 100,
|
1045
1057
|
y: 200,
|
1046
1058
|
});
|
@@ -1204,6 +1216,15 @@ describe("DrGaugeChart", () => {
|
|
1204
1216
|
css: jest.fn(),
|
1205
1217
|
},
|
1206
1218
|
},
|
1219
|
+
180: {
|
1220
|
+
pos: 180,
|
1221
|
+
label: {
|
1222
|
+
css: jest.fn(),
|
1223
|
+
},
|
1224
|
+
mark: {
|
1225
|
+
attr: jest.fn(),
|
1226
|
+
},
|
1227
|
+
},
|
1207
1228
|
},
|
1208
1229
|
},
|
1209
1230
|
],
|
@@ -1234,11 +1255,14 @@ describe("DrGaugeChart", () => {
|
|
1234
1255
|
yAxis: [
|
1235
1256
|
{
|
1236
1257
|
ticks: {
|
1237
|
-
|
1258
|
+
180: {
|
1238
1259
|
pos: 180,
|
1239
1260
|
mark: {
|
1240
1261
|
attr: jest.fn(),
|
1241
1262
|
},
|
1263
|
+
label: {
|
1264
|
+
css: jest.fn(),
|
1265
|
+
},
|
1242
1266
|
},
|
1243
1267
|
},
|
1244
1268
|
},
|
@@ -1256,7 +1280,7 @@ describe("DrGaugeChart", () => {
|
|
1256
1280
|
},
|
1257
1281
|
});
|
1258
1282
|
// add a goal tick styles
|
1259
|
-
expect(mockChart.yAxis[0].ticks[
|
1283
|
+
expect(mockChart.yAxis[0].ticks[180].mark.attr).toHaveBeenCalledWith({
|
1260
1284
|
"pointer-events": "none",
|
1261
1285
|
stroke: "blue",
|
1262
1286
|
"stroke-dasharray": 2,
|
@@ -1524,7 +1548,7 @@ describe("DrGaugeChart", () => {
|
|
1524
1548
|
|
1525
1549
|
// Spy on class methods
|
1526
1550
|
jest.spyOn(chart, "createValueLabel").mockReturnValue(mockValueLabel);
|
1527
|
-
jest.spyOn(
|
1551
|
+
jest.spyOn(DrGaugeChart, "createBorder").mockImplementation((chart, options, position) => {
|
1528
1552
|
if (position === "start") return mockStartBorder;
|
1529
1553
|
if (position === "end") return mockEndBorder;
|
1530
1554
|
});
|
@@ -1545,14 +1569,14 @@ describe("DrGaugeChart", () => {
|
|
1545
1569
|
it("assigns the start border to chart.startBorder", () => {
|
1546
1570
|
chart.setCustomElements(mockChart, mockOptions);
|
1547
1571
|
|
1548
|
-
expect(
|
1572
|
+
expect(DrGaugeChart.createBorder).toHaveBeenCalledWith(mockChart, mockOptions, "start");
|
1549
1573
|
expect(mockChart.startBorder).toBe(mockStartBorder);
|
1550
1574
|
});
|
1551
1575
|
|
1552
1576
|
it("assigns the end border to chart.endBorder", () => {
|
1553
1577
|
chart.setCustomElements(mockChart, mockOptions);
|
1554
1578
|
|
1555
|
-
expect(
|
1579
|
+
expect(DrGaugeChart.createBorder).toHaveBeenCalledWith(mockChart, mockOptions, "end");
|
1556
1580
|
expect(mockChart.endBorder).toBe(mockEndBorder);
|
1557
1581
|
});
|
1558
1582
|
|
@@ -1593,12 +1617,12 @@ describe("DrGaugeChart", () => {
|
|
1593
1617
|
mockValueLabelPosition = { x: 70, y: 80 };
|
1594
1618
|
|
1595
1619
|
// Spy on helper methods
|
1596
|
-
jest.spyOn(
|
1620
|
+
jest.spyOn(DrGaugeChart, "getBorderPosition").mockImplementation((chart, options, position) => {
|
1597
1621
|
if (position === "start") return mockStartPosition;
|
1598
1622
|
if (position === "end") return mockEndPosition;
|
1599
1623
|
});
|
1600
1624
|
jest.spyOn(chart, "getGoalIconPosition").mockReturnValue(mockGoalIconPosition);
|
1601
|
-
jest.spyOn(
|
1625
|
+
jest.spyOn(DrGaugeChart, "getValueLabelPosition").mockReturnValue(mockValueLabelPosition);
|
1602
1626
|
});
|
1603
1627
|
|
1604
1628
|
afterEach(() => {
|
@@ -1608,14 +1632,14 @@ describe("DrGaugeChart", () => {
|
|
1608
1632
|
it("updates startBorder attributes correctly", () => {
|
1609
1633
|
chart.updateCustomElements(mockChart, mockOptions);
|
1610
1634
|
|
1611
|
-
expect(
|
1635
|
+
expect(DrGaugeChart.getBorderPosition).toHaveBeenCalledWith(mockChart, mockOptions, "start");
|
1612
1636
|
expect(mockChart.startBorder.attr).toHaveBeenCalledWith(mockStartPosition);
|
1613
1637
|
});
|
1614
1638
|
|
1615
1639
|
it("updates endBorder attributes correctly", () => {
|
1616
1640
|
chart.updateCustomElements(mockChart, mockOptions);
|
1617
1641
|
|
1618
|
-
expect(
|
1642
|
+
expect(DrGaugeChart.getBorderPosition).toHaveBeenCalledWith(mockChart, mockOptions, "end");
|
1619
1643
|
expect(mockChart.endBorder.attr).toHaveBeenCalledWith(mockEndPosition);
|
1620
1644
|
});
|
1621
1645
|
|
@@ -1629,7 +1653,7 @@ describe("DrGaugeChart", () => {
|
|
1629
1653
|
it("updates label attributes correctly", () => {
|
1630
1654
|
chart.updateCustomElements(mockChart, mockOptions);
|
1631
1655
|
|
1632
|
-
expect(
|
1656
|
+
expect(DrGaugeChart.getValueLabelPosition).toHaveBeenCalledWith(mockChart, mockOptions);
|
1633
1657
|
expect(mockChart.label.attr).toHaveBeenCalledWith(mockValueLabelPosition);
|
1634
1658
|
});
|
1635
1659
|
});
|
@@ -1729,13 +1753,13 @@ describe("DrGaugeChart", () => {
|
|
1729
1753
|
color: "#BF1D30",
|
1730
1754
|
},
|
1731
1755
|
{
|
1732
|
-
from:
|
1756
|
+
from: 50,
|
1733
1757
|
to: 160,
|
1734
1758
|
title: "Medium",
|
1735
1759
|
color: "#FFA310",
|
1736
1760
|
},
|
1737
1761
|
{
|
1738
|
-
from:
|
1762
|
+
from: 160,
|
1739
1763
|
to: 200,
|
1740
1764
|
title: "High",
|
1741
1765
|
color: "#037C5A",
|
@@ -1889,7 +1913,7 @@ describe("DrGaugeChart", () => {
|
|
1889
1913
|
expect(config.yAxis.labels.enabled).toBe(mockOptions.label.show);
|
1890
1914
|
expect(config.yAxis.labels.distance).toBe(0),
|
1891
1915
|
expect(config.yAxis.labels.verticalAlign).toBe("middle"),
|
1892
|
-
expect(config.yAxis.labels.allowOverlap).toBe(
|
1916
|
+
expect(config.yAxis.labels.allowOverlap).toBe(false),
|
1893
1917
|
expect(config.yAxis.labels.align).toBe("left");
|
1894
1918
|
expect(config.yAxis.labels.style).toEqual({
|
1895
1919
|
whiteSpace: "nowrap",
|