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.
- package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
- package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
- package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
- package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/pace-chart-lib.es.js +54619 -0
- package/dist/pace-chart-lib.umd.js +54622 -0
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
- package/dist/Services/ErrorLog.js +0 -3
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
- package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
- package/dist/components/Charts/Core/Common.type.d.ts +0 -0
- package/dist/components/Charts/Core/Common.type.js +0 -0
- package/dist/components/Charts/Core/Common.types.js +0 -133
- package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
- package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
- package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
- package/dist/components/Charts/Core/DefaultProperties.js +0 -0
- package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
- package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
- package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
- package/dist/index.js +0 -40
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
- /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
- /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
- /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
|
@@ -1,418 +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 { useEffect, useRef } from "react";
|
|
5
|
-
import { logError } from "../../../../Services/ErrorLog";
|
|
6
|
-
import { responsiveXaxisLabelForNumericValue } from "../../ChartsWithoutAxis/ChartsWithoutAxisFunctions";
|
|
7
|
-
import { staticLegendShape } from "../../Core/Common.types";
|
|
8
|
-
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
9
|
-
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, responsiveYaxisLabel, setChartTitle, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
|
|
10
|
-
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
11
|
-
const ColumnHistogramChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
|
-
// adding variables as per requirement
|
|
13
|
-
const chartId = crypto.randomUUID();
|
|
14
|
-
const columnWidth = 0; // coz line chartO
|
|
15
|
-
const chartType = actualChartTypes.columnHistogram;
|
|
16
|
-
const svgRef = useRef();
|
|
17
|
-
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
18
|
-
const dimensionList = data.DimensionList;
|
|
19
|
-
const barChart = false;
|
|
20
|
-
const isSecondaryAxisDrawn = false;
|
|
21
|
-
const isNormalizedChart = false;
|
|
22
|
-
let isPrimaryAxisDrawn = true;
|
|
23
|
-
let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
|
|
24
|
-
let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
|
|
25
|
-
let customXaxisMinValue = parseFloat(formatOptions.xAxisLabel.xAxisMinText);
|
|
26
|
-
let customXaxisMaxValue = parseFloat(formatOptions.xAxisLabel.xAxisMaxText);
|
|
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 thresholds;
|
|
44
|
-
let periods = [];
|
|
45
|
-
let bins = [];
|
|
46
|
-
let width;
|
|
47
|
-
let height;
|
|
48
|
-
let dataTable;
|
|
49
|
-
let dataTableHeight;
|
|
50
|
-
let svg;
|
|
51
|
-
let gTag;
|
|
52
|
-
let yScaleLeft;
|
|
53
|
-
let yScaleRight;
|
|
54
|
-
let xScale;
|
|
55
|
-
let xScaleForLegends;
|
|
56
|
-
let seriesLabels;
|
|
57
|
-
let calculatedRange;
|
|
58
|
-
let seriesLabelWidth;
|
|
59
|
-
let yAxisLeft;
|
|
60
|
-
let xAxis;
|
|
61
|
-
let yAxisRight;
|
|
62
|
-
let filteredDimension;
|
|
63
|
-
let filteredData = [];
|
|
64
|
-
let scrollPosition = 0;
|
|
65
|
-
const visibleBars = 2;
|
|
66
|
-
let chartJSON = {
|
|
67
|
-
dimensionList: dimensionList,
|
|
68
|
-
chartType: chartType,
|
|
69
|
-
chartData: [],
|
|
70
|
-
formatOptions: formatOptions,
|
|
71
|
-
legendList: [],
|
|
72
|
-
secondaryAxisDrawn: false,
|
|
73
|
-
yMaxLeft: 0,
|
|
74
|
-
yMaxRight: 0,
|
|
75
|
-
yMinLeft: 0,
|
|
76
|
-
yMinRight: 0,
|
|
77
|
-
hideZeroValues: false,
|
|
78
|
-
formattedDimensionListMap: new Map(),
|
|
79
|
-
};
|
|
80
|
-
//#region UseEffect
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
try {
|
|
83
|
-
createColumnChart();
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
logError("Columnchart", "createColumnChart", error);
|
|
87
|
-
}
|
|
88
|
-
}, [formatOptions]);
|
|
89
|
-
//#endregion
|
|
90
|
-
const createColumnChart = () => {
|
|
91
|
-
({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
|
|
92
|
-
preProcessChartData(); // preaparing data related to chart creation
|
|
93
|
-
// Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
|
|
94
|
-
({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } =
|
|
95
|
-
customYscaleLabelFormatting(
|
|
96
|
-
// for calculating primary/secondary axis max number so that we can calculate margin accordinglt
|
|
97
|
-
formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
|
|
98
|
-
({
|
|
99
|
-
margin,
|
|
100
|
-
yLabel,
|
|
101
|
-
xLabel,
|
|
102
|
-
yTitle,
|
|
103
|
-
xTitle,
|
|
104
|
-
dimensionHeightWidthArray,
|
|
105
|
-
chartTitleHeight,
|
|
106
|
-
secondaryAxisTitleWidth,
|
|
107
|
-
legendMargin,
|
|
108
|
-
secondaryYLabel,
|
|
109
|
-
} = marginCalculation(
|
|
110
|
-
// for all margin related calculations
|
|
111
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
112
|
-
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
113
|
-
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
114
|
-
// calculations for data tables
|
|
115
|
-
formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
|
|
116
|
-
initSvg(
|
|
117
|
-
// for svg creation
|
|
118
|
-
svg, width, height, formatOptions);
|
|
119
|
-
gTag = initChartArea(svg, margin); // creating chart area
|
|
120
|
-
initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
|
|
121
|
-
binsCalculation();
|
|
122
|
-
initScale();
|
|
123
|
-
initAxis();
|
|
124
|
-
initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
|
|
125
|
-
horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
|
|
126
|
-
if (formatOptions.dataTableProperties &&
|
|
127
|
-
formatOptions.dataTableProperties.dataTable) {
|
|
128
|
-
if (formatOptions.xAxisLabel.xAxisPosition != "1")
|
|
129
|
-
formatOptions.xAxisLabel.xAxisLabelVisibility = false;
|
|
130
|
-
addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, columnWidth, yScaleLeft, xScale, xScaleForLegends, undefined, undefined, dataTableHeight, chartType, formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
|
|
131
|
-
}
|
|
132
|
-
setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
|
|
133
|
-
yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
|
|
134
|
-
yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
|
|
135
|
-
setChartTitle(svg, formatOptions, width, chartTitleHeight);
|
|
136
|
-
drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, staticLegendShape.rectangle);
|
|
137
|
-
};
|
|
138
|
-
const preProcessChartData = () => {
|
|
139
|
-
const allChartData = [];
|
|
140
|
-
const legendList = [];
|
|
141
|
-
let formatedDimensionList = [];
|
|
142
|
-
let cumulativeDataPoints = [];
|
|
143
|
-
let yMaxLeft = -Infinity;
|
|
144
|
-
let yMinLeft = Infinity;
|
|
145
|
-
seriesData.forEach((series) => {
|
|
146
|
-
legendList.push(series.legend);
|
|
147
|
-
series.data.forEach((point) => {
|
|
148
|
-
allChartData.push(point);
|
|
149
|
-
yMaxLeft = Math.max(yMaxLeft, point.value);
|
|
150
|
-
yMinLeft = Math.min(yMinLeft, point.value);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
chartJSON.chartData = allChartData;
|
|
154
|
-
chartJSON.legendList = legendList;
|
|
155
|
-
chartJSON.yMaxLeft = yMaxLeft;
|
|
156
|
-
chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
|
|
157
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
158
|
-
filteredData.forEach((d) => d.data.forEach((j) => cumulativeDataPoints.push(j.value)));
|
|
159
|
-
let yMin = (customYaxisMinValue || customYaxisMinValue == 0) ? customYaxisMinValue : 0;
|
|
160
|
-
let yMax = (customYaxisMaxValue || customYaxisMaxValue == 0) ? customYaxisMaxValue : filteredData[0]?.data?.length;
|
|
161
|
-
chartJSON.yMaxLeft = parseFloat(((yMin + "").length > (yMax + "").length) ? (yMin + "") : (yMax + ""));
|
|
162
|
-
chartJSON.xMax = d3.max(cumulativeDataPoints);
|
|
163
|
-
chartJSON.xMin = d3.min(cumulativeDataPoints);
|
|
164
|
-
};
|
|
165
|
-
const binsCalculation = () => {
|
|
166
|
-
switch (formatOptions.bins.binsCalculation) {
|
|
167
|
-
case "Automatic":
|
|
168
|
-
thresholds = innerWidth / 50;
|
|
169
|
-
break;
|
|
170
|
-
case "Number of Bins":
|
|
171
|
-
calculatingPeriodsWithBins(false);
|
|
172
|
-
break;
|
|
173
|
-
case "Bin Width":
|
|
174
|
-
calculatingPeriodsWithBins(true);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
const calculatingPeriodsWithBins = (isWithWidth) => {
|
|
178
|
-
let sortedArray = [];
|
|
179
|
-
filteredData.forEach((d) => (sortedArray = d.data.sort(function (a, b) {
|
|
180
|
-
return a.value - b.value;
|
|
181
|
-
})));
|
|
182
|
-
let range = chartJSON.xMax - chartJSON.xMin;
|
|
183
|
-
let tempPeriod;
|
|
184
|
-
if (isWithWidth) {
|
|
185
|
-
parseFloat(formatOptions.bins.binsCalculationValue) <= 2 && (formatOptions.bins.binsCalculationValue = "3");
|
|
186
|
-
tempPeriod = range / parseFloat(formatOptions.bins.binsCalculationValue);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
parseFloat(formatOptions.bins.binsCalculationValue) <= 1 && (formatOptions.bins.binsCalculationValue = "1"); //minimum bins 1
|
|
190
|
-
tempPeriod = range / parseFloat(formatOptions.bins.binsCalculationValue);
|
|
191
|
-
}
|
|
192
|
-
let currentElement = chartJSON.xMin;
|
|
193
|
-
if (isWithWidth) {
|
|
194
|
-
periods = [currentElement];
|
|
195
|
-
while (currentElement < chartJSON.xMax) {
|
|
196
|
-
currentElement += tempPeriod;
|
|
197
|
-
periods.push(currentElement);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
periods = [currentElement];
|
|
202
|
-
while (Math.round(currentElement) < Math.round(chartJSON.xMax)) {
|
|
203
|
-
currentElement += tempPeriod;
|
|
204
|
-
periods.push(Math.round(currentElement));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
const initScale = () => {
|
|
209
|
-
xScale = d3
|
|
210
|
-
.scaleLinear()
|
|
211
|
-
.domain([chartJSON.xMin, chartJSON.xMax])
|
|
212
|
-
.range([0, innerWidth]);
|
|
213
|
-
let histogram = d3
|
|
214
|
-
.bin()
|
|
215
|
-
.value((d) => d) // how to extract value from data
|
|
216
|
-
.domain(xScale.domain())
|
|
217
|
-
.thresholds((periods && periods.length) || xScale.ticks(thresholds)); // the numbers of bins
|
|
218
|
-
filteredData.forEach((d) => {
|
|
219
|
-
let tempArray = histogram(d.data.map(val => val.value));
|
|
220
|
-
bins.push(tempArray);
|
|
221
|
-
});
|
|
222
|
-
filteredData.forEach((d, i) => bins[i].forEach((j) => {
|
|
223
|
-
j["name"] = d.properties["legend"];
|
|
224
|
-
j["color"] = d.properties["color"];
|
|
225
|
-
j["opacity"] = d.properties["opacity"];
|
|
226
|
-
})); // Adding additional information from the main data.
|
|
227
|
-
let cumulativeLength = [];
|
|
228
|
-
bins.forEach((d) => d.forEach((j) => cumulativeLength.push(j.length)));
|
|
229
|
-
chartJSON.yMaxLeft = d3.max(cumulativeLength);
|
|
230
|
-
chartJSON.yMinLeft = d3.min(cumulativeLength);
|
|
231
|
-
// rounding the ymin & ymax
|
|
232
|
-
yScaleLeft = d3
|
|
233
|
-
.scaleLinear()
|
|
234
|
-
.range([innerHeight, 0])
|
|
235
|
-
// .domain([0, this.Ymax + 0.2 * this.Ymax])
|
|
236
|
-
.domain([(customYaxisMinValue || customYaxisMinValue == 0) ? customYaxisMinValue : 0, (customYaxisMaxValue || customYaxisMaxValue == 0) ? customYaxisMaxValue : chartJSON.yMaxLeft + 0.2 * chartJSON.yMaxLeft]);
|
|
237
|
-
};
|
|
238
|
-
const initAxis = () => {
|
|
239
|
-
getXAxis();
|
|
240
|
-
if (isPrimaryAxisDrawn) {
|
|
241
|
-
yAxisLeft = d3
|
|
242
|
-
.axisLeft(yScaleLeft)
|
|
243
|
-
.tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
|
|
244
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
245
|
-
? formatOptions.plotArea.gridLinesHorizontal
|
|
246
|
-
? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
|
|
247
|
-
: 0
|
|
248
|
-
: 0)
|
|
249
|
-
.tickValues(responsiveYaxisLabel(chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, false, innerWidth).yAxisLabelArray)
|
|
250
|
-
.ticks(innerHeight / 50)
|
|
251
|
-
.tickSizeOuter(0);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
const getXAxis = () => {
|
|
255
|
-
let xaxisLabelPosition = parseInt(formatOptions.xAxisLabel.xAxisPosition);
|
|
256
|
-
let labelArray = responsiveXaxisLabelForNumericValue(chartJSON.xMax, chartJSON.xMin, innerWidth, formatOptions, customXaxisMinValue, customXaxisMaxValue, innerHeight, false).xAxisLabelArray;
|
|
257
|
-
labelArray.shift();
|
|
258
|
-
xAxis =
|
|
259
|
-
(xaxisLabelPosition == 1 ?
|
|
260
|
-
d3.axisTop(xScale) : d3.axisBottom(xScale))
|
|
261
|
-
.tickFormat((d) => getNumberWithFormat(d, formatOptions.xAxisLabel.xAxisDisplayUnits, formatOptions.xAxisLabel.xAxisNumberFormat, formatOptions.xAxisLabel.xAxisLabelDecimalPrecision, false))
|
|
262
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
263
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
264
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
265
|
-
? -(dataTableHeight > 0
|
|
266
|
-
? innerHeight - dataTableHeight
|
|
267
|
-
: innerHeight)
|
|
268
|
-
: parseFloat(formatOptions.plotArea.ticksHeight) *
|
|
269
|
-
((dataTableHeight > 0
|
|
270
|
-
? innerHeight - dataTableHeight
|
|
271
|
-
: innerHeight) /
|
|
272
|
-
100) *
|
|
273
|
-
(formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
|
|
274
|
-
: 0
|
|
275
|
-
: 0)
|
|
276
|
-
.tickValues(labelArray)
|
|
277
|
-
.ticks(innerWidth / 30)
|
|
278
|
-
.tickSizeOuter(0);
|
|
279
|
-
formatOptions.bins.binsCalculation === "Automatic"
|
|
280
|
-
? xAxis.ticks(thresholds)
|
|
281
|
-
: xAxis.tickValues(periods).ticks(innerWidth / 50);
|
|
282
|
-
};
|
|
283
|
-
const getChartType = (lineData) => {
|
|
284
|
-
gTag
|
|
285
|
-
.append("g")
|
|
286
|
-
.attr("class", "parentGroup")
|
|
287
|
-
.selectAll("#scaling-svg" + chartId + " .rect")
|
|
288
|
-
.data(bins)
|
|
289
|
-
.enter()
|
|
290
|
-
.append("g")
|
|
291
|
-
.selectAll("rect")
|
|
292
|
-
.data((d) => d)
|
|
293
|
-
.enter()
|
|
294
|
-
.append("rect")
|
|
295
|
-
.attr("class", "rect")
|
|
296
|
-
.attr("stroke", formatOptions.bins.binsBorderVisibility && formatOptions.bins.binsBorderColor)
|
|
297
|
-
.attr("stroke-width", formatOptions.bins.binsBorderVisibility && formatOptions.bins.binsBorderThickness)
|
|
298
|
-
.attr("stroke-opacity", formatOptions.bins.binsBorderVisibility && formatOptions.bins.binsBorderOpacity)
|
|
299
|
-
.attr("x", 1)
|
|
300
|
-
.attr("transform", function (d) {
|
|
301
|
-
return ("translate(" + xScale(d.x0) + "," + (yScaleLeft(d.length) > 0 ? yScaleLeft(d.length) : 0) + ")");
|
|
302
|
-
})
|
|
303
|
-
.attr("width", function (d) {
|
|
304
|
-
return xScale(d.x1) - xScale(d.x0) - parseFloat(formatOptions.bins.binsGapWidth) < 0
|
|
305
|
-
? 0
|
|
306
|
-
: xScale(d.x1) - xScale(d.x0) - parseFloat(formatOptions.bins.binsGapWidth);
|
|
307
|
-
})
|
|
308
|
-
.attr("height", function (d) {
|
|
309
|
-
return innerHeight - yScaleLeft(d.length);
|
|
310
|
-
})
|
|
311
|
-
.style("fill", (d) => d.color !== "#ffffff" ? d.color : "none")
|
|
312
|
-
.style("opacity", formatOptions.bins.binsFillOpacity)
|
|
313
|
-
.style("shape-rendering", "crispEdges")
|
|
314
|
-
.on("mousemove", (event, d) => {
|
|
315
|
-
showTooltipOnMouseMove([
|
|
316
|
-
{
|
|
317
|
-
key: formatOptions.xAxisTitle.xAxisTitleText.includes("~$~")
|
|
318
|
-
? formatOptions.xAxisTitle.xAxisTitleText.split("~$~")[1]
|
|
319
|
-
: formatOptions.xAxisTitle.xAxisTitleText,
|
|
320
|
-
value: `${d["x0"]}-${d["x1"]}`
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
key: formatOptions.yAxisTitle.yAxisTitleText,
|
|
324
|
-
value: getNumberWithFormat(formatOptions.toolTip.toolTipNumberFormat == ",.0%" ? Math.abs(d.length / filteredData[0].data.length) : d.length, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision, false),
|
|
325
|
-
},
|
|
326
|
-
], formatOptions, event);
|
|
327
|
-
})
|
|
328
|
-
.on("mouseout", hideTooltipOnMouseOut);
|
|
329
|
-
};
|
|
330
|
-
const setSVGContainer = (margin) => {
|
|
331
|
-
innerWidth = width - margin.left - margin.right;
|
|
332
|
-
innerHeight = height - margin.bottom - margin.top;
|
|
333
|
-
};
|
|
334
|
-
const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
|
|
335
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
336
|
-
// Scrollbar parameters
|
|
337
|
-
const scrollMax = seriesData[0].data.length - visibleBars;
|
|
338
|
-
// Scrollbar track & handle
|
|
339
|
-
const scrollbarY = height - 20;
|
|
340
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
341
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
342
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
343
|
-
getXAxis();
|
|
344
|
-
svg
|
|
345
|
-
.append("rect")
|
|
346
|
-
.attr("x", margin.left)
|
|
347
|
-
.attr("y", scrollbarY)
|
|
348
|
-
.attr("width", innerWidth)
|
|
349
|
-
.attr("height", 8)
|
|
350
|
-
.attr("fill", "#ddd")
|
|
351
|
-
.attr("rx", 4);
|
|
352
|
-
const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
|
|
353
|
-
const handle = svg
|
|
354
|
-
.append("rect")
|
|
355
|
-
.attr("x", margin.left)
|
|
356
|
-
.attr("y", scrollbarY)
|
|
357
|
-
.attr("width", handleWidth)
|
|
358
|
-
.attr("height", 8)
|
|
359
|
-
.attr("fill", "#999")
|
|
360
|
-
.attr("rx", 4)
|
|
361
|
-
.style("cursor", "ew-resize")
|
|
362
|
-
.call(d3.drag().on("drag", (event) => {
|
|
363
|
-
let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
|
|
364
|
-
handle.attr("x", x);
|
|
365
|
-
scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
|
|
366
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
367
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
368
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
369
|
-
getXAxis();
|
|
370
|
-
drawColumnChart();
|
|
371
|
-
}));
|
|
372
|
-
svg.on("wheel", (event) => {
|
|
373
|
-
event.preventDefault();
|
|
374
|
-
const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
|
|
375
|
-
? event.deltaX
|
|
376
|
-
: event.deltaY;
|
|
377
|
-
scrollPosition += scrollDelta > 0 ? 1 : -1;
|
|
378
|
-
scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
|
|
379
|
-
const x = margin.left +
|
|
380
|
-
((innerWidth - handleWidth) * scrollPosition) / scrollMax;
|
|
381
|
-
handle.attr("x", x);
|
|
382
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
383
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
384
|
-
getXAxis();
|
|
385
|
-
drawColumnChart();
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
drawColumnChart();
|
|
389
|
-
};
|
|
390
|
-
const drawColumnChart = () => {
|
|
391
|
-
getChartType(filteredData);
|
|
392
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
393
|
-
// commonAnnotations(
|
|
394
|
-
// seriesData,
|
|
395
|
-
// xScale,
|
|
396
|
-
// yScaleLeft,
|
|
397
|
-
// yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
398
|
-
// margin,
|
|
399
|
-
// d3Annotation,
|
|
400
|
-
// [], //this.labelExcludeList,
|
|
401
|
-
// [], //this.individualLabelColor,
|
|
402
|
-
// [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
|
|
403
|
-
// formatOptions,
|
|
404
|
-
// chartType,
|
|
405
|
-
// height,
|
|
406
|
-
// width,
|
|
407
|
-
// innerWidth,
|
|
408
|
-
// filteredDimension,
|
|
409
|
-
// innerHeight,
|
|
410
|
-
// chartId,
|
|
411
|
-
// svg,
|
|
412
|
-
// xScaleForLegends,
|
|
413
|
-
// columnWidth
|
|
414
|
-
// );
|
|
415
|
-
};
|
|
416
|
-
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%" } })] }));
|
|
417
|
-
};
|
|
418
|
-
export default ColumnHistogramChart;
|