pace-chart-lib 0.0.12 → 1.0.1

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 (44) hide show
  1. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +9 -11
  2. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +6 -9
  3. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +7 -10
  4. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +4 -4
  5. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +12 -17
  6. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +2 -4
  7. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +9 -11
  8. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +8 -7
  9. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +11 -13
  10. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +11 -13
  11. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +7 -10
  12. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +7 -10
  13. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +9 -11
  14. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +11 -13
  15. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +11 -13
  16. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +6 -7
  17. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +3 -3
  18. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +9 -11
  19. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +7 -10
  20. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +7 -10
  21. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +10 -12
  22. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +19 -22
  23. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +4 -3
  24. package/dist/components/Charts/Core/Common.types.d.ts +3 -3
  25. package/dist/components/Charts/Core/CommonFunctions.js +3 -1
  26. package/package.json +27 -11
  27. package/dist/Components1/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
  28. package/dist/Components1/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
  29. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +0 -46
  30. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -2285
  31. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -169
  32. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -47
  33. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -4
  34. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -403
  35. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  36. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -0
  37. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  38. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  39. package/dist/Components1/Charts/Core/Common.type.d.ts +0 -8
  40. package/dist/Components1/Charts/Core/Common.type.js +0 -9
  41. package/dist/Components1/Charts/Core/CommonFunctions.d.ts +0 -12
  42. package/dist/Components1/Charts/Core/CommonFunctions.js +0 -512
  43. package/dist/Components1/Charts/Core/DefaultProperties.d.ts +0 -586
  44. package/dist/Components1/Charts/Core/DefaultProperties.js +0 -585
@@ -1,169 +0,0 @@
1
- import { TDefaultChartFormatOptionsType } from "../Core/DefaultProperties";
2
- export type TMargin = {
3
- top: number;
4
- left: number;
5
- right: number;
6
- bottom: number;
7
- };
8
- export declare enum actualChartTypes {
9
- waterfall = "Waterfall",
10
- lineWithMarker = "LineWithMarker",
11
- stackLine = "StackLine",
12
- stackLine100 = "100StackLine",
13
- line = "Line",
14
- bar = "Bar",
15
- stackColumn = "StackColumn",
16
- area = "Area",
17
- pie = "Pie",
18
- sankey = "Sankey",
19
- sunburst = "Sunburst",
20
- horizontalBar = "HorizontalBar",
21
- stackArea = "StackArea",
22
- stackArea100 = "100StackArea",
23
- treeMap = "TreeMap",
24
- stackBar = "StackBar",
25
- stackColumn100 = "100StackColumn",
26
- stackBar100 = "100StackBar",
27
- scatterPlot = "ScatterPlot",
28
- customColumnChart = "CustomColumnChart",
29
- customBarChart = "CustomBarChart",
30
- histogram = "Histogram",
31
- columnHistogram = "ColumnHistogram",
32
- barHistogram = "BarHistogram",
33
- column = "Column",
34
- miscellaneous = "Miscellaneous",
35
- custom = "Custom",
36
- collapsableTree = "CollapsableTree",
37
- maps = "Maps",
38
- tornadoChart = "Tornado",
39
- pieOfPie = "PieOfPie",
40
- wordCloud = "WordCloud",
41
- boxPlot = "BoxPlot",
42
- bubblePlot = "BubblePlot",
43
- vennDiagramChart = "VennDiagramChart",
44
- speedometerChart = "SpeedometerChart",
45
- layeredColumnChart = "LayeredColumnChart",
46
- layeredBarChart = "LayeredBarChart",
47
- organizationalChart = "OrganizationalChart",
48
- pyramidChart = "PyramidChart",
49
- scaleBreakStackedColumnChart = "ScaleBreakStackedColumnChart",
50
- progressChart = "ProgressChart",
51
- radialBarChart = "RadialBarChart"
52
- }
53
- export type TSeries = {
54
- legend: string;
55
- data: TDataPoint[];
56
- properties: ILineData;
57
- };
58
- export type TDataPoint = {
59
- dimension: string;
60
- value: number;
61
- legend: string;
62
- };
63
- export type TLineChartProps = {
64
- title?: string;
65
- width?: number;
66
- height?: number;
67
- data: TSeries[];
68
- chartId: string;
69
- formatOptions: TDefaultChartFormatOptionsType;
70
- dataType: string;
71
- };
72
- export type TChartJSON = {
73
- dimensionList: string[];
74
- chartData: any[];
75
- formatOptions: TDefaultChartFormatOptionsType;
76
- chartType: string;
77
- legendList: string[];
78
- secondaryAxisDrawn: boolean;
79
- yMaxLeft: number;
80
- yMaxRight: number;
81
- yMinLeft: number;
82
- yMinRight: number;
83
- hideZeroValues: boolean;
84
- customYaxisMaxValue?: number;
85
- customYaxisMinValue?: number;
86
- secondaryCustomYaxisMaxValue?: number;
87
- secondaryCustomYaxisMinValue?: number;
88
- formattedDimensionListMap: Map<string, any>;
89
- };
90
- export interface IXaxisObject {
91
- name: INameObject;
92
- title: {
93
- name: INameObject;
94
- };
95
- counter: number;
96
- dataType: string;
97
- dataSourceId: string;
98
- groupBy?: string;
99
- }
100
- export interface INameObject {
101
- actualName: string;
102
- dataSourceId?: string;
103
- name: string;
104
- type: string;
105
- }
106
- export interface ILineData {
107
- annotation?: number;
108
- axis?: string;
109
- color?: string;
110
- legend?: string;
111
- lineStyle?: string;
112
- type?: string;
113
- dimensions?: string[];
114
- hideZeroValues?: boolean;
115
- legendUniqueId?: string;
116
- lineWidth?: number;
117
- markerColor?: string;
118
- markerShape?: string;
119
- markerSize?: number;
120
- maximumMeasure?: number;
121
- measures?: number[];
122
- minimumMeasure?: number;
123
- seriesLabelVisibility?: boolean;
124
- xAxisObject?: IXaxisObject;
125
- fontStyle?: string[];
126
- borderColor?: string;
127
- disableConnector?: boolean;
128
- disableLineStyle?: boolean;
129
- actualChartType?: string;
130
- endColor?: string;
131
- stackBorderColor?: string;
132
- valueFontColor?: string;
133
- disableAnnotationPosition?: string;
134
- name?: string;
135
- startColor?: string;
136
- disableAnnotation?: boolean;
137
- labelFontSize?: number;
138
- labelColor?: string;
139
- borderStyle?: string;
140
- nodeWidth?: number;
141
- measureUniqueId?: string;
142
- stackBorderWidth?: number;
143
- dataLabelPosition?: number;
144
- disableMarkerShape?: boolean;
145
- disableMarkerColor?: boolean;
146
- borderRadius?: number;
147
- fontSize?: number;
148
- valueFont?: string;
149
- setColorScale?: boolean;
150
- connector?: number;
151
- areaBorderColor?: string;
152
- labelFontStyle?: string[];
153
- borderWidth?: number;
154
- secondaryAxisBgColor?: string;
155
- opacity?: number;
156
- fontFamily?: string;
157
- backgroundColor?: string;
158
- valueFontStyle?: string[];
159
- valueFontSize?: number;
160
- labelFontColor?: string;
161
- nodeHeight?: number;
162
- disableDataLabelPosition?: boolean;
163
- disableMarkerSize?: boolean;
164
- annotationPosition?: number;
165
- alias?: string;
166
- stackBorderStyle?: number;
167
- labelFont?: string;
168
- individualAnnotationVisibility?: number;
169
- }
@@ -1,47 +0,0 @@
1
- export var actualChartTypes;
2
- (function (actualChartTypes) {
3
- actualChartTypes["waterfall"] = "Waterfall";
4
- actualChartTypes["lineWithMarker"] = "LineWithMarker";
5
- actualChartTypes["stackLine"] = "StackLine";
6
- actualChartTypes["stackLine100"] = "100StackLine";
7
- actualChartTypes["line"] = "Line";
8
- actualChartTypes["bar"] = "Bar";
9
- actualChartTypes["stackColumn"] = "StackColumn";
10
- actualChartTypes["area"] = "Area";
11
- actualChartTypes["pie"] = "Pie";
12
- actualChartTypes["sankey"] = "Sankey";
13
- actualChartTypes["sunburst"] = "Sunburst";
14
- actualChartTypes["horizontalBar"] = "HorizontalBar";
15
- actualChartTypes["stackArea"] = "StackArea";
16
- actualChartTypes["stackArea100"] = "100StackArea";
17
- actualChartTypes["treeMap"] = "TreeMap";
18
- actualChartTypes["stackBar"] = "StackBar";
19
- actualChartTypes["stackColumn100"] = "100StackColumn";
20
- actualChartTypes["stackBar100"] = "100StackBar";
21
- actualChartTypes["scatterPlot"] = "ScatterPlot";
22
- actualChartTypes["customColumnChart"] = "CustomColumnChart";
23
- actualChartTypes["customBarChart"] = "CustomBarChart";
24
- actualChartTypes["histogram"] = "Histogram";
25
- actualChartTypes["columnHistogram"] = "ColumnHistogram";
26
- actualChartTypes["barHistogram"] = "BarHistogram";
27
- actualChartTypes["column"] = "Column";
28
- actualChartTypes["miscellaneous"] = "Miscellaneous";
29
- actualChartTypes["custom"] = "Custom";
30
- actualChartTypes["collapsableTree"] = "CollapsableTree";
31
- actualChartTypes["maps"] = "Maps";
32
- actualChartTypes["tornadoChart"] = "Tornado";
33
- actualChartTypes["pieOfPie"] = "PieOfPie";
34
- actualChartTypes["wordCloud"] = "WordCloud";
35
- actualChartTypes["boxPlot"] = "BoxPlot";
36
- actualChartTypes["bubblePlot"] = "BubblePlot";
37
- actualChartTypes["vennDiagramChart"] = "VennDiagramChart";
38
- actualChartTypes["speedometerChart"] = "SpeedometerChart";
39
- actualChartTypes["layeredColumnChart"] = "LayeredColumnChart";
40
- actualChartTypes["layeredBarChart"] = "LayeredBarChart";
41
- actualChartTypes["organizationalChart"] = "OrganizationalChart";
42
- actualChartTypes["pyramidChart"] = "PyramidChart";
43
- actualChartTypes["scaleBreakStackedColumnChart"] = "ScaleBreakStackedColumnChart";
44
- actualChartTypes["progressChart"] = "ProgressChart";
45
- actualChartTypes["radialBarChart"] = "RadialBarChart";
46
- })(actualChartTypes || (actualChartTypes = {}));
47
- ;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import type { TLineChartProps } from "../ChartsWithAxisTypes.type";
3
- declare const LineChart: React.FC<TLineChartProps>;
4
- export default LineChart;
@@ -1,403 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- //#region Imports
3
- import { useEffect, useRef } from "react";
4
- import * as d3 from "d3";
5
- import * as d3Annotation from "d3-svg-annotation";
6
- import { marginCalculation, initSvg, customYscaleLabelFormatting, InitChartArea, initBlackBox, calculateWidthHeightDynamically, isVerticallyOverlapping, getNumberWithFormat, responsiveYaxisLabel, initYaxis, responsiveXaxisLabel, initXaxis, setDateFormats, drawSeriesLabels, setXaxistitle, Yaxistitle, setChartTitle, initSvgBox, lineAnnotations, } from "../ChartsWithAxisFunctions";
7
- import { legendsWithScroll } from "../core/CommonFunctions";
8
- import { legendShape } from "../core/Json.type";
9
- const LineChart = ({ title, width, height, data, dataType, chartId, formatOptions, }) => {
10
- const chartType = "Line";
11
- const svgRef = useRef();
12
- const seriesData = data;
13
- const barChart = false;
14
- const chartsWithXScrollFlag = true;
15
- const chartsWithYScrollFlag = false;
16
- let chartJSON = {
17
- dimensionList: [],
18
- chartType: chartType,
19
- chartData: [],
20
- formatOptions: formatOptions,
21
- legendList: [],
22
- secondaryAxisDrawn: false,
23
- yMaxLeft: 0,
24
- yMaxRight: 0,
25
- yMinLeft: 0,
26
- yMinRight: 0,
27
- hideZeroValues: false,
28
- customYaxisMaxValue: parseFloat(formatOptions.yAxisLabel.yAxisMinText),
29
- customYaxisMinValue: parseFloat(formatOptions.yAxisLabel.yAxisAutoText),
30
- formattedDimensionListMap: new Map(),
31
- };
32
- const widgetId = chartId
33
- ? "scaling-svg-" + chartId
34
- : "scaling-svg-" + crypto.randomUUID();
35
- //#region UseEffect
36
- useEffect(() => {
37
- createLineChart();
38
- }, []);
39
- //#endregion
40
- const createLineChart = () => {
41
- preprocessChartData();
42
- // this.customYaxisLabelFormatting(this.primaryAxisScaleValues[0], this.primaryAxisScaleValues[1], this.secondaryAxisScaleValues[0], this.secondaryAxisScaleValues[1]);
43
- const { maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight);
44
- const { Margin, Ylabel, Xlabel, Ytitle, Xtitle, dimensionHeightWidthArray, staticSvgInnerWidth, chartTitleHeight, legendMargin, } = marginCalculation(width, height, maxNumberForPrimaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList); //{ top: 20, right: 30, bottom: 30, left: 40 };
45
- const innerWidth = width - Margin.left - Margin.right;
46
- const innerHeight = height - Margin.top - Margin.bottom;
47
- // initSvgContainer(); // to be added later
48
- // dataTablePreCalculation(); // to be added later
49
- const dataTableHeight = 0;
50
- const barWidth = 0;
51
- let svg = initSvg(svgRef.current, width, height); //d3.select(svgRef.current, width, height);
52
- let gTag = InitChartArea(svg, Margin);
53
- // const floattingGTag = InitChartFloatingArea(formatOptions, margin, floatingSvg, gTag, chartsWithXScrollFlag, chartsWithYScrollFlag); // to be added later
54
- initBlackBox(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
55
- const { YscaleLeft, Xscale, seriesLabels } = initScale(dataTableHeight, innerWidth, innerHeight);
56
- // this.setDataLabels(); // no need of this function as we have drag/drop/delete option on every data label
57
- const { YaxisLeft, Xaxis } = initAxis(Xscale, YscaleLeft, dataTableHeight, innerHeight, innerWidth);
58
- gTag = initYaxis(gTag, formatOptions, dataTableHeight, Ylabel, YaxisLeft, innerHeight);
59
- // initYaxisRight(); // will create after secondary axis
60
- let floatingTagG = gTag; // for now lets assume
61
- gTag = initXaxis(formatOptions.plotArea.fitChart ? gTag : floatingTagG, chartJSON, Xlabel, formatOptions, seriesData[0].properties.xAxisObject, dataTableHeight, YscaleLeft, Xaxis, dimensionHeightWidthArray, height, barWidth, dataType, innerWidth, innerHeight);
62
- // initScrollingSvgClippath(formatOptions, Margin, width); // for charts with scroll // to be added later
63
- seriesData.forEach((data) => getChartType(data, gTag, Xscale, YscaleLeft));
64
- // setDataTable(); // data tables to be added later
65
- drawSeriesLabels(formatOptions, floatingTagG, seriesLabels);
66
- svg = setXaxistitle(formatOptions, barChart, svg, Margin, Xlabel, height, Xtitle, chartJSON.chartType, Ylabel, staticSvgInnerWidth, innerHeight);
67
- svg = Yaxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, Margin, Ytitle, Ylabel);
68
- // YaxistitleRight() // to be added later
69
- setChartTitle(svg, formatOptions, width, chartTitleHeight);
70
- drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin);
71
- // LabelPosition: d.properties.dataLabelPosition,
72
- // Labelcolor: d.properties.LabelColor,
73
- // Axis: d.properties.Axis,
74
- // all above properties to be embeded in seriesData[i].properties : Pending
75
- lineAnnotations(seriesData, Xscale, YscaleLeft, YscaleLeft, // need to pass secondary axis scale if secondary axis is drawn
76
- Margin, d3Annotation, [], //this.labelExcludeList,
77
- [], //this.individualLabelColor,
78
- [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
79
- formatOptions, chartType);
80
- svg = initSvgBox(svg, formatOptions, widgetId, chartsWithXScrollFlag, chartsWithYScrollFlag);
81
- // clear previous chart
82
- // svg.selectAll("*").remove();
83
- // const color = d3
84
- // .scaleOrdinal(d3.schemeCategory10)
85
- // .domain(seriesData.map((s) => s.legend));
86
- // // X Axis
87
- // const g = svg
88
- // .append("g")
89
- // .attr("transform", `translate(${Margin.left},${Margin.top})`);
90
- // // Y Axis
91
- // g.append("g").call(d3.axisLeft(yScale));
92
- // g.append("g")
93
- // .attr("transform", `translate(0,${innerHeight})`)
94
- // .call(d3.axisBottom(xScale));
95
- };
96
- const preprocessChartData = () => {
97
- chartJSON.chartData = seriesData.flatMap((s) => s.data); // Flattening the data from all series
98
- chartJSON.dimensionList = Array.from(new Set(chartJSON.chartData.map((data) => data.dimension))); // getting unique x values as dimension list
99
- chartJSON.yMaxLeft = d3.max(chartJSON.chartData, (data) => data.value); // max value from chart Data
100
- chartJSON.yMinLeft = d3.min(chartJSON.chartData, (data) => data.value); // min value from chart Data
101
- chartJSON.legendList = seriesData.map((data) => data.legend); // getting legend list from series data
102
- let xAxisObject = seriesData[0].properties.xAxisObject;
103
- let formatedDimesionList = (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
104
- dataType === "DATE"
105
- ? setDateFormats(xAxisObject.name.name, formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList, xAxisObject.name.dataSourceId).map((d) => d[0])
106
- : chartJSON.dimensionList;
107
- chartJSON.dimensionList.forEach((d, i) => {
108
- chartJSON.formattedDimensionListMap.set(d, formatedDimesionList[i]);
109
- });
110
- };
111
- const initScale = (dataTableHeight, innerWidth, innerHeight) => {
112
- let isPrimaryAxisDrawn = true;
113
- let isSecondaryAxisDrawn = false;
114
- let YscaleLeft;
115
- if (isPrimaryAxisDrawn) {
116
- YscaleLeft = d3
117
- .scaleLinear()
118
- .domain([
119
- chartJSON.customYaxisMinValue !== undefined &&
120
- !Number.isNaN(chartJSON.customYaxisMinValue)
121
- ? chartJSON.customYaxisMinValue
122
- : chartJSON.yMinLeft < 0
123
- ? chartJSON.yMinLeft * 1.1
124
- : chartJSON.yMinLeft * 0.9,
125
- chartJSON.yMaxLeft <= 0
126
- ? 0
127
- : chartJSON.customYaxisMaxValue !== undefined &&
128
- !Number.isNaN(chartJSON.customYaxisMaxValue)
129
- ? chartJSON.customYaxisMaxValue
130
- : chartJSON.yMaxLeft * 1.1,
131
- ])
132
- .range([
133
- dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
134
- 0,
135
- ]);
136
- }
137
- // if (this.isSecondaryAxisDrawn) {
138
- // let YscaleRight = d3.scaleLinear()
139
- // .domain([
140
- // this.secondaryAxisScaleValues[0] >= 0
141
- // ? (this.secondaryCustomYaxisMinValue ||
142
- // this.secondaryCustomYaxisMinValue == 0) &&
143
- // !Number.isNaN(this.secondaryCustomYaxisMinValue)
144
- // ? this.secondaryCustomYaxisMinValue
145
- // : 0
146
- // : (this.secondaryCustomYaxisMinValue ||
147
- // this.secondaryCustomYaxisMinValue == 0) &&
148
- // !Number.isNaN(this.secondaryCustomYaxisMinValue)
149
- // ? this.secondaryCustomYaxisMinValue
150
- // : this.secondaryAxisScaleValues[0] * 1.1,
151
- // this.secondaryAxisScaleValues[1] <= 0
152
- // ? this.secondaryCustomYaxisMaxValue
153
- // ? this.secondaryCustomYaxisMaxValue
154
- // : 0
155
- // : this.secondaryCustomYaxisMaxValue
156
- // ? this.secondaryCustomYaxisMaxValue
157
- // : this.secondaryAxisScaleValues[1] * 1.1,
158
- // ])
159
- // .range([
160
- // this.dataTableHeight > 0
161
- // ? this.innerHeight - this.dataTableHeight
162
- // : this.innerHeight,
163
- // 0,
164
- // ]);
165
- // }
166
- let calculatedRange = [0, innerWidth];
167
- let seriesLabelWidth = undefined;
168
- let seriesLabels = [];
169
- if (formatOptions.seriesLabel.seriesLabelVisibility) {
170
- let labelObj = prepareDataForSeriesLabel(innerWidth, YscaleLeft);
171
- seriesLabels = labelObj.labelArray;
172
- formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
173
- (seriesLabelWidth = labelObj.heightWidth[0]);
174
- formatOptions.seriesLabel.seriesLabelPosition == "Right"
175
- ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
176
- : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
177
- }
178
- let Xscale = d3
179
- .scalePoint()
180
- .domain(chartJSON.dimensionList)
181
- .range(calculatedRange)
182
- .padding(0.5);
183
- return {
184
- YscaleLeft,
185
- Xscale,
186
- seriesLabels,
187
- };
188
- };
189
- const initAxis = (Xscale, YscaleLeft, dataTableHeight, innerHeight, innerWidth) => {
190
- let customTickValue;
191
- let seriesLabelWidth;
192
- let isPrimaryAxisDrawn = true;
193
- let Xaxis = d3
194
- .axisBottom(Xscale)
195
- .tickSize(formatOptions.plotArea.gridLinesVisibility
196
- ? formatOptions.plotArea.gridLinesVeritcal
197
- ? formatOptions.plotArea.gridLinesVeritcal
198
- ? -(dataTableHeight > 0
199
- ? innerHeight - dataTableHeight
200
- : innerHeight)
201
- : formatOptions.plotArea.ticksHeight *
202
- ((dataTableHeight > 0
203
- ? innerHeight - dataTableHeight
204
- : innerHeight) /
205
- 100) *
206
- (formatOptions.xAxisLabel.xAxisPosition == 1 ? 1 : -1)
207
- : 0
208
- : 0)
209
- .tickSizeOuter(0)
210
- .tickValues(responsiveXaxisLabel(chartJSON.dimensionList, innerWidth));
211
- let YaxisLeft;
212
- if (isPrimaryAxisDrawn) {
213
- YaxisLeft = d3
214
- .axisLeft(YscaleLeft)
215
- .tickFormat(getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
216
- .tickSize(formatOptions.plotArea.gridLinesVisibility
217
- ? formatOptions.plotArea.gridLinesHorizontal
218
- ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
219
- : 0
220
- : 0)
221
- .tickValues(responsiveYaxisLabel(chartJSON.customYaxisMaxValue
222
- ? chartJSON.customYaxisMaxValue
223
- : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerWidth, innerHeight, formatOptions, chartJSON))
224
- .ticks(customTickValue
225
- ? customTickValue
226
- : dataTableHeight > 0
227
- ? (innerHeight - dataTableHeight) / 30
228
- : innerHeight / 30)
229
- .tickSizeOuter(0);
230
- }
231
- // if (this.isSecondaryAxisDrawn) {
232
- // this.YaxisRight = axisRight(this.YscaleRight)
233
- // .tickFormat(
234
- // this.NumberFormat3ForSecondaryAxes(
235
- // formatOptions.SecondaryYAxisLabel.SecondaryYAxisDisplayUnits,
236
- // formatOptions.SecondaryYAxisLabel.SecondaryYAxisNumberFormat,
237
- // formatOptions.SecondaryYAxisLabel.SecondaryYAxisLabelDecimalPrecision
238
- // )
239
- // )
240
- // .tickValues(this.responsiveSecondaryYaxisLabel(this.secondaryCustomYaxisMaxValue ? this.secondaryCustomYaxisMaxValue : this.secondaryAxisScaleValues[1], this.secondaryAxisScaleValues[0]))
241
- // .ticks(this.secondaryCustomTickValue ? this.secondaryCustomTickValue : this.innerHeight / 30)
242
- // .tickSize( formatOptions.plotArea.gridLinesVisibility
243
- // ? formatOptions.plotArea.GridLinesHorizontal
244
- // ? -this.innerWidth
245
- // : 0
246
- // : 0
247
- // )
248
- // .tickSizeOuter(0)
249
- // this.initYaxisRight();
250
- // }
251
- return {
252
- YaxisLeft,
253
- Xaxis,
254
- };
255
- };
256
- const prepareDataForSeriesLabel = (innerWidth, YscaleLeft) => {
257
- // try {
258
- let isSecondaryAxisDrawn = false;
259
- let seriesApplied = formatOptions.seriesLabel.seriesLabelApplySeries;
260
- let seriesPosition = formatOptions.seriesLabel.seriesLabelPosition;
261
- let seriesLabelData = [];
262
- //finding longest legend
263
- let longestLegend = seriesData[0].legend;
264
- //calculate node height and width dynamically
265
- let hwObject = calculateWidthHeightDynamically(longestLegend, formatOptions.seriesLabel.seriesLabelFontSize, formatOptions.seriesLabel.seriesLabelFontFamily);
266
- seriesData.forEach((lineData) => {
267
- let isVisible = false;
268
- seriesApplied == 1
269
- ? (isVisible = true)
270
- : (isVisible = lineData.properties.seriesLabelVisibility);
271
- if (isVisible) {
272
- let seriesObject = {};
273
- //Checking for position
274
- let measureObject = seriesPosition == "Right"
275
- ? lineData.data[lineData.data.length - 1]
276
- : lineData.data[0];
277
- if (lineData.properties.axis == "Primary") {
278
- seriesObject["yPosition"] =
279
- YscaleLeft(measureObject.value) - hwObject[1] / 2;
280
- }
281
- // else {
282
- // seriesObject["yPosition"] =
283
- // this.YscaleRight(measureObject.value) - hwObject[1] / 2;
284
- // }
285
- seriesObject["isVisible"] = isVisible;
286
- seriesObject["seriesValue"] = lineData.legend;
287
- seriesObject["height"] = hwObject[1];
288
- seriesObject["width"] = hwObject[0];
289
- let isCollidingWithPrevious = false;
290
- if (seriesLabelData.length > 0) {
291
- seriesLabelData.some((previousData) => {
292
- if (!isCollidingWithPrevious) {
293
- isCollidingWithPrevious = isVerticallyOverlapping(previousData, seriesObject);
294
- }
295
- });
296
- }
297
- isVisible &&
298
- !isCollidingWithPrevious &&
299
- seriesLabelData.push(seriesObject);
300
- }
301
- else {
302
- return;
303
- }
304
- });
305
- longestLegend = "";
306
- seriesLabelData.forEach((seriesData) => {
307
- if (seriesData.seriesValue.length > longestLegend.length) {
308
- longestLegend = seriesData.seriesValue;
309
- }
310
- });
311
- hwObject = calculateWidthHeightDynamically(longestLegend, formatOptions.seriesLabel.seriesLabelFontSize, formatOptions.seriesLabel.seriesLabelFontFamily);
312
- hwObject[0] = hwObject[0] + 20;
313
- seriesLabelData.forEach((seriesData) => {
314
- seriesData["height"] = hwObject[1];
315
- seriesData["width"] = hwObject[0];
316
- seriesData["xPosition"] =
317
- seriesPosition == "Right"
318
- ? innerWidth + (isSecondaryAxisDrawn ? 10 : 0) - hwObject[0] - 10
319
- : 5;
320
- });
321
- return { labelArray: seriesLabelData, heightWidth: hwObject };
322
- // } catch (error) {
323
- // this.loggerService.logError(error, {
324
- // componentName: this.constructor.name,
325
- // functionName: "prepareDataForSeriesLabel",
326
- // });
327
- };
328
- const getChartType = (lineData, gTag, xScale, yScale) => {
329
- const lineGenerator = d3
330
- .line()
331
- .x((d) => xScale(d.dimension)
332
- ? xScale(d.dimension)
333
- : null)
334
- .y((d) => lineData.properties.axis == "Primary"
335
- ? yScale(d.value)
336
- : yScale(d.value));
337
- // .defined((d) => (this.HideZeroValues || d.hideZero ? d.value : true))
338
- // .curve(this.getCurveType());
339
- const lines = gTag
340
- .append("g")
341
- .attr("class", "lines")
342
- .attr("class", "parentGroup");
343
- //Lines
344
- lines
345
- .append("g")
346
- .selectAll("#scaling-svg" + widgetId + " .line-group")
347
- .data([lineData])
348
- .enter()
349
- .append("g")
350
- // .attr("hoverId", (d,index) => d.Legend.replace(/ /g, "-"))
351
- .append("path")
352
- .attr("class", "line")
353
- .attr("d", (d, i) => lineGenerator(d.data))
354
- .attr("stroke", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
355
- .attr("stroke-dasharray", (d) => d.properties.lineStyle === "Dotted"
356
- ? "0,3"
357
- : d.properties.lineStyle === "Dashed"
358
- ? "20,10,5,5,5,10"
359
- : "")
360
- .attr("stroke-linecap", (d) => d.properties.lineStyle === "Dotted" ? "round" : "")
361
- .attr("fill", "none")
362
- .attr("stroke-width", (d) => d.properties.lineStyle !== "None" ? d.properties.linewidth : "0");
363
- // .attr("clip-path", `url(#${this.uniqueID})`);
364
- };
365
- const drawLegends = (height, svg, maxLegendDimensions, chartTitleHeight, width, legendMargin) => {
366
- try {
367
- // to set default values for newly added legend props for old saved reports.
368
- // let alignment = formatOptions.Legends.LegendAlignment === undefined ? formatOptions.Legends.LegendAlignment = "Top" : null;
369
- // formatOptions.Legends.LegendAlignmentTopBottom === undefined ? formatOptions.Legends.LegendAlignmentTopBottom = "Start" : null;
370
- // let position = formatOptions.Legends.LegendPosition;
371
- let position = formatOptions.legends.legendPosition;
372
- let horizontalLegendAlignment = formatOptions.legends.legendAlignmentTopBottom;
373
- let verticalLegendAlignment = formatOptions.legends.legendAlignment;
374
- switch (position) {
375
- case "None":
376
- break;
377
- case "Right":
378
- let heightRight = !formatOptions.plotArea.fitChart
379
- ? height - chartTitleHeight - 20
380
- : height - chartTitleHeight - 10;
381
- legendsWithScroll(svg, seriesData, width - maxLegendDimensions[0] - 30, chartTitleHeight + 5, legendMargin + 25, heightRight, position, verticalLegendAlignment, legendShape.line, formatOptions, widgetId);
382
- break;
383
- case "Top":
384
- legendsWithScroll(svg, seriesData, 7, chartTitleHeight + 5, width - 10, 30, position, horizontalLegendAlignment, legendShape.line, formatOptions, widgetId);
385
- break;
386
- case "Left":
387
- let heightLeft = !formatOptions.plotArea.fitChart
388
- ? height - chartTitleHeight - 20
389
- : height - chartTitleHeight - 10;
390
- legendsWithScroll(svg, seriesData, 7, chartTitleHeight + 5, legendMargin + 25, heightLeft, position, verticalLegendAlignment, legendShape.line, formatOptions, widgetId);
391
- break;
392
- case "Bottom":
393
- legendsWithScroll(svg, seriesData, 7, height - 25, width - 10, 30, position, horizontalLegendAlignment, legendShape.line, formatOptions, widgetId);
394
- break;
395
- }
396
- }
397
- catch (error) {
398
- console.log(error);
399
- }
400
- };
401
- return (_jsxs("div", { children: [_jsx("h3", { children: title || "Line Chart" }), _jsx("div", { style: { width, height, border: "1px solid #ccc", padding: "10px" }, children: _jsx("svg", { ref: svgRef, id: widgetId, width: width, height: height }) })] }));
402
- };
403
- export default LineChart;
@@ -1,8 +0,0 @@
1
- export declare enum legendShape {
2
- rectangle = "rectangle",
3
- circle = "circle",
4
- hollowCircle = "hollowCircle",
5
- areaWithLine = "areaWithLine",
6
- line = "line",
7
- custom = "custom"
8
- }
@@ -1,9 +0,0 @@
1
- export var legendShape;
2
- (function (legendShape) {
3
- legendShape["rectangle"] = "rectangle";
4
- legendShape["circle"] = "circle";
5
- legendShape["hollowCircle"] = "hollowCircle";
6
- legendShape["areaWithLine"] = "areaWithLine";
7
- legendShape["line"] = "line";
8
- legendShape["custom"] = "custom";
9
- })(legendShape || (legendShape = {}));
@@ -1,12 +0,0 @@
1
- import { TSeries } from "../ChartsWithAxis/ChartsWithAxisTypes.type";
2
- import { TDefaultChartFormatOptionsType } from "./DefaultProperties";
3
- export declare function getRandomColor(): {
4
- color: string;
5
- };
6
- export declare function getCircleShape(d: any, innerDiv: any): void;
7
- export declare function getHollowCircleShape(d: any, innerDiv: any): void;
8
- export declare function getLineShape(d: any, innerDiv: any, formatOptions: TDefaultChartFormatOptionsType): void;
9
- export declare function getAreaShape(d: any, innerDiv: any, formatOptions: any): void;
10
- export declare function getReactShape(d: any, innerDiv: any): void;
11
- export declare const legendsWithScroll: (svg: any, seriesData: TSeries[], x: number, y: number, width: number, height: number, legendPosition: string, alignment: string, shape: string, chartFormatOptions: TDefaultChartFormatOptionsType, chartId: string) => void;
12
- export declare function calculateMaxLegendWidth(list: any, formatOptions: any): number[];