pace-chart-lib 1.0.2 → 1.0.3

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
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pace-chart-lib",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A simple React + Vite + TS UI library with a Button using custom fonts via SCSS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,3 +0,0 @@
1
- export function logError(fileName, funcName, msg) {
2
- console.error(fileName, funcName, msg);
3
- }
@@ -1,496 +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 { staticLegendShape } from "../../Core/Common.types";
8
- import { drawLegends, generalizedChartData, lineMarkers, onHoverMarkerForAreaChartFamily, } from "../../Core/CommonFunctions";
9
- import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getCurveType, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis,
10
- // initYaxisRight,
11
- commonAnnotations, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
12
- import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
13
- const AreaChart = ({ isDateType, formatOptions, data, }) => {
14
- // adding variables as per requirement
15
- const chartId = crypto.randomUUID();
16
- const barWidth = 0; // coz line chart
17
- const chartType = actualChartTypes.area;
18
- const svgRef = useRef();
19
- const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
20
- const dimensionList = data.DimensionList;
21
- const barChart = false;
22
- const isSecondaryAxisDrawn = false;
23
- const isNormalizedChart = false;
24
- let isPrimaryAxisDrawn = true;
25
- let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
26
- let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
27
- let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
28
- let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
29
- let margin;
30
- let yLabel;
31
- let xLabel;
32
- let yTitle;
33
- let xTitle;
34
- let dimensionHeightWidthArray;
35
- let chartTitleHeight;
36
- let secondaryAxisTitleWidth;
37
- let legendMargin;
38
- let secondaryYLabel;
39
- let maxNumberForPrimaryAxis;
40
- let maxNumberForSecondaryAxis;
41
- let innerWidth;
42
- let innerHeight;
43
- let width;
44
- let height;
45
- let dataTable;
46
- let dataTableHeight;
47
- let svg;
48
- let gTag;
49
- let yScaleLeft;
50
- // let yScaleRight: any;
51
- let xScale;
52
- let seriesLabels;
53
- let calculatedRange;
54
- let seriesLabelWidth;
55
- let yAxisLeft;
56
- let xAxis;
57
- let yAxisRight;
58
- let filteredDimension;
59
- let filteredData = [];
60
- let scrollPosition = 0;
61
- const visibleBars = 2;
62
- let chartJSON = {
63
- dimensionList: dimensionList,
64
- chartType: chartType,
65
- chartData: [],
66
- formatOptions: formatOptions,
67
- legendList: [],
68
- secondaryAxisDrawn: false,
69
- yMaxLeft: 0,
70
- yMaxRight: 0,
71
- yMinLeft: 0,
72
- yMinRight: 0,
73
- hideZeroValues: false,
74
- formattedDimensionListMap: new Map(),
75
- };
76
- //#region UseEffect
77
- useEffect(() => {
78
- try {
79
- createAreaChart();
80
- }
81
- catch (error) {
82
- logError("Linechart", "createLineChart", error);
83
- }
84
- }, [formatOptions]);
85
- //#endregion
86
- const createAreaChart = () => {
87
- ({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
88
- preProcessChartData(); // preaparing data related to chart creation
89
- // Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
90
- ({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } =
91
- customYscaleLabelFormatting(
92
- // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
93
- formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
94
- ({
95
- margin,
96
- yLabel,
97
- xLabel,
98
- yTitle,
99
- xTitle,
100
- dimensionHeightWidthArray,
101
- chartTitleHeight,
102
- secondaryAxisTitleWidth,
103
- legendMargin,
104
- secondaryYLabel,
105
- } = marginCalculation(
106
- // for all margin related calculations
107
- width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
108
- setSVGContainer(margin); // for innerWidth/height static width/height
109
- ({ dataTable, dataTableHeight } = dataTablePreCalculation(
110
- // calculations for data tables
111
- formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
112
- initSvg(
113
- // for svg creation
114
- svg, width, height, formatOptions);
115
- gTag = initChartArea(svg, margin); // creating chart area
116
- initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
117
- initScale();
118
- initAxis();
119
- initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
120
- // initYaxisRight(
121
- // gTag,
122
- // formatOptions,
123
- // dataTableHeight,
124
- // secondaryYLabel,
125
- // yAxisRight,
126
- // innerHeight,
127
- // innerWidth
128
- // );
129
- horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
130
- if (formatOptions.dataTableProperties &&
131
- formatOptions.dataTableProperties.dataTable) {
132
- if (formatOptions.xAxisLabel.xAxisPosition != "1")
133
- formatOptions.xAxisLabel.xAxisLabelVisibility = false;
134
- addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, barWidth, yScaleLeft, xScale, undefined, undefined, undefined, dataTableHeight, "Area", formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
135
- }
136
- setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
137
- yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
138
- yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
139
- setChartTitle(svg, formatOptions, width, chartTitleHeight);
140
- drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, staticLegendShape.areaWithLine);
141
- };
142
- const preProcessChartData = () => {
143
- const allChartData = [];
144
- const legendList = [];
145
- let formatedDimensionList = [];
146
- let yMaxLeft = -Infinity;
147
- let yMinLeft = Infinity;
148
- let yMaxRight = -Infinity;
149
- let yMinRight = Infinity;
150
- seriesData.forEach((series) => {
151
- legendList.push(series.legend);
152
- series.data.forEach((point) => {
153
- allChartData.push(point);
154
- if (isSecondaryAxisDrawn && series.properties.axis === "Secondary") {
155
- // isSecondaryAxisDrawn = true;
156
- yMaxRight = Math.max(yMaxRight, point.value);
157
- yMinRight = Math.min(yMinRight, point.value);
158
- }
159
- else {
160
- yMaxLeft = Math.max(yMaxLeft, point.value);
161
- yMinLeft = Math.min(yMinLeft, point.value);
162
- }
163
- });
164
- });
165
- chartJSON.chartData = allChartData;
166
- chartJSON.legendList = legendList;
167
- chartJSON.yMaxLeft = yMaxLeft;
168
- chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
169
- chartJSON.yMaxRight = yMaxRight;
170
- chartJSON.yMinRight = yMinRight;
171
- // Apply formatted dimensions
172
- formatedDimensionList = isDateType
173
- ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
174
- : chartJSON.dimensionList;
175
- chartJSON.dimensionList.forEach((dim, i) => {
176
- chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
177
- });
178
- filteredData = JSON.parse(JSON.stringify(seriesData));
179
- if (!formatOptions.plotArea.fitChart) {
180
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
181
- }
182
- else {
183
- filteredDimension = chartJSON.dimensionList;
184
- }
185
- if (formatOptions.plotArea.hideZeroValues) {
186
- chartJSON.hideZeroValues = true;
187
- }
188
- };
189
- const initScale = () => {
190
- // rounding the ymin & ymax
191
- let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
192
- chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
193
- chartJSON.yMinLeft = yAxisLabelArray[0];
194
- if (isPrimaryAxisDrawn) {
195
- yScaleLeft = d3
196
- .scaleLinear()
197
- .domain([
198
- chartJSON.yMinLeft >= 0 ?
199
- customYaxisMinValue !== undefined &&
200
- !Number.isNaN(customYaxisMinValue)
201
- ? customYaxisMinValue : 0
202
- : chartJSON.yMinLeft < 0
203
- ? chartJSON.yMinLeft * 1.1
204
- : chartJSON.yMinLeft * 0.9,
205
- chartJSON.yMaxLeft <= 0
206
- ? 0
207
- : customYaxisMaxValue !== undefined &&
208
- !Number.isNaN(customYaxisMaxValue)
209
- ? customYaxisMaxValue
210
- : chartJSON.yMaxLeft * 1.1,
211
- ])
212
- .range([
213
- dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
214
- 0,
215
- ]);
216
- }
217
- // if (isSecondaryAxisDrawn) {
218
- // yScaleRight = d3
219
- // .scaleLinear()
220
- // .domain([
221
- // chartJSON.yMinRight >= 0
222
- // ? (secondaryCustomYaxisMinValue ||
223
- // secondaryCustomYaxisMinValue == 0) &&
224
- // !Number.isNaN(secondaryCustomYaxisMinValue)
225
- // ? secondaryCustomYaxisMinValue
226
- // : 0
227
- // : (secondaryCustomYaxisMinValue ||
228
- // secondaryCustomYaxisMinValue == 0) &&
229
- // !Number.isNaN(secondaryCustomYaxisMinValue)
230
- // ? secondaryCustomYaxisMinValue
231
- // : chartJSON.yMinRight * 1.1,
232
- // chartJSON.yMaxRight <= 0
233
- // ? secondaryCustomYaxisMaxValue
234
- // ? secondaryCustomYaxisMaxValue
235
- // : 0
236
- // : secondaryCustomYaxisMaxValue
237
- // ? secondaryCustomYaxisMaxValue
238
- // : chartJSON.yMaxRight * 1.1,
239
- // ])
240
- // .range([
241
- // dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
242
- // 0,
243
- // ]);
244
- // }
245
- calculatedRange = [0, innerWidth];
246
- if (formatOptions.seriesLabel.seriesLabelVisibility) {
247
- let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn);
248
- seriesLabels = labelObj.labelArray;
249
- formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
250
- (seriesLabelWidth = labelObj.heightWidth[0]);
251
- formatOptions.seriesLabel.seriesLabelPosition == "Right"
252
- ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
253
- : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
254
- }
255
- getXScale();
256
- };
257
- const getXScale = () => {
258
- xScale = d3
259
- .scalePoint()
260
- .domain(filteredDimension)
261
- .range(calculatedRange)
262
- .padding(0);
263
- };
264
- const initAxis = () => {
265
- getXAxis();
266
- if (isPrimaryAxisDrawn) {
267
- yAxisLeft = d3
268
- .axisLeft(yScaleLeft)
269
- .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
270
- .tickSize(formatOptions.plotArea.gridLinesVisibility
271
- ? formatOptions.plotArea.gridLinesHorizontal
272
- ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
273
- : 0
274
- : 0)
275
- .tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
276
- .ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
277
- (dataTableHeight > 0
278
- ? (innerHeight - dataTableHeight) / 30
279
- : innerHeight / 30))
280
- .tickSizeOuter(0);
281
- }
282
- // if (isSecondaryAxisDrawn) {
283
- // yAxisRight = d3
284
- // .axisRight(yScaleRight)
285
- // .tickFormat((d: number) =>
286
- // getNumberWithFormat(
287
- // d,
288
- // formatOptions.secondaryYAxisLabel.secondaryYAxisDisplayUnits,
289
- // formatOptions.secondaryYAxisLabel.secondaryYAxisNumberFormat,
290
- // formatOptions.secondaryYAxisLabel
291
- // .secondaryYAxisLabelDecimalPrecision
292
- // )
293
- // )
294
- // .tickValues(
295
- // responsiveSecondaryYaxisLabel(
296
- // secondaryCustomYaxisMaxValue
297
- // ? secondaryCustomYaxisMaxValue
298
- // : chartJSON.yMaxRight,
299
- // chartJSON.yMinRight,
300
- // formatOptions,
301
- // chartJSON
302
- // ).secondaryYAxisLabelArray
303
- // )
304
- // .ticks(
305
- // responsiveSecondaryYaxisLabel(
306
- // secondaryCustomYaxisMaxValue
307
- // ? secondaryCustomYaxisMaxValue
308
- // : chartJSON.yMaxRight,
309
- // chartJSON.yMinRight,
310
- // formatOptions,
311
- // chartJSON
312
- // ).secondaryCustomTickValue ?? innerHeight / 30
313
- // )
314
- // .tickSize(
315
- // formatOptions.plotArea.gridLinesVisibility
316
- // ? formatOptions.plotArea.gridLinesHorizontal
317
- // ? -innerWidth
318
- // : 0
319
- // : 0
320
- // )
321
- // .tickSizeOuter(0);
322
- // }
323
- };
324
- const getXAxis = () => {
325
- xAxis = d3
326
- .axisBottom(xScale)
327
- .tickSize(formatOptions.plotArea.gridLinesVisibility
328
- ? formatOptions.plotArea.gridLinesVertical
329
- ? formatOptions.plotArea.gridLinesVertical
330
- ? -(dataTableHeight > 0
331
- ? innerHeight - dataTableHeight
332
- : innerHeight)
333
- : parseFloat(formatOptions.plotArea.ticksHeight) *
334
- ((dataTableHeight > 0
335
- ? innerHeight - dataTableHeight
336
- : innerHeight) /
337
- 100) *
338
- (formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
339
- : 0
340
- : 0)
341
- .tickSizeOuter(0)
342
- .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
343
- };
344
- const getChartType = (lineData) => {
345
- lineData.forEach((lData) => {
346
- lData.data.forEach((cData) => {
347
- cData.hideZero = lData.properties.hideZeroValues;
348
- cData.axis = lData.properties.axis;
349
- });
350
- });
351
- const areaGenerator = d3
352
- .area()
353
- .x((d) => xScale(d.dimension)
354
- ? xScale(d.dimension)
355
- : null)
356
- .y0((d) =>
357
- // d.axis == "Primary" ?
358
- yScaleLeft(0)
359
- // : yScaleRight(0)
360
- )
361
- .y1((d) =>
362
- // d.axis == "Primary" ?
363
- yScaleLeft(d.value)
364
- // : yScaleRight((d as TDataPoint).value)
365
- )
366
- .defined((d) => (d.hideZero ? Boolean(d.value) : true))
367
- .curve(getCurveType(formatOptions));
368
- // Bind dummy data to ensure a single group is created
369
- let areas = gTag.selectAll(".parentGroup").data([lineData]);
370
- let focus = gTag.append("g").attr("class", "focusClass");
371
- areas = areas
372
- .enter()
373
- .append("g")
374
- .attr("class", "areas parentGroup")
375
- .merge(areas);
376
- // JOIN: one group per line
377
- let areaGroups = areas.selectAll(".area-group").data((d) => d);
378
- // ENTER: create group for each new line
379
- let areaGroupsEnter = areaGroups
380
- .enter()
381
- .append("g")
382
- .attr("class", "area-group");
383
- // Append path to new groups
384
- areaGroupsEnter
385
- .attr("hoverId", (d) => d.legend.replace(/ /g, "-"))
386
- .append("path")
387
- .attr("class", "area")
388
- .attr("fill", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
389
- .style("fill-opacity", formatOptions.plotArea.fillOpacity);
390
- // ENTER + UPDATE
391
- areaGroupsEnter
392
- .merge(areaGroups)
393
- .select("path")
394
- .attr("d", (d) => areaGenerator(d.data))
395
- .attr("stroke", (d) => d.properties.areaBorderColor !== "#ffffff"
396
- ? d.properties.areaBorderColor
397
- : "none")
398
- .attr("stroke-dasharray", (d) => {
399
- switch (d.properties.lineStyle) {
400
- case "dotted":
401
- return "0,3";
402
- case "dashed":
403
- return "20,10,5,5,5,10";
404
- default:
405
- return "";
406
- }
407
- })
408
- .attr("stroke-linecap", (d) => d.properties.lineStyle === "dotted" ? "round" : "")
409
- .attr("stroke-width", (d) => d.properties.lineStyle !== "None" &&
410
- formatOptions.plotArea.plotAreaHideLineAndMarkers
411
- ? d.properties.lineWidth
412
- : "0");
413
- onHoverMarkerForAreaChartFamily(formatOptions, areas, focus, filteredDimension, lineData, xScale, yScaleLeft, chartType);
414
- // EXIT: remove old groups
415
- areaGroups.exit().remove();
416
- //Markers
417
- lineMarkers(areas, lineData, chartType, xScale, yScaleLeft, undefined, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue, false);
418
- };
419
- const setSVGContainer = (margin) => {
420
- innerWidth = width - margin.left - margin.right;
421
- innerHeight = height - margin.bottom - margin.top;
422
- };
423
- const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
424
- if (!formatOptions.plotArea.fitChart) {
425
- // Scrollbar parameters
426
- const scrollMax = seriesData[0].data.length - visibleBars;
427
- // Scrollbar track & handle
428
- const scrollbarY = height - 20;
429
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
430
- getXScale();
431
- filteredData = JSON.parse(JSON.stringify(seriesData));
432
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
433
- getXAxis();
434
- svg
435
- .append("rect")
436
- .attr("x", margin.left)
437
- .attr("y", scrollbarY)
438
- .attr("width", innerWidth)
439
- .attr("height", 8)
440
- .attr("fill", "#ddd")
441
- .attr("rx", 4);
442
- const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
443
- const handle = svg
444
- .append("rect")
445
- .attr("x", margin.left)
446
- .attr("y", scrollbarY)
447
- .attr("width", handleWidth)
448
- .attr("height", 8)
449
- .attr("fill", "#999")
450
- .attr("rx", 4)
451
- .style("cursor", "ew-resize")
452
- .call(d3.drag().on("drag", (event) => {
453
- let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
454
- handle.attr("x", x);
455
- scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
456
- filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
457
- getXScale();
458
- filteredData = JSON.parse(JSON.stringify(seriesData));
459
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
460
- getXAxis();
461
- drawAreaChart();
462
- }));
463
- svg.on("wheel", (event) => {
464
- event.preventDefault();
465
- const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
466
- ? event.deltaX
467
- : event.deltaY;
468
- scrollPosition += scrollDelta > 0 ? 1 : -1;
469
- scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
470
- const x = margin.left +
471
- ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
472
- handle.attr("x", x);
473
- getXScale();
474
- filteredData = JSON.parse(JSON.stringify(seriesData));
475
- filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
476
- getXAxis();
477
- drawAreaChart();
478
- });
479
- }
480
- drawAreaChart();
481
- };
482
- const drawAreaChart = () => {
483
- getChartType(filteredData);
484
- initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, isDateType, innerWidth, innerHeight, filteredDimension);
485
- commonAnnotations(seriesData, xScale, yScaleLeft, undefined, // need to pass secondary axis scale if secondary axis is drawn
486
- margin, d3Annotation, [], //this.labelExcludeList,
487
- [], //this.individualLabelColor,
488
- [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
489
- formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg);
490
- let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn).labelArray;
491
- // adding series labels ( appending legends at the end of line : by default) in plot area
492
- drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
493
- };
494
- return (_jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, style: { width: "100%", height: "100%" } })] }));
495
- };
496
- export default AreaChart;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import { type TLineChartProps } from "../ChartsWithAxisTypes.types";
3
- declare const LineChart: React.FC<TLineChartProps>;
4
- export default LineChart;