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,491 +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 { legendShape } from "../../Core/Common.types";
8
- import { legendsWithScroll, 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 LineChart = ({ 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
- setDataTable(gTag, dataTable, barWidth, yScaleLeft, xScale, dataTableHeight, yLabel, yTitle, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, svg, innerWidth, innerHeight); // data tables to be added later
116
- setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
117
- yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
118
- yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
119
- setChartTitle(svg, formatOptions, width, chartTitleHeight);
120
- drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin);
121
- };
122
- const preProcessChartData = () => {
123
- const allChartData = [];
124
- const legendList = [];
125
- const dimensionSet = new Set();
126
- let formatedDimesionList = [];
127
- let yMaxLeft = -Infinity;
128
- let yMinLeft = Infinity;
129
- let yMaxRight = -Infinity;
130
- let yMinRight = Infinity;
131
- seriesData.forEach((series) => {
132
- legendList.push(series.legend);
133
- series.data.forEach((point) => {
134
- allChartData.push(point);
135
- dimensionSet.add(point.dimension);
136
- if (series.properties.axis === "Secondary") {
137
- isSecondaryAxisDrawn = true;
138
- yMaxRight = Math.max(yMaxRight, point.value);
139
- yMinRight = Math.min(yMinRight, point.value);
140
- }
141
- else {
142
- yMaxLeft = Math.max(yMaxLeft, point.value);
143
- yMinLeft = Math.min(yMinLeft, point.value);
144
- }
145
- });
146
- });
147
- chartJSON.chartData = allChartData;
148
- chartJSON.legendList = legendList;
149
- chartJSON.dimensionList = Array.from(dimensionSet);
150
- chartJSON.yMaxLeft = yMaxLeft;
151
- chartJSON.yMinLeft = yMinLeft;
152
- chartJSON.yMaxRight = yMaxRight;
153
- chartJSON.yMinRight = yMinRight;
154
- // Apply formatted dimensions
155
- let xAxisObject = xAxisObj[0];
156
- formatedDimesionList =
157
- (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
158
- xAxisObject.dataType === "DATE"
159
- ? setDateFormats(xAxisObject.name.name, formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList, xAxisObject.name.dataSourceId).map((d) => d[0])
160
- : chartJSON.dimensionList;
161
- chartJSON.dimensionList.forEach((dim, i) => {
162
- chartJSON.formattedDimensionListMap.set(dim, formatedDimesionList[i]);
163
- });
164
- filteredData = JSON.parse(JSON.stringify(seriesData));
165
- // if (formatOptions.scrollChart.scrollX) {
166
- if (false) {
167
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
168
- }
169
- else {
170
- filteredDimension = chartJSON.dimensionList;
171
- }
172
- if (formatOptions.plotArea.hideZeroValues) {
173
- chartJSON.hideZeroValues = true;
174
- }
175
- };
176
- const initScale = () => {
177
- // rounding the ymin & ymax
178
- let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
179
- chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
180
- chartJSON.yMinLeft = yAxisLabelArray[0];
181
- if (isPrimaryAxisDrawn) {
182
- yScaleLeft = d3
183
- .scaleLinear()
184
- .domain([
185
- customYaxisMinValue !== undefined &&
186
- !Number.isNaN(customYaxisMinValue)
187
- ? customYaxisMinValue
188
- : chartJSON.yMinLeft < 0
189
- ? chartJSON.yMinLeft * 1.1
190
- : chartJSON.yMinLeft * 0.9,
191
- chartJSON.yMaxLeft <= 0
192
- ? 0
193
- : customYaxisMaxValue !== undefined &&
194
- !Number.isNaN(customYaxisMaxValue)
195
- ? customYaxisMaxValue
196
- : chartJSON.yMaxLeft * 1.1,
197
- ])
198
- .range([
199
- dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
200
- 0,
201
- ]);
202
- }
203
- if (isSecondaryAxisDrawn) {
204
- yScaleRight = d3
205
- .scaleLinear()
206
- .domain([
207
- chartJSON.yMinRight >= 0
208
- ? (secondaryCustomYaxisMinValue ||
209
- secondaryCustomYaxisMinValue == 0) &&
210
- !Number.isNaN(secondaryCustomYaxisMinValue)
211
- ? secondaryCustomYaxisMinValue
212
- : 0
213
- : (secondaryCustomYaxisMinValue ||
214
- secondaryCustomYaxisMinValue == 0) &&
215
- !Number.isNaN(secondaryCustomYaxisMinValue)
216
- ? secondaryCustomYaxisMinValue
217
- : chartJSON.yMinRight * 1.1,
218
- chartJSON.yMaxRight <= 0
219
- ? secondaryCustomYaxisMaxValue
220
- ? secondaryCustomYaxisMaxValue
221
- : 0
222
- : secondaryCustomYaxisMaxValue
223
- ? secondaryCustomYaxisMaxValue
224
- : chartJSON.yMaxRight * 1.1,
225
- ])
226
- .range([
227
- dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
228
- 0,
229
- ]);
230
- }
231
- calculatedRange = [0, innerWidth];
232
- if (formatOptions.seriesLabel.seriesLabelVisibility) {
233
- let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn);
234
- seriesLabels = labelObj.labelArray;
235
- formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
236
- (seriesLabelWidth = labelObj.heightWidth[0]);
237
- formatOptions.seriesLabel.seriesLabelPosition == "Right"
238
- ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
239
- : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
240
- }
241
- getXScale();
242
- };
243
- const getXScale = () => {
244
- xScale = d3
245
- .scalePoint()
246
- .domain(filteredDimension)
247
- .range(calculatedRange)
248
- .padding(0.5);
249
- };
250
- const initAxis = () => {
251
- getXAxis();
252
- if (isPrimaryAxisDrawn) {
253
- yAxisLeft = d3
254
- .axisLeft(yScaleLeft)
255
- .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
256
- .tickSize(formatOptions.plotArea.gridLinesVisibility
257
- ? formatOptions.plotArea.gridLinesHorizontal
258
- ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
259
- : 0
260
- : 0)
261
- .tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
262
- .ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
263
- (dataTableHeight > 0
264
- ? (innerHeight - dataTableHeight) / 30
265
- : innerHeight / 30))
266
- .tickSizeOuter(0);
267
- }
268
- if (isSecondaryAxisDrawn) {
269
- yAxisRight = d3
270
- .axisRight(yScaleRight)
271
- .tickFormat((d) => getNumberWithFormat(d, formatOptions.secondaryYAxisLabel.secondaryYAxisDisplayUnits, formatOptions.secondaryYAxisLabel.secondaryYAxisNumberFormat, formatOptions.secondaryYAxisLabel
272
- .secondaryYAxisLabelDecimalPrecision))
273
- .tickValues(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
274
- ? secondaryCustomYaxisMaxValue
275
- : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryYAxisLabelArray)
276
- .ticks(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
277
- ? secondaryCustomYaxisMaxValue
278
- : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryCustomTickValue ?? innerHeight / 30)
279
- .tickSize(formatOptions.plotArea.gridLinesVisibility
280
- ? formatOptions.plotArea.gridLinesHorizontal
281
- ? -innerWidth
282
- : 0
283
- : 0)
284
- .tickSizeOuter(0);
285
- }
286
- };
287
- const getXAxis = () => {
288
- xAxis = d3
289
- .axisBottom(xScale)
290
- .tickSize(formatOptions.plotArea.gridLinesVisibility
291
- ? formatOptions.plotArea.gridLinesVeritcal
292
- ? formatOptions.plotArea.gridLinesVeritcal
293
- ? -(dataTableHeight > 0
294
- ? innerHeight - dataTableHeight
295
- : innerHeight)
296
- : formatOptions.plotArea.ticksHeight *
297
- ((dataTableHeight > 0
298
- ? innerHeight - dataTableHeight
299
- : innerHeight) /
300
- 100) *
301
- (formatOptions.xAxisLabel.xAxisPosition == 1 ? 1 : -1)
302
- : 0
303
- : 0)
304
- .tickSizeOuter(0)
305
- .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
306
- };
307
- const getChartType = (lineData) => {
308
- lineData.forEach((lData) => {
309
- lData.data.forEach((cData) => {
310
- cData.hideZero = lData.properties.hideZeroValues;
311
- cData.axis = lData.properties.axis;
312
- });
313
- });
314
- const lineGenerator = d3
315
- .line()
316
- .x((d) => xScale(d.dimension)
317
- ? xScale(d.dimension)
318
- : null)
319
- .y((d) => d.axis == "Primary"
320
- ? yScaleLeft(d.value)
321
- : yScaleRight(d.value))
322
- .defined((d) => (d.hideZero ? Boolean(d.value) : true))
323
- .curve(getCurveType(formatOptions));
324
- // Bind dummy data to ensure a single group is created
325
- let lines = gTag.selectAll(".parentGroup").data([lineData]);
326
- lines = lines
327
- .enter()
328
- .append("g")
329
- .attr("class", "lines parentGroup")
330
- .merge(lines);
331
- // JOIN: one group per line
332
- let lineGroups = lines.selectAll(".line-group").data((d) => d);
333
- // ENTER: create group for each new line
334
- let lineGroupsEnter = lineGroups
335
- .enter()
336
- .append("g")
337
- .attr("class", "line-group");
338
- // Append path to new groups
339
- lineGroupsEnter
340
- .attr("hoverId", (d) => d.legend.replace(/ /g, "-"))
341
- .append("path")
342
- .attr("class", "line")
343
- .attr("fill", "none");
344
- // ENTER + UPDATE
345
- lineGroupsEnter
346
- .merge(lineGroups)
347
- .select("path")
348
- .attr("d", (d) => lineGenerator(d.data))
349
- .attr("stroke", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
350
- .attr("stroke-dasharray", (d) => {
351
- switch (d.properties.lineStyle) {
352
- case "dotted":
353
- return "0,3";
354
- case "dashed":
355
- return "20,10,5,5,5,10";
356
- default:
357
- return "";
358
- }
359
- })
360
- .attr("stroke-linecap", (d) => d.properties.lineStyle === "dotted" ? "round" : "")
361
- .attr("stroke-width", (d) => d.properties.lineStyle !== "None" ? d.properties.lineWidth : "0");
362
- // EXIT: remove old groups
363
- lineGroups.exit().remove();
364
- //Markers
365
- lineMarkers(lines, lineData, "None", xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue);
366
- };
367
- const drawLegends = (height, svg, maxLegendDimensions, chartTitleHeight, width, legendMargin) => {
368
- try {
369
- let position = formatOptions.legends.legendPosition;
370
- let horizontalLegendAlignment = formatOptions.legends.legendAlignmentTopBottom;
371
- let verticalLegendAlignment = formatOptions.legends.legendAlignment;
372
- switch (position) {
373
- case "None":
374
- break;
375
- case "Right":
376
- let heightRight = !formatOptions.plotArea.fitChart
377
- ? height - chartTitleHeight - 20
378
- : height - chartTitleHeight - 10;
379
- legendsWithScroll(svg, seriesData, width - maxLegendDimensions[0] - 30, chartTitleHeight + 5, legendMargin + 25, heightRight, position, verticalLegendAlignment, legendShape.line, formatOptions, chartId);
380
- break;
381
- case "Top":
382
- legendsWithScroll(svg, seriesData, 7, chartTitleHeight + 5, width - 10, 30, position, horizontalLegendAlignment, legendShape.line, formatOptions, chartId);
383
- break;
384
- case "Left":
385
- let heightLeft = !formatOptions.plotArea.fitChart
386
- ? height - chartTitleHeight - 20
387
- : height - chartTitleHeight - 10;
388
- legendsWithScroll(svg, seriesData, 7, chartTitleHeight + 5, legendMargin + 25, heightLeft, position, verticalLegendAlignment, legendShape.line, formatOptions, chartId);
389
- break;
390
- case "Bottom":
391
- legendsWithScroll(svg, seriesData, 7, height - 25, width - 10, 30, position, horizontalLegendAlignment, legendShape.line, formatOptions, chartId);
392
- break;
393
- }
394
- }
395
- catch (error) {
396
- console.log(error);
397
- }
398
- };
399
- const setSVGContainer = (margin) => {
400
- innerWidth = width - margin.left - margin.right;
401
- innerHeight = height - margin.bottom - margin.top;
402
- };
403
- const setDataTable = (gTag, dataTable, barWidth, yScaleLeft, xScale, dataTableHeight, yLabel, yTitle, calculatedRange, formatedDimensionMap, chartId, margin, svg, innerWidth, innerHeight) => {
404
- try {
405
- if (formatOptions.dataTableProperties &&
406
- formatOptions.dataTableProperties.dataTable) {
407
- if (formatOptions.xAxisLabel.xAxisPosition != 1)
408
- formatOptions.xAxisLabel.xAxisLabelVisibility = false;
409
- addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, barWidth, yScaleLeft, xScale, undefined, undefined, undefined, dataTableHeight, "Line", formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, formatedDimensionMap, chartId, margin, innerHeight);
410
- }
411
- }
412
- catch (error) {
413
- // loggerService.logError(error,{componentName :constructor.name,functionName :"setDataTable"}); }
414
- }
415
- };
416
- const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
417
- // if (formatOptions.scrollChart.scrollX) {
418
- if (false) {
419
- // Scrollbar parameters
420
- const scrollMax = seriesData[0].data.length - visibleBars;
421
- // Scrollbar track & handle
422
- const scrollbarY = height - 20;
423
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
424
- getXScale();
425
- filteredData = JSON.parse(JSON.stringify(seriesData));
426
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
427
- getXAxis();
428
- svg
429
- .append("rect")
430
- .attr("x", margin.left)
431
- .attr("y", scrollbarY)
432
- .attr("width", innerWidth)
433
- .attr("height", 8)
434
- .attr("fill", "#ddd")
435
- .attr("rx", 4);
436
- const handleWidth = (innerWidth * visibleBars) / seriesData.length;
437
- const handle = svg
438
- .append("rect")
439
- .attr("x", margin.left)
440
- .attr("y", scrollbarY)
441
- .attr("width", handleWidth)
442
- .attr("height", 8)
443
- .attr("fill", "#999")
444
- .attr("rx", 4)
445
- .style("cursor", "ew-resize")
446
- .call(d3.drag().on("drag", (event) => {
447
- let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
448
- handle.attr("x", x);
449
- scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
450
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
451
- getXScale();
452
- filteredData = JSON.parse(JSON.stringify(seriesData));
453
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
454
- getXAxis();
455
- drawLineChart();
456
- }));
457
- svg.on("wheel", (event) => {
458
- event.preventDefault();
459
- const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
460
- ? event.deltaX
461
- : event.deltaY;
462
- scrollPosition += scrollDelta > 0 ? 1 : -1;
463
- scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
464
- const x = margin.left +
465
- ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
466
- handle.attr("x", x);
467
- getXScale();
468
- filteredData = JSON.parse(JSON.stringify(seriesData));
469
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
470
- getXAxis();
471
- drawLineChart();
472
- });
473
- }
474
- drawLineChart();
475
- };
476
- const drawLineChart = () => {
477
- // filteredData.forEach((data) => getChartType([data]));
478
- getChartType(filteredData);
479
- initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
480
- lineAnnotations(seriesData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
481
- margin, d3Annotation, [], //this.labelExcludeList,
482
- [], //this.individualLabelColor,
483
- [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
484
- formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg);
485
- let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn).labelArray;
486
- // adding series labels ( appending legends at the end of line : by default) in plot area
487
- drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
488
- };
489
- return (_jsxs("div", { children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, width: width, height: height })] }));
490
- };
491
- export default LineChart;