@datarailsshared/dr_renderer 1.2.439 → 1.2.441

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.2.439",
3
+ "version": "1.2.441",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -2090,6 +2090,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2090
2090
  highchartsRenderer.setYAxisMinMax(chartOptions.yAxis[1], opts.comboOptions.secondaryAxisSettings);
2091
2091
  };
2092
2092
 
2093
+ /**
2094
+ * @deprecated Basic Pie Chart has been deprecated. Please use PieWithDrilldown instead.
2095
+ */
2096
+
2093
2097
  highchartsRenderer.ptRenderBasicPie = function (pivotData, opts) {
2094
2098
  var chartOptions = {};
2095
2099
  var additionOptions = opts.chartOptions ? opts.chartOptions : highchartsRenderer.getDefaultValueForChart('pie-chart');
@@ -8321,6 +8321,185 @@ describe('highcharts_renderer', () => {
8321
8321
  });
8322
8322
  });
8323
8323
 
8324
+ describe('highchartsRenderer.ptRenderPieWithDrillDown', () => {
8325
+ beforeEach(() => {
8326
+ jest.spyOn(highchartsRenderer, 'ptCreateSeriesToDrillDownChart')
8327
+ .mockReturnValue([{ name: 'Sample Series', data: [1, 2, 3] }]);
8328
+ jest.spyOn(highchartsRenderer, 'ptCreateElementAndDraw').mockImplementation(() => {});
8329
+ });
8330
+
8331
+ afterEach(() => {
8332
+ jest.restoreAllMocks();
8333
+ });
8334
+
8335
+ it('should call ptCreateElementAndDraw with correct chart options', () => {
8336
+ const pivotData = {
8337
+ getColKeys: jest.fn(() => [['Category 1'], ['Category 2']]),
8338
+ getRowKeys: jest.fn(() => [['Row 1'], ['Row 2']]),
8339
+ isDrillDownDisabled: false,
8340
+ getAggregator: jest.fn((row, col) => ({
8341
+ value: jest.fn(() => 100)
8342
+ })),
8343
+ rows: { 0: { type: 'Date' }, 1: { type: 'Date' } },
8344
+ cols: { 0: { type: 'Category' }, 1: { type: 'Category' } }
8345
+ };
8346
+
8347
+ const opts = {
8348
+ chartOptions: {
8349
+ label_pie: {
8350
+ overlap: true,
8351
+ show: true
8352
+ },
8353
+ chart: {
8354
+ colors_offset: 1
8355
+ }
8356
+ }
8357
+ };
8358
+
8359
+ const drilldownFunc = jest.fn();
8360
+
8361
+ highchartsRenderer.ptRenderPieWithDrillDown(pivotData, opts, drilldownFunc);
8362
+
8363
+ const expectedChartOptions = {
8364
+ chart: {
8365
+ type: 'pie',
8366
+ events: {
8367
+ drilldown: expect.any(Function),
8368
+ drillup: expect.any(Function)
8369
+ }
8370
+ },
8371
+ colors: ["#91e7e7", "#f37789", "#ffdc65", "#0e569d", "#bbe0ff", "#57b2ff", "#5ecfb9", "#c7ffda", "#179ab9", "#008aff"],
8372
+ plotOptions: {
8373
+ series: {
8374
+ animation: true,
8375
+ dataLabels: {
8376
+ allowOverlap: true,
8377
+ color: "#151a41",
8378
+ enabled: true,
8379
+ formatter: expect.any(Function),
8380
+ style: {
8381
+ "fontFamily": "Poppins",
8382
+ "fontSize": "11",
8383
+ "fontWeight": "normal"
8384
+ }
8385
+ },
8386
+ showInLegend: true
8387
+ }
8388
+ },
8389
+ tooltip: {
8390
+ headerFormat: '',
8391
+ pointFormatter: expect.any(Function)
8392
+ },
8393
+ series: [{ name: 'Sample Series', data: [1, 2, 3] }],
8394
+ legend: {
8395
+ align: "right",
8396
+ borderWidth: 0,
8397
+ enabled: true,
8398
+ itemMarginTop: 10,
8399
+ layout: "vertical",
8400
+ verticalAlign: "top",
8401
+ y: 13
8402
+ },
8403
+ drilldown: {},
8404
+ subtitle: {
8405
+ align: "center",
8406
+ style: {
8407
+ "color": "#2969b0",
8408
+ "font-family": "'Poppins', sans-serif",
8409
+ "font-size": "14px",
8410
+ "font-weight": "100"
8411
+ },
8412
+ text: ""
8413
+ },
8414
+ title: {
8415
+ align: "center",
8416
+ style: {
8417
+ "color": "#2969b0",
8418
+ "font-family": "'Poppins', sans-serif",
8419
+ "font-size": "18px",
8420
+ "font-weight": "300"
8421
+ },
8422
+ text: ""
8423
+ }
8424
+ };
8425
+ expect(highchartsRenderer.ptCreateElementAndDraw).toHaveBeenCalledWith(expectedChartOptions, opts);
8426
+ });
8427
+ });
8428
+
8429
+ describe('highchartsRenderer.ptRenderBasicPie', () => {
8430
+ const pivotData = {
8431
+ getColKeys: jest.fn(() => [['Category 1'], ['Category 2']]),
8432
+ getRowKeys: jest.fn(() => [['Row 1'], ['Row 2']]),
8433
+ getAggregator: jest.fn(() => ({ value: jest.fn(() => 100) }))
8434
+ };
8435
+
8436
+ const opts = {
8437
+ chartOptions: {
8438
+ label_pie: { show: true, overlap: true },
8439
+ chart: { colors_offset: 1 },
8440
+ hideChartHeader: false
8441
+ },
8442
+ drillDownListFunc: jest.fn()
8443
+ };
8444
+
8445
+ beforeEach(() => {
8446
+ jest.spyOn(highchartsRenderer, 'ptCreateElementAndDraw').mockImplementation(() => {});
8447
+ jest.spyOn(highchartsRenderer, 'getFormattedColKey').mockImplementation((name) => `Formatted ${name}`);
8448
+ });
8449
+
8450
+ afterEach(() => {
8451
+ jest.restoreAllMocks();
8452
+ });
8453
+
8454
+ it('should call ptCreateElementAndDraw with correct chart options', () => {
8455
+ highchartsRenderer.ptRenderBasicPie(pivotData, opts);
8456
+
8457
+ expect(highchartsRenderer.ptCreateElementAndDraw).toHaveBeenCalledWith(
8458
+ expect.objectContaining({
8459
+ chart: expect.objectContaining({
8460
+ type: 'pie'
8461
+ }),
8462
+ colors: expect.arrayContaining(["#91e7e7", "#f37789"]),
8463
+ plotOptions: expect.objectContaining({
8464
+ pie: expect.objectContaining({
8465
+ allowPointSelect: true,
8466
+ cursor: 'pointer',
8467
+ dataLabels: expect.objectContaining({
8468
+ enabled: true,
8469
+ allowOverlap: true,
8470
+ style: expect.objectContaining({
8471
+ fontFamily: "Poppins",
8472
+ fontSize: "11",
8473
+ fontWeight: "normal"
8474
+ })
8475
+ }),
8476
+ showInLegend: true
8477
+ })
8478
+ }),
8479
+ series: expect.arrayContaining([
8480
+ expect.objectContaining({
8481
+ name: 'Row 1',
8482
+ colorByPoint: true,
8483
+ data: expect.arrayContaining([
8484
+ expect.objectContaining({
8485
+ initialName: ["Category 1"],
8486
+ name: 'Formatted Category 1',
8487
+ y: 100
8488
+ }),
8489
+ expect.objectContaining({
8490
+ initialName: ["Category 2"],
8491
+ name: 'Formatted Category 2',
8492
+ y: 100
8493
+ })
8494
+ ])
8495
+ })
8496
+ ])
8497
+ }),
8498
+ opts
8499
+ );
8500
+ });
8501
+ });
8502
+
8324
8503
  describe('Function ptRenderGauge', () => {
8325
8504
 
8326
8505
  const pivotDataMock = {