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
@@ -7,8 +7,9 @@ import { staticLegendShape } from "../../Core/Common.types";
7
7
  import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove } from "../../Core/CommonFunctions";
8
8
  import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, getStackedData, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
9
9
  import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
10
- const WaterfallChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
10
+ const WaterfallChart = ({ isDateType, formatOptions, data, }) => {
11
11
  // adding variables as per requirement
12
+ const chartId = crypto.randomUUID?.();
12
13
  let columnWidth = 0; // coz line chartO
13
14
  let colorScale;
14
15
  const chartType = actualChartTypes.waterfall;
@@ -103,7 +104,7 @@ const WaterfallChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
103
104
  secondaryYLabel,
104
105
  } = marginCalculation(
105
106
  // for all margin related calculations
106
- width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, xAxisObj[0]));
107
+ width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
107
108
  setSVGContainer(margin); // for innerWidth/height static width/height
108
109
  ({ dataTable, dataTableHeight } = dataTablePreCalculation(
109
110
  // calculations for data tables
@@ -140,7 +141,7 @@ const WaterfallChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
140
141
  };
141
142
  const preProcessChartData = () => {
142
143
  const allChartData = [];
143
- let formatedDimesionList = [];
144
+ let formatedDimensionList = [];
144
145
  seriesData.forEach((series) => {
145
146
  series.data.forEach((point) => {
146
147
  allChartData.push(point);
@@ -187,38 +188,34 @@ const WaterfallChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
187
188
  chartJSON.dimensionList = chartJSON.legendList;
188
189
  }
189
190
  // Apply formatted dimensions
190
- let xAxisObject = xAxisObj[0];
191
- formatedDimesionList =
192
- (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
193
- xAxisObject.dataType === "DATE"
194
- ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
195
- : chartJSON.dimensionList;
196
- getFormattedDimensionList(tempWaterfallChartData, xAxisObject);
191
+ formatedDimensionList = isDateType
192
+ ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
193
+ : chartJSON.dimensionList;
194
+ getFormattedDimensionList(tempWaterfallChartData);
197
195
  };
198
- const getFormattedDimensionList = (tempWaterfallChartData, xAxisObject) => {
196
+ const getFormattedDimensionList = (tempWaterfallChartData) => {
199
197
  try {
200
198
  let tempDimensionList = [];
201
199
  let tempDimensionListWithIndex = [];
202
- let tempFormatedDimesionList = [];
200
+ let tempformatedDimensionList = [];
203
201
  tempWaterfallChartData && tempWaterfallChartData.forEach((d, i) => {
204
202
  if (d.dimension) {
205
203
  tempDimensionList.push(d.dimension);
206
204
  tempDimensionListWithIndex.push({ dimension: d.dimension, chartDataIndex: i, selfIndex: tempDimensionListWithIndex.length });
207
205
  }
208
206
  });
209
- if ((xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
210
- xAxisObject.dataType === "DATE") {
211
- tempFormatedDimesionList = setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d);
207
+ if (isDateType) {
208
+ tempformatedDimensionList = setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d);
212
209
  }
213
210
  else {
214
- tempFormatedDimesionList = tempDimensionList;
211
+ tempformatedDimensionList = tempDimensionList;
215
212
  }
216
- let formatedDimesionList = JSON.parse(JSON.stringify(chartJSON.legendList));
213
+ let formatedDimensionList = JSON.parse(JSON.stringify(chartJSON.legendList));
217
214
  tempDimensionListWithIndex.forEach((listItem, i) => {
218
- formatedDimesionList[listItem.chartDataIndex] = tempFormatedDimesionList[listItem.selfIndex];
215
+ formatedDimensionList[listItem.chartDataIndex] = tempformatedDimensionList[listItem.selfIndex];
219
216
  });
220
217
  chartJSON.legendList.forEach((d, i) => {
221
- chartJSON.formattedDimensionListMap.set(d, formatedDimesionList[i]);
218
+ chartJSON.formattedDimensionListMap.set(d, formatedDimensionList[i]);
222
219
  });
223
220
  }
224
221
  catch (error) {
@@ -491,7 +488,7 @@ const WaterfallChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
491
488
  };
492
489
  const drawColumnChart = () => {
493
490
  getChartType(filteredData);
494
- initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, xAxisObj[0].dataType, innerWidth, innerHeight, chartJSON.legendList);
491
+ initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, chartJSON.legendList);
495
492
  // commonAnnotations(
496
493
  // seriesData,
497
494
  // xScale,
@@ -524,10 +521,10 @@ const WaterfallChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
524
521
  let tempWaterFallData = [];
525
522
  let dataRequiredForWaterfall = []; //JSON.parse(JSON.stringify(chartData));
526
523
  let dataRequiredForStackTotal = []; //JSON.parse(JSON.stringify(chartData));
527
- let seriesSlice = yAxisObj[0].legendData;
524
+ let seriesSlice = "";
528
525
  if (seriesSlice.length > 1) {
529
526
  // seriesSlice.forEach(key => {
530
- let tempSliceArr = seriesSlice[0].actualName;
527
+ let tempSliceArr = seriesSlice;
531
528
  seriesData.forEach(entry => {
532
529
  if (tempSliceArr === entry.properties.currentLegend) {
533
530
  dataRequiredForWaterfall.push(entry);
@@ -3,15 +3,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as d3 from "d3";
4
4
  import { OrgChart } from "d3-org-chart";
5
5
  import { useEffect, useRef } from "react";
6
+ import { logError } from "../../../../Services/ErrorLog";
6
7
  import { fontStyleOptions, } from "../../Core/Common.types";
7
- import { convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, getNumberWithFormatFunction, initSvg, marginCalculationsForChartsWithoutLegends, } from "../../Core/CommonFunctions";
8
+ import { convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, getNumberWithFormatFunction, initSvg, marginCalculationsForChartsWithoutLegends } from "../../Core/CommonFunctions";
8
9
  import { chartMargins } from "../../Core/DefaultProperties.types";
9
10
  import { connectorStyle, orgChartDirection, orgChartLineType, orgChartNodeType, } from "../ChartsWithoutAxisTypes.types";
10
- import { logError } from "../../../../Services/ErrorLog";
11
11
  //#endregion
12
12
  const fileName = "OrganizationChart.tsx";
13
- const OrganizationChart = ({ data, legendEntries, chartId, formatOptions, legendSequence, }) => {
13
+ const OrganizationChart = ({ data, formatOptions, legendEntries, legendSequence, }) => {
14
14
  //#region Variables
15
+ const chartId = crypto.randomUUID();
15
16
  const svgRef = useRef(); // Reference to the SVG element
16
17
  const floatingSvgRef = useRef(); // Reference to the SVG element
17
18
  let chartFormatOptions; // Format options for the chart
@@ -344,12 +344,12 @@ export type bubbleScatterData = {
344
344
  sizeValue: number;
345
345
  };
346
346
  export type TBubbleChartProps = {
347
- chartId: string;
347
+ chartId?: string;
348
348
  clientWidth: number;
349
349
  clientHeight: number;
350
350
  data: bubbleScatterData[];
351
- legendEntries: TLegendsFormatting[];
352
- formatOptions: TDefaultChartFormatOptionsType;
351
+ legendEntries?: TLegendsFormatting[];
352
+ formatOptions?: TDefaultChartFormatOptionsType;
353
353
  };
354
354
  export declare const referenceLineTypes: {
355
355
  None: string;
@@ -1743,7 +1743,9 @@ export function generalizedChartData(chartData, dimensionList) {
1743
1743
  properties = {
1744
1744
  ...chartProperties,
1745
1745
  legend: item.legend,
1746
- currentLegend: item.legend
1746
+ currentLegend: item.legend,
1747
+ alias: item.legend,
1748
+ name: item.legend
1747
1749
  };
1748
1750
  }
1749
1751
  else {
package/package.json CHANGED
@@ -1,22 +1,32 @@
1
1
  {
2
2
  "name": "pace-chart-lib",
3
- "version": "0.0.12",
4
- "main": "dist/index.js",
5
- "module": "./dist/index.js",
3
+ "version": "1.0.1",
4
+ "description": "A simple React + Vite + TS UI library with a Button using custom fonts via SCSS",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/pace-chart-lib.umd.js",
8
+ "module": "dist/pace-chart-lib.es.js",
6
9
  "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "sideEffects": [
14
+ "**/*.css",
15
+ "**/*.scss"
16
+ ],
7
17
  "exports": {
8
18
  ".": {
9
- "import": "./dist/index.js",
10
- "require": "./dist/index.js",
19
+ "import": "./dist/pace-chart-lib.es.js",
20
+ "require": "./dist/pace-chart-lib.umd.js",
11
21
  "types": "./dist/index.d.ts"
12
22
  }
13
23
  },
14
- "files": [
15
- "dist"
16
- ],
17
24
  "scripts": {
18
- "build": "tsc",
19
- "dev": "tsc --watch"
25
+ "build": "vite build && tsc --emitDeclarationOnly --declaration --declarationDir dist --project tsconfig.json",
26
+ "dev": "vite",
27
+ "preview": "vite preview",
28
+ "clean": "rm -rf dist node_modules",
29
+ "watch": "vite build --watch"
20
30
  },
21
31
  "peerDependencies": {
22
32
  "react": "^18.0.0 || ^19.0.0",
@@ -26,7 +36,13 @@
26
36
  "@types/d3": "^7.4.3",
27
37
  "@types/react": "^18.0.0",
28
38
  "@types/react-dom": "^18.0.0",
29
- "typescript": "^5.2.0"
39
+ "typescript": "^5.2.0",
40
+ "@vitejs/plugin-react": "^5.0.2",
41
+ "react": "^19.1.0",
42
+ "react-dom": "^19.1.0",
43
+ "sass": "^1.92.0",
44
+ "vite": "^7.1.4",
45
+ "vite-plugin-css-injected-by-js": "^3.5.2"
30
46
  },
31
47
  "dependencies": {
32
48
  "d3": "^7.9.0",
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- interface BarChartProps {
3
- title?: string;
4
- width?: number;
5
- height?: number;
6
- data: {
7
- label: string;
8
- value: number;
9
- }[];
10
- }
11
- declare const BarChart: React.FC<BarChartProps>;
12
- export default BarChart;
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- const BarChart = ({ title, width = 400, height = 300, data }) => {
3
- const barWidth = width / data.length;
4
- return (_jsxs("div", { style: { width, height, border: "1px solid #ccc", padding: "10px" }, children: [_jsx("h3", { children: title || "Bar Chart" }), _jsx("svg", { width: width, height: height, children: data.map((item, index) => {
5
- const barHeight = item.value;
6
- return (_jsxs("g", { children: [_jsx("rect", { x: index * barWidth + 10, y: height - barHeight, width: barWidth - 20, height: barHeight, fill: "#0074d9" }), _jsx("text", { x: index * barWidth + barWidth / 2, y: height - 5, fontSize: "10", textAnchor: "middle", children: item.label })] }, index));
7
- }) })] }));
8
- };
9
- export default BarChart;
@@ -1,46 +0,0 @@
1
- import * as d3 from "d3";
2
- import { TMargin } from "./ChartsWithAxisTypes.type";
3
- import { TChartJSON, TSeries } from "../ChartsWithAxis/ChartsWithAxisTypes.type";
4
- import { TDefaultChartFormatOptionsType } from "../Core/DefaultProperties";
5
- export declare function getRandomColor(): {
6
- color: string;
7
- };
8
- export declare function calculateWidthHeightDynamically(content: any, fontSize: any, fontFamily: any, rotationDegree?: any, fixedWidth?: any): number[];
9
- export declare function getYAxisLabel(formatOptions: TDefaultChartFormatOptionsType, maxLegendLength: any): number;
10
- export declare function marginCalculation(width: any, height: any, maxNumberForPrimaryAxis: any, YmaxLeft: any, formatOptions: TDefaultChartFormatOptionsType, legendList: string[], dimensionList: string[]): {
11
- Margin: TMargin;
12
- Ylabel: any;
13
- Xlabel: number;
14
- Ytitle: number;
15
- Xtitle: number;
16
- dimensionHeightWidthArray: number[];
17
- staticSvgInnerWidth: number;
18
- chartTitleHeight: number;
19
- legendMargin: number;
20
- };
21
- export declare function initSvg(svgRef: any, width: any, height: any): d3.Selection<any, unknown, null, undefined>;
22
- export declare function customYscaleLabelFormatting(formatOptions: TDefaultChartFormatOptionsType, YminLeft: number, YmaxLeft: number, YminRight: number, YmaxRight: number): {
23
- maxNumberForPrimaryAxis: number;
24
- maxNumberForSecondaryAxis: any;
25
- };
26
- export declare function getYaxisLabelList(dataMin: number, dataMax: number, axisLengthPx: number, labelWidthPx?: number): number[];
27
- export declare function getNumberWithFormat(displayUnits: any, numberFormat: any, decimalPrescision: any): (d: any) => string;
28
- export declare function responsiveYaxisMargin(maxNumberForPrimaryAxis: any, yMaxLeft: any, formatOptions: TDefaultChartFormatOptionsType): any;
29
- export declare function InitChartArea(svg: any, margin: any): any;
30
- export declare function InitChartFloatingArea(formatOptions: TDefaultChartFormatOptionsType, margin: any, floatingSvg: any, gTag: any, chartsWithXScrollFlag: any, chartsWithYScrollFlag: any): any;
31
- export declare function initBlackBox(g: any, formatOptions: TDefaultChartFormatOptionsType, dataTableHeight: any, innerWidth: any, innerHeight: any, chartType: any): void;
32
- export declare function isVerticallyOverlapping(obj1: any, obj2: any): boolean;
33
- export declare function responsiveYaxisLabel(Ymax: any, Ymin: any, innerWidth: any, innerHeight: any, formatOptions: TDefaultChartFormatOptionsType, chartJSON: TChartJSON): any[];
34
- export declare function getLabelsFromAlgo(dataMin: number, dataMax: number, axisLengthPx: number, labelWidthPx?: number): number[];
35
- export declare function initYaxis(gTag: any, formatOptions: TDefaultChartFormatOptionsType, dataTableHeight: any, Ylabel: any, YaxisLeft: any, innerHeight: any): any;
36
- export declare function responsiveXaxisLabel(dimenstionList: any, innerWidth: any): any[];
37
- export declare function initXaxis(gTag: any, chartJSON: any, Xlabel: any, formatOptions: TDefaultChartFormatOptionsType, xAxisObj: any, dataTableHeight: any, YscaleLeft: any, Xaxis: any, dimensionHeightWidthArray: any, height: any, barWidth: any, dataType: any, innerWidth: any, innerHeight: any): any;
38
- export declare function detectBrowserName(): string;
39
- export declare function setDateFormats(name: any, format: any, dimensionmarks: any, datasourceId?: any): any;
40
- export declare function initScrollingSvgClippath(formatOptions: TDefaultChartFormatOptionsType, Margin: any, width: any): void;
41
- export declare function drawSeriesLabels(formatOptions: TDefaultChartFormatOptionsType, floatingTagG: any, seriesLabels: any): void;
42
- export declare function setXaxistitle(formatOptions: TDefaultChartFormatOptionsType, barChart: any, svg: any, Margin: any, Xlabel: any, height: any, Xtitle: any, chartType: any, Ylabel: any, staticSvgInnerWidth: any, innerHeight: any): any;
43
- export declare function Yaxistitle(innerHeight: any, formatOptions: TDefaultChartFormatOptionsType, dataTableHeight: any, barChart: any, svg: any, Margin: any, Ytitle: any, Ylabel: any): any;
44
- export declare function setChartTitle(svg: any, formatOptions: TDefaultChartFormatOptionsType, width: any, chartTitleHeight: any): void;
45
- export declare function initSvgBox(svg: any, formatOptions: TDefaultChartFormatOptionsType, widgetId: any, chartsWithXScrollFlag: any, chartsWithYScrollFlag: any): any;
46
- export declare function lineAnnotations(chartData: TSeries[], Xscale: any, YscaleLeft: any, YscaleRight: any, Margin: any, d3Annotation: any, labelExcludeList: any, individualLabelColor: any, oldAnnotationList: any, formatOptions: TDefaultChartFormatOptionsType, chartType: any): void;