pace-chart-lib 1.0.2 → 1.0.4

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.
Files changed (131) hide show
  1. package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
  2. package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
  3. package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
  4. package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/pace-chart-lib.es.js +54619 -0
  7. package/dist/pace-chart-lib.umd.js +54622 -0
  8. package/dist/vite.svg +1 -0
  9. package/package.json +1 -1
  10. package/dist/Services/ErrorLog.js +0 -3
  11. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
  12. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
  13. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
  14. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
  15. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
  16. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
  17. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
  18. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
  19. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
  20. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
  21. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
  22. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
  23. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  24. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  25. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
  26. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
  27. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
  28. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
  29. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
  30. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
  31. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
  32. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
  33. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
  34. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
  35. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
  36. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
  37. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
  38. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
  39. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
  40. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
  41. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
  42. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
  43. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
  44. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
  45. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
  46. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
  47. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  48. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  49. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
  50. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
  51. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
  52. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
  53. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
  54. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
  55. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
  56. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
  57. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
  58. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  59. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  60. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
  61. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  62. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  63. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
  64. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
  65. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
  66. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
  67. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
  68. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
  69. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
  70. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
  71. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
  72. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
  73. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
  74. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
  75. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
  76. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
  77. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
  78. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
  79. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
  80. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
  81. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  82. package/dist/components/Charts/Core/Common.type.js +0 -0
  83. package/dist/components/Charts/Core/Common.types.js +0 -133
  84. package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
  85. package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
  86. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  87. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  88. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
  89. package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
  90. package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
  91. package/dist/index.js +0 -40
  92. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
  93. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
  94. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
  95. /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
  96. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
  97. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
  98. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
  99. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
  100. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
  101. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
  102. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
  103. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
  104. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
  105. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
  106. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
  107. /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
  108. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
  109. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
  110. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
  111. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
  112. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  113. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
  114. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
  115. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
  116. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
  117. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
  118. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
  119. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
  120. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
  121. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
  122. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
  123. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
  124. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
  125. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
  126. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
  127. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
  128. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
  129. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
  130. /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
  131. /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
@@ -1,451 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- //#region Imports
3
- import * as d3 from "d3";
4
- import * as d3Annotation from "d3-svg-annotation";
5
- import { useEffect, useRef } from "react";
6
- import { logError } from "../../../../Services/ErrorLog";
7
- import { staticLineStyle } from "../../Core/Common.types";
8
- import { drawLegends, lineMarkers } from "../../Core/CommonFunctions";
9
- import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getCurveType, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, initYaxisRight, lineAnnotations, marginCalculation, prepareDataForSeriesLabel, responsiveSecondaryYaxisLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
10
- import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
11
- const ColumnChart = ({ title, width, height, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
12
- // adding variables as per requirement
13
- const barWidth = 0; // coz line chart
14
- const chartType = actualChartTypes.line;
15
- const svgRef = useRef();
16
- const seriesData = data;
17
- const barChart = false;
18
- let isSecondaryAxisDrawn = false;
19
- const isNormalizedChart = false;
20
- let isPrimaryAxisDrawn = true;
21
- let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
22
- let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
23
- let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
24
- let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
25
- let margin;
26
- let yLabel;
27
- let xLabel;
28
- let yTitle;
29
- let xTitle;
30
- let dimensionHeightWidthArray;
31
- let chartTitleHeight;
32
- let secondaryAxisTitleWidth;
33
- let legendMargin;
34
- let secondaryYLabel;
35
- let maxNumberForPrimaryAxis;
36
- let maxNumberForSecondaryAxis;
37
- let innerWidth;
38
- let innerHeight;
39
- let dataTable;
40
- let dataTableHeight;
41
- let svg;
42
- let gTag;
43
- let yScaleLeft;
44
- let yScaleRight;
45
- let xScale;
46
- let seriesLabels;
47
- let calculatedRange;
48
- let seriesLabelWidth;
49
- let yAxisLeft;
50
- let xAxis;
51
- let yAxisRight;
52
- let filteredDimension;
53
- let filteredData;
54
- let scrollPosition = 0;
55
- const visibleBars = 2;
56
- let chartJSON = {
57
- dimensionList: [],
58
- chartType: chartType,
59
- chartData: [],
60
- formatOptions: formatOptions,
61
- legendList: [],
62
- secondaryAxisDrawn: false,
63
- yMaxLeft: 0,
64
- yMaxRight: 0,
65
- yMinLeft: 0,
66
- yMinRight: 0,
67
- hideZeroValues: false,
68
- formattedDimensionListMap: new Map(),
69
- };
70
- //#region UseEffect
71
- useEffect(() => {
72
- try {
73
- createLineChart();
74
- }
75
- catch (error) {
76
- logError("Linechart", "createLineChart", error);
77
- }
78
- }, []);
79
- //#endregion
80
- const createLineChart = () => {
81
- ({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
82
- preProcessChartData(); // preaparing data related to chart creation
83
- // Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
84
- ({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(
85
- // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
86
- formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
87
- ({
88
- margin,
89
- yLabel,
90
- xLabel,
91
- yTitle,
92
- xTitle,
93
- dimensionHeightWidthArray,
94
- chartTitleHeight,
95
- secondaryAxisTitleWidth,
96
- legendMargin,
97
- secondaryYLabel,
98
- } = marginCalculation(
99
- // for all margin related calculations
100
- width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart));
101
- setSVGContainer(margin); // for innerWidth/height static width/height
102
- ({ dataTable, dataTableHeight } = dataTablePreCalculation(
103
- // calculations for data tables
104
- formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
105
- initSvg(
106
- // for svg creation
107
- svg, width, height, formatOptions);
108
- gTag = initChartArea(svg, margin); // creating chart area
109
- initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
110
- initScale();
111
- initAxis();
112
- initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
113
- initYaxisRight(gTag, formatOptions, dataTableHeight, secondaryYLabel, yAxisRight, innerHeight, innerWidth);
114
- horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
115
- if (formatOptions.dataTableProperties &&
116
- formatOptions.dataTableProperties.dataTable) {
117
- if (formatOptions.xAxisLabel.xAxisPosition != 1)
118
- formatOptions.xAxisLabel.xAxisLabelVisibility = false;
119
- addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, barWidth, yScaleLeft, xScale, undefined, undefined, undefined, dataTableHeight, "Line", formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
120
- }
121
- setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
122
- yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
123
- yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
124
- setChartTitle(svg, formatOptions, width, chartTitleHeight);
125
- drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId);
126
- };
127
- const preProcessChartData = () => {
128
- const allChartData = [];
129
- const legendList = [];
130
- const dimensionSet = new Set();
131
- let formatedDimesionList = [];
132
- let yMaxLeft = -Infinity;
133
- let yMinLeft = Infinity;
134
- let yMaxRight = -Infinity;
135
- let yMinRight = Infinity;
136
- seriesData.forEach((series) => {
137
- legendList.push(series.legend);
138
- series.data.forEach((point) => {
139
- allChartData.push(point);
140
- dimensionSet.add(point.dimension);
141
- if (series.properties.axis === "Secondary") {
142
- isSecondaryAxisDrawn = true;
143
- yMaxRight = Math.max(yMaxRight, point.value);
144
- yMinRight = Math.min(yMinRight, point.value);
145
- }
146
- else {
147
- yMaxLeft = Math.max(yMaxLeft, point.value);
148
- yMinLeft = Math.min(yMinLeft, point.value);
149
- }
150
- });
151
- });
152
- chartJSON.chartData = allChartData;
153
- chartJSON.legendList = legendList;
154
- chartJSON.dimensionList = Array.from(dimensionSet);
155
- chartJSON.yMaxLeft = yMaxLeft;
156
- chartJSON.yMinLeft = yMinLeft;
157
- chartJSON.yMaxRight = yMaxRight;
158
- chartJSON.yMinRight = yMinRight;
159
- // Apply formatted dimensions
160
- let xAxisObject = xAxisObj[0];
161
- formatedDimesionList =
162
- (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
163
- xAxisObject.dataType === "DATE"
164
- ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d[0])
165
- : chartJSON.dimensionList;
166
- chartJSON.dimensionList.forEach((dim, i) => {
167
- chartJSON.formattedDimensionListMap.set(dim, formatedDimesionList[i]);
168
- });
169
- filteredData = JSON.parse(JSON.stringify(seriesData));
170
- // if (formatOptions.scrollChart.scrollX) {
171
- if (false) {
172
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
173
- }
174
- else {
175
- filteredDimension = chartJSON.dimensionList;
176
- }
177
- if (formatOptions.plotArea.hideZeroValues) {
178
- chartJSON.hideZeroValues = true;
179
- }
180
- };
181
- const initScale = () => {
182
- // rounding the ymin & ymax
183
- let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
184
- chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
185
- chartJSON.yMinLeft = yAxisLabelArray[0];
186
- if (isPrimaryAxisDrawn) {
187
- yScaleLeft = d3
188
- .scaleLinear()
189
- .domain([
190
- customYaxisMinValue !== undefined &&
191
- !Number.isNaN(customYaxisMinValue)
192
- ? customYaxisMinValue
193
- : chartJSON.yMinLeft < 0
194
- ? chartJSON.yMinLeft * 1.1
195
- : chartJSON.yMinLeft * 0.9,
196
- chartJSON.yMaxLeft <= 0
197
- ? 0
198
- : customYaxisMaxValue !== undefined &&
199
- !Number.isNaN(customYaxisMaxValue)
200
- ? customYaxisMaxValue
201
- : chartJSON.yMaxLeft * 1.1,
202
- ])
203
- .range([
204
- dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
205
- 0,
206
- ]);
207
- }
208
- if (isSecondaryAxisDrawn) {
209
- yScaleRight = d3
210
- .scaleLinear()
211
- .domain([
212
- chartJSON.yMinRight >= 0
213
- ? (secondaryCustomYaxisMinValue ||
214
- secondaryCustomYaxisMinValue == 0) &&
215
- !Number.isNaN(secondaryCustomYaxisMinValue)
216
- ? secondaryCustomYaxisMinValue
217
- : 0
218
- : (secondaryCustomYaxisMinValue ||
219
- secondaryCustomYaxisMinValue == 0) &&
220
- !Number.isNaN(secondaryCustomYaxisMinValue)
221
- ? secondaryCustomYaxisMinValue
222
- : chartJSON.yMinRight * 1.1,
223
- chartJSON.yMaxRight <= 0
224
- ? secondaryCustomYaxisMaxValue
225
- ? secondaryCustomYaxisMaxValue
226
- : 0
227
- : secondaryCustomYaxisMaxValue
228
- ? secondaryCustomYaxisMaxValue
229
- : chartJSON.yMaxRight * 1.1,
230
- ])
231
- .range([
232
- dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
233
- 0,
234
- ]);
235
- }
236
- calculatedRange = [0, innerWidth];
237
- if (formatOptions.seriesLabel.seriesLabelVisibility) {
238
- let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn);
239
- seriesLabels = labelObj.labelArray;
240
- formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
241
- (seriesLabelWidth = labelObj.heightWidth[0]);
242
- formatOptions.seriesLabel.seriesLabelPosition == "Right"
243
- ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
244
- : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
245
- }
246
- getXScale();
247
- };
248
- const getXScale = () => {
249
- xScale = d3
250
- .scalePoint()
251
- .domain(filteredDimension)
252
- .range(calculatedRange)
253
- .padding(0.5);
254
- };
255
- const initAxis = () => {
256
- getXAxis();
257
- if (isPrimaryAxisDrawn) {
258
- yAxisLeft = d3
259
- .axisLeft(yScaleLeft)
260
- .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
261
- .tickSize(formatOptions.plotArea.gridLinesVisibility
262
- ? formatOptions.plotArea.gridLinesHorizontal
263
- ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
264
- : 0
265
- : 0)
266
- .tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
267
- .ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
268
- (dataTableHeight > 0
269
- ? (innerHeight - dataTableHeight) / 30
270
- : innerHeight / 30))
271
- .tickSizeOuter(0);
272
- }
273
- if (isSecondaryAxisDrawn) {
274
- yAxisRight = d3
275
- .axisRight(yScaleRight)
276
- .tickFormat((d) => getNumberWithFormat(d, formatOptions.secondaryYAxisLabel.secondaryYAxisDisplayUnits, formatOptions.secondaryYAxisLabel.secondaryYAxisNumberFormat, formatOptions.secondaryYAxisLabel
277
- .secondaryYAxisLabelDecimalPrecision))
278
- .tickValues(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
279
- ? secondaryCustomYaxisMaxValue
280
- : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryYAxisLabelArray)
281
- .ticks(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
282
- ? secondaryCustomYaxisMaxValue
283
- : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryCustomTickValue ?? innerHeight / 30)
284
- .tickSize(formatOptions.plotArea.gridLinesVisibility
285
- ? formatOptions.plotArea.gridLinesHorizontal
286
- ? -innerWidth
287
- : 0
288
- : 0)
289
- .tickSizeOuter(0);
290
- }
291
- };
292
- const getXAxis = () => {
293
- xAxis = d3
294
- .axisBottom(xScale)
295
- .tickSize(formatOptions.plotArea.gridLinesVisibility
296
- ? formatOptions.plotArea.gridLinesVeritcal
297
- ? formatOptions.plotArea.gridLinesVeritcal
298
- ? -(dataTableHeight > 0
299
- ? innerHeight - dataTableHeight
300
- : innerHeight)
301
- : formatOptions.plotArea.ticksHeight *
302
- ((dataTableHeight > 0
303
- ? innerHeight - dataTableHeight
304
- : innerHeight) /
305
- 100) *
306
- (formatOptions.xAxisLabel.xAxisPosition == 1 ? 1 : -1)
307
- : 0
308
- : 0)
309
- .tickSizeOuter(0)
310
- .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
311
- };
312
- const getChartType = (lineData) => {
313
- lineData.forEach((lData) => {
314
- lData.data.forEach((cData) => {
315
- cData.hideZero = lData.properties.hideZeroValues;
316
- cData.axis = lData.properties.axis;
317
- });
318
- });
319
- const lineGenerator = d3
320
- .line()
321
- .x((d) => xScale(d.dimension)
322
- ? xScale(d.dimension)
323
- : null)
324
- .y((d) => d.axis == "Primary"
325
- ? yScaleLeft(d.value)
326
- : yScaleRight(d.value))
327
- .defined((d) => (d.hideZero ? Boolean(d.value) : true))
328
- .curve(getCurveType(formatOptions));
329
- // Bind dummy data to ensure a single group is created
330
- let lines = gTag.selectAll(".parentGroup").data([lineData]);
331
- lines = lines
332
- .enter()
333
- .append("g")
334
- .attr("class", "lines parentGroup")
335
- .merge(lines);
336
- // JOIN: one group per line
337
- let lineGroups = lines.selectAll(".line-group").data((d) => d);
338
- // ENTER: create group for each new line
339
- let lineGroupsEnter = lineGroups
340
- .enter()
341
- .append("g")
342
- .attr("class", "line-group");
343
- // Append path to new groups
344
- lineGroupsEnter
345
- .attr("hoverId", (d) => d.legend.replace(/ /g, "-"))
346
- .append("path")
347
- .attr("class", "line")
348
- .attr("fill", "none");
349
- // ENTER + UPDATE
350
- lineGroupsEnter
351
- .merge(lineGroups)
352
- .select("path")
353
- .attr("d", (d) => lineGenerator(d.data))
354
- .attr("stroke", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
355
- .attr("stroke-dasharray", (d) => {
356
- switch (d.properties.lineStyle) {
357
- case staticLineStyle.dotted:
358
- return "0,3";
359
- case staticLineStyle.dashed:
360
- return "20,10,5,5,5,10";
361
- default:
362
- return "";
363
- }
364
- })
365
- .attr("stroke-linecap", (d) => d.properties.lineStyle === staticLineStyle.dotted ? "round" : "")
366
- .attr("stroke-width", (d) => d.properties.lineStyle !== "None" ? d.properties.lineWidth : "0");
367
- // EXIT: remove old groups
368
- lineGroups.exit().remove();
369
- //Markers
370
- lineMarkers(lines, lineData, "None", xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue);
371
- };
372
- const setSVGContainer = (margin) => {
373
- innerWidth = width - margin.left - margin.right;
374
- innerHeight = height - margin.bottom - margin.top;
375
- };
376
- const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
377
- // if (formatOptions.scrollChart.scrollX) {
378
- if (false) {
379
- // Scrollbar parameters
380
- const scrollMax = seriesData[0].data.length - visibleBars;
381
- // Scrollbar track & handle
382
- const scrollbarY = height - 20;
383
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
384
- getXScale();
385
- filteredData = JSON.parse(JSON.stringify(seriesData));
386
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
387
- getXAxis();
388
- svg
389
- .append("rect")
390
- .attr("x", margin.left)
391
- .attr("y", scrollbarY)
392
- .attr("width", innerWidth)
393
- .attr("height", 8)
394
- .attr("fill", "#ddd")
395
- .attr("rx", 4);
396
- const handleWidth = (innerWidth * visibleBars) / seriesData.length;
397
- const handle = svg
398
- .append("rect")
399
- .attr("x", margin.left)
400
- .attr("y", scrollbarY)
401
- .attr("width", handleWidth)
402
- .attr("height", 8)
403
- .attr("fill", "#999")
404
- .attr("rx", 4)
405
- .style("cursor", "ew-resize")
406
- .call(d3.drag().on("drag", (event) => {
407
- let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
408
- handle.attr("x", x);
409
- scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
410
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
411
- getXScale();
412
- filteredData = JSON.parse(JSON.stringify(seriesData));
413
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
414
- getXAxis();
415
- drawLineChart();
416
- }));
417
- svg.on("wheel", (event) => {
418
- event.preventDefault();
419
- const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
420
- ? event.deltaX
421
- : event.deltaY;
422
- scrollPosition += scrollDelta > 0 ? 1 : -1;
423
- scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
424
- const x = margin.left +
425
- ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
426
- handle.attr("x", x);
427
- getXScale();
428
- filteredData = JSON.parse(JSON.stringify(seriesData));
429
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
430
- getXAxis();
431
- drawLineChart();
432
- });
433
- }
434
- drawLineChart();
435
- };
436
- const drawLineChart = () => {
437
- // filteredData.forEach((data) => getChartType([data]));
438
- getChartType(filteredData);
439
- initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
440
- lineAnnotations(seriesData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
441
- margin, d3Annotation, [], //this.labelExcludeList,
442
- [], //this.individualLabelColor,
443
- [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
444
- formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg);
445
- let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn).labelArray;
446
- // adding series labels ( appending legends at the end of line : by default) in plot area
447
- drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
448
- };
449
- return (_jsxs("div", { children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, width: width, height: height })] }));
450
- };
451
- export default ColumnChart;