@datarailsshared/dr_renderer 1.5.72 → 1.5.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.5.72",
3
+ "version": "1.5.76",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -4464,30 +4464,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4464
4464
  return to_return;
4465
4465
  };
4466
4466
 
4467
- highchartsRenderer.checkFreezePanesAvaliable = function (pivotView) {
4468
- if (!pivotView || !pivotView.querySelector) {
4469
- return;
4470
- }
4471
-
4472
- const tableContainer = pivotView.querySelector('.pivot-div');
4473
- const tableHead = pivotView.querySelector('table.pvtTable thead');
4474
- const tableHeadChildren = tableHead ? tableHead.children[0] : null;
4475
- const trChildren = tableHeadChildren ? tableHeadChildren.children : [];
4476
- let thWidth = 0;
4477
-
4478
- for (let th of trChildren) {
4479
- if (th.classList.contains('axis-freeze-pane') || th.classList.contains('horizontal-freeze-pane')) {
4480
- thWidth += th.offsetWidth;
4481
- }
4482
- }
4483
-
4484
- if (thWidth >= tableContainer.offsetWidth) {
4485
- tableContainer.dataset.canFreezePanes = 'false';
4486
- } else if (thWidth < tableContainer.offsetWidth && tableContainer.dataset.canFreezePanes) {
4487
- delete tableContainer.dataset.canFreezePanes;
4488
- }
4489
- };
4490
-
4491
4467
  /**
4492
4468
  * Support rhPivotViewV2 version
4493
4469
  */
@@ -5177,19 +5153,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5177
5153
  }
5178
5154
  };
5179
5155
 
5180
- highchartsRenderer.setWidgetRawData = function (selectedTemplate) {
5181
- if (!selectedTemplate.widget_raw_data) {
5182
- selectedTemplate.widget_raw_data = lodash.map(selectedTemplate.raw_data,
5183
- function (row) {
5184
- var ob = {};
5185
- lodash.forEach(selectedTemplate.fields, function (value, key) {
5186
- ob[value.name] = row[value.name]; //highchartsRenderer.returnRawDataValue(value.type, row[value.name], value.format)+"";
5187
- });
5188
- return ob;
5189
- });
5190
- }
5191
- };
5192
-
5193
5156
  highchartsRenderer.updateBackwardCompatibleWidgetOptions = function(options, type) {
5194
5157
  if (lodash.get(options, 'chartOptions.chart.hideLegends', false)) {
5195
5158
  options.chartOptions.legends_position = { value: 'none' };
@@ -10049,8 +10012,23 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
10049
10012
  // It is just not counting sum there. So we remove it in order not to show improper values
10050
10013
  if ((calculatedValuesInValsCount > 1 || calculatedValuesInValsCount && widget.vals.length > 1) && !widget.rows.length) {
10051
10014
  res = lodash.filter(res, record => {
10015
+ // Check if record is metadata (has col_keys or row_keys)
10016
+ const isMetadata = typeof record['col_keys'] !== 'undefined' || typeof record['row_keys'] !== 'undefined';
10017
+ if (isMetadata) {
10018
+ return false;
10019
+ }
10020
+
10052
10021
  const isColsTotal = typeof record['DR_Values'] === 'undefined';
10053
- return !isColsTotal;
10022
+
10023
+ if (!isColsTotal) {
10024
+ return true;
10025
+ }
10026
+
10027
+ // If it doesn't have DR_Values, check if it has any value fields
10028
+ // Records with value fields are valid data, not empty subtotals
10029
+ return lodash.some(fieldWithDrValuesNames, fieldName => {
10030
+ return typeof record[fieldName] !== 'undefined' || typeof record['value'] !== 'undefined';
10031
+ });
10054
10032
  })
10055
10033
  }
10056
10034
  }
@@ -1501,53 +1501,6 @@ describe('highcharts_renderer', () => {
1501
1501
  });
1502
1502
  });
1503
1503
 
1504
- describe('function checkFreezePanesAvaliable', () => {
1505
- let pivotView;
1506
-
1507
- beforeEach(() => {
1508
- pivotView = document.createElement('div');
1509
- pivotView.innerHTML = `
1510
- <div class="pivot-div">
1511
- <table class="pvtTable">
1512
- <thead>
1513
- <tr>
1514
- <th class="axis-freeze-pane" style="width: 100px;"></th>
1515
- <th class="horizontal-freeze-pane" style="width: 100px;"></th>
1516
- <th style="width: 500px;"></th>
1517
- </tr>
1518
- </thead>
1519
- </table>
1520
- </div>
1521
- `;
1522
- });
1523
-
1524
- it('should set dataset.canFreezePanes to false when total width of frozen columns exceeds table width', () => {
1525
- const tableContainer = pivotView.querySelector('.pivot-div');
1526
- const expectedDataset = { canFreezePanes: 'false' };
1527
-
1528
- highchartsRenderer.checkFreezePanesAvaliable(pivotView);
1529
- expect(tableContainer.dataset.canFreezePanes).toEqual(expectedDataset.canFreezePanes);
1530
- });
1531
-
1532
- it('should remove dataset.canFreezePanes when total width of frozen columns is less than table width', () => {
1533
- const tableContainer ={
1534
- dataset: { canFreezePanes: "false" },
1535
- offsetWidth: 1000
1536
- };
1537
-
1538
- const _pivotView = {
1539
- querySelector: (p) => p === '.pivot-div' ? tableContainer : null
1540
- };
1541
- highchartsRenderer.checkFreezePanesAvaliable(_pivotView);
1542
-
1543
- expect(tableContainer.dataset.canFreezePanes).toEqual(undefined);
1544
- });
1545
-
1546
- it('should not set dataset.canFreezePanes when pivotView or pivotView.querySelector is undefined', () => {
1547
- expect(highchartsRenderer.checkFreezePanesAvaliable(null)).toEqual(undefined);
1548
- });
1549
- });
1550
-
1551
1504
  describe('function getOnlyIncludedOfField', () => {
1552
1505
  it('returns includes array if it exists', () => {
1553
1506
  const fieldObj = {
@@ -1773,56 +1726,6 @@ describe('highcharts_renderer', () => {
1773
1726
  });
1774
1727
  });
1775
1728
 
1776
- describe('function setWidgetRawData', () => {
1777
- it('should create widget_raw_data property if it does not exist', () => {
1778
- const selectedTemplate = {
1779
- raw_data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
1780
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '' }]
1781
- };
1782
-
1783
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1784
-
1785
- expect(selectedTemplate.widget_raw_data).toBeDefined();
1786
- });
1787
-
1788
- it('should map raw_data to widget_raw_data property', () => {
1789
- const selectedTemplate = {
1790
- raw_data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
1791
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '' }]
1792
- };
1793
-
1794
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1795
-
1796
- expect(selectedTemplate.widget_raw_data).toEqual([{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }]);
1797
- });
1798
-
1799
- it('should return raw_data values formatted based on their type and format', () => {
1800
- const selectedTemplate = {
1801
- raw_data: [{ name: 'John', age: 30.5 }, { name: 'Jane', age: 25 }],
1802
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '0.00' }]
1803
- };
1804
-
1805
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1806
-
1807
- expect(selectedTemplate.widget_raw_data[0].name).toBe('John');
1808
- expect(selectedTemplate.widget_raw_data[0].age).toBe(30.5);
1809
- expect(selectedTemplate.widget_raw_data[1].name).toBe('Jane');
1810
- expect(selectedTemplate.widget_raw_data[1].age).toBe(25);
1811
- });
1812
-
1813
- it('shouldn\'t create widget_raw_data if it exists', () => {
1814
- const selectedTemplate = {
1815
- widget_raw_data: [{}],
1816
- raw_data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
1817
- fields: [{ name: 'name', type: 'string', format: '' }, { name: 'age', type: 'number', format: '' }]
1818
- };
1819
-
1820
- highchartsRenderer.setWidgetRawData(selectedTemplate);
1821
-
1822
- expect(selectedTemplate.widget_raw_data.length).toBe(1);
1823
- });
1824
- });
1825
-
1826
1729
  describe("function updateBackwardCompatibleWidgetOptions", () => {
1827
1730
  it("should delete chart 'hideLegends' option if exists and true", () => {
1828
1731
  const options = {