pace-chart-lib 1.0.64 → 1.0.66

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.
@@ -11261,7 +11261,7 @@ const defaultChartFormatOptions = {
11261
11261
  dataLabelsCoordinates: [],
11262
11262
  hideInsignificantValue: false,
11263
11263
  sortBy: "default",
11264
- chartDirection: "top",
11264
+ chartDirection: "right",
11265
11265
  plotAreaRangeFilter: {
11266
11266
  enabled: false,
11267
11267
  condition: "lt",
@@ -13097,7 +13097,7 @@ function setChartTitle(svg, formatOptions, width, chartTitleHeight) {
13097
13097
  let object2 = svg.append("foreignObject").attr(
13098
13098
  "visibility",
13099
13099
  formatOptions.chartTitle.chartTitleVisibility ? "visible" : "hidden"
13100
- ).attr("transform", `translate(2,2)`).attr("class", "chartTitle").attr("width", width).attr("height", chartTitleHeight + "px");
13100
+ ).attr("transform", `translate(2,2)`).attr("class", "chartTitle").attr("width", width - 4).attr("height", chartTitleHeight + "px");
13101
13101
  const parseHTMLText = (html) => {
13102
13102
  const temp = document.createElement("div");
13103
13103
  temp.innerHTML = html;
@@ -21000,19 +21000,20 @@ function marginCalculationForBubbleScatter(width, height, maxMeasure, formatOpti
21000
21000
  let maxLegendWidth = maxLegendDimensions[0];
21001
21001
  let legendMargin = width15Percent < maxLegendWidth + 10 ? width15Percent : maxLegendWidth + 10;
21002
21002
  let totalHeight = formatOptions.plotArea.numberOfBubbles ? 20 : 0;
21003
- let dimensionHeightWidth = preCalculateTextDimensions(
21004
- getNumberWithFormatFunction(
21005
- formatOptions.xAxisLabel.xAxisDisplayUnits,
21006
- formatOptions.xAxisLabel.xAxisNumberFormat,
21007
- formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"
21008
- )(
21009
- maxDimension
21010
- ).toString(),
21011
- convertStringToNumber(formatOptions.xAxisLabel.xAxisLabelFontSize),
21003
+ const maxDim = getNumberWithFormatFunction(
21004
+ formatOptions.xAxisLabel.xAxisDisplayUnits,
21005
+ formatOptions.xAxisLabel.xAxisNumberFormat,
21006
+ formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"
21007
+ )(
21008
+ maxDimension
21009
+ ).toString();
21010
+ let dimensionHeightWidth = calculateWidthHeightDynamically(
21011
+ maxDim,
21012
+ formatOptions.xAxisLabel.xAxisLabelFontSize,
21012
21013
  formatOptions.xAxisLabel.xAxisLabelFontFamily,
21013
21014
  formatOptions.xAxisLabel.xAxisLabelRotation
21014
21015
  );
21015
- let maxDimensionWidth = dimensionHeightWidth.width + 10;
21016
+ let maxDimensionWidth = dimensionHeightWidth[3] + 10;
21016
21017
  let xTitle = formatOptions.xAxisTitle.xAxisTitleVisibility ? formatOptions.xAxisTitle.xAxisDynamicTitleText.length !== 0 ? preCalculateTextDimensions(
21017
21018
  formatOptions.xAxisTitle.xAxisTitleHTML,
21018
21019
  void 0,
@@ -54272,6 +54273,12 @@ const OrganizationChart = ({
54272
54273
  let chartData = [];
54273
54274
  let scrollWidth = 0;
54274
54275
  let scrollHeight = 0;
54276
+ let legendListWidth;
54277
+ let displayedLegends = /* @__PURE__ */ new Map();
54278
+ let maxLegendDimensions;
54279
+ let maxMeasure = Number.NEGATIVE_INFINITY;
54280
+ let minMeasure = Number.POSITIVE_INFINITY;
54281
+ let heatMapScale;
54275
54282
  useEffect(() => {
54276
54283
  drawChart();
54277
54284
  }, [chartId, data, formatOptions]);
@@ -54280,19 +54287,64 @@ const OrganizationChart = ({
54280
54287
  svgRef,
54281
54288
  formatOptions
54282
54289
  ));
54283
- ({ margins, chartTitleHeight, innerHeight, innerWidth } = marginCalculationsForChartsWithoutLegends(
54290
+ dataPreparation();
54291
+ maxLegendDimensions = calculateLegendsMaxPossibleWidth2(displayedLegends);
54292
+ ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } = marginCalculationsForChartsWithoutAxis(
54284
54293
  chartFormatOptions,
54294
+ width,
54285
54295
  height,
54286
- width
54296
+ maxLegendDimensions,
54297
+ margins
54287
54298
  ));
54288
54299
  initSvg(svgRef, width, height, chartFormatOptions);
54289
54300
  drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
54290
- dataPreparation();
54291
54301
  scrollWidthHeightCalculation();
54292
54302
  drawOrganizationChart(chartData);
54303
+ initLegendListForOrganizationChart();
54304
+ };
54305
+ const calculateLegendsMaxPossibleWidth2 = (displayedLegendsMap) => {
54306
+ const legends = [];
54307
+ displayedLegendsMap.forEach((_value, key) => {
54308
+ legends.push(key);
54309
+ });
54310
+ const longestLegend = legends.reduce((a2, b) => a2.length > b.length ? a2 : b, "");
54311
+ const legendDims = preCalculateTextDimensions(
54312
+ longestLegend,
54313
+ convertStringToNumber(chartFormatOptions.legends.legendFontSize),
54314
+ chartFormatOptions.legends.legendFontFamily
54315
+ );
54316
+ return [legendDims.width, legendDims.height];
54317
+ };
54318
+ const initLegendListForOrganizationChart = () => {
54319
+ let seriesData = [];
54320
+ displayedLegends.forEach((colors2, label) => {
54321
+ const color2 = `linear-gradient(90deg, ${colors2.join(", ")})`;
54322
+ seriesData.push({
54323
+ properties: {
54324
+ ...legendEntries[0],
54325
+ name: label,
54326
+ alias: label,
54327
+ color: color2
54328
+ }
54329
+ });
54330
+ });
54331
+ initLegendListWithTotalValueAllowance(
54332
+ chartFormatOptions,
54333
+ svg,
54334
+ seriesData,
54335
+ width,
54336
+ height,
54337
+ legendListWidth,
54338
+ chartTitleHeight,
54339
+ chartId,
54340
+ margins,
54341
+ staticLegendShape.rectangle,
54342
+ void 0
54343
+ );
54293
54344
  };
54294
54345
  const dataPreparation = () => {
54295
54346
  try {
54347
+ const sortType = formatOptions?.plotArea?.sortBy ?? "default";
54296
54348
  chartDirection = chartFormatOptions.plotArea.chartDirection || orgChartDirection.left;
54297
54349
  var sum2 = 0;
54298
54350
  var absoluteSum = 0;
@@ -54303,9 +54355,19 @@ const OrganizationChart = ({
54303
54355
  let tempData = getFlattenedData(rootNode).filter(
54304
54356
  (data2) => data2.value !== null
54305
54357
  );
54358
+ if (sortType !== "default") {
54359
+ tempData = tempData.sort(
54360
+ (a2, b) => sortType === "asc" ? a2.value - b.value : b.value - a2.value
54361
+ );
54362
+ }
54306
54363
  createIdIndexMap(tempData);
54307
54364
  generateUID(tempData);
54308
54365
  chartData = addStyleObjectToChartData(tempData);
54366
+ if (chartFormatOptions.heatMap.showHeatMap) {
54367
+ heatMapScale = sequential().domain([minMeasure, maxMeasure]).interpolator(
54368
+ interpolateRgb$1(chartFormatOptions.heatMap.heatMapMinColor, chartFormatOptions.heatMap.heatMapMaxColor)
54369
+ );
54370
+ }
54309
54371
  } catch (error) {
54310
54372
  logError$2(fileName$1, "dataPreparation", error);
54311
54373
  }
@@ -54362,11 +54424,22 @@ const OrganizationChart = ({
54362
54424
  indexMapForStyleObject.set(styleObject.name, styleObject);
54363
54425
  });
54364
54426
  Object.keys(data2).forEach((key) => {
54365
- const legendObject = indexMapForStyleObject.get(data2[key].UID ?? data2[key].nodeLabel);
54427
+ const nodeObj = data2[key];
54428
+ const legendObject = indexMapForStyleObject.get(nodeObj.UID ?? nodeObj.nodeLabel) ?? legendEntries[0];
54366
54429
  data2[key] = {
54367
- ...data2[key],
54368
- styleObject: legendObject || legendEntries[0]
54430
+ ...nodeObj,
54431
+ styleObject: legendObject
54369
54432
  };
54433
+ if (nodeObj.label) {
54434
+ if (displayedLegends.has(nodeObj.label)) {
54435
+ const colors2 = displayedLegends.get(nodeObj.label);
54436
+ displayedLegends.set(nodeObj.label, [...colors2, legendObject.color ?? "#eedddd"]);
54437
+ } else {
54438
+ displayedLegends.set(nodeObj.label, [legendObject.color ?? "#eedddd"]);
54439
+ }
54440
+ }
54441
+ maxMeasure = Math.max(maxMeasure, nodeObj.value);
54442
+ minMeasure = Math.min(minMeasure, nodeObj.value);
54370
54443
  });
54371
54444
  return data2;
54372
54445
  } catch (error) {
@@ -54407,6 +54480,7 @@ const OrganizationChart = ({
54407
54480
  let connectorVisibility = parseInt(
54408
54481
  chartFormatOptions.connector.connectorLineThickness
54409
54482
  );
54483
+ select$2(floatingSvgRef.current).selectAll("*").remove();
54410
54484
  let organizationalChart = new OrgChart();
54411
54485
  organizationalChart.container(`#floating-${chartId}`).svgWidth(scrollWidth).svgHeight(scrollHeight).nodeHeight((d) => calculateNodeHeight(d)).nodeWidth((d) => calculateNodeWidth(d, true)).layout(chartDirection).diagonal((s2, t, m, offsets = { sy: 0 }) => {
54412
54486
  if (chartDirection == "top" || chartDirection == "bottom" || !chartDirection) {
@@ -54580,7 +54654,7 @@ const OrganizationChart = ({
54580
54654
  justify-content: center;
54581
54655
  align-items: center;
54582
54656
  text-align: center;
54583
- background-color: ${d.data.styleObject.color ? d.data.styleObject.color : d.data.styleObject.backgroundColor};
54657
+ background-color: ${chartFormatOptions.heatMap.showHeatMap ? heatMapScale(d.data.value) : chartFormatOptions.nodes.nodesSingleColor ? chartFormatOptions.nodes.nodesColor : d.data.styleObject.color};
54584
54658
  z-index: 99;
54585
54659
  transform: ${transform};
54586
54660
  transition: unset;">
@@ -55316,6 +55390,15 @@ const ScatterChart = ({
55316
55390
  ));
55317
55391
  initSvg(svgRef, width, height, chartFormatOptions);
55318
55392
  chartAreaTagG = initChartArea(svg, margins);
55393
+ initPlotArea(
55394
+ chartAreaTagG,
55395
+ formatOptions,
55396
+ 0,
55397
+ innerWidth2,
55398
+ innerHeight2,
55399
+ "Scatter",
55400
+ chartId
55401
+ );
55319
55402
  drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
55320
55403
  initScale();
55321
55404
  drawXAxis();
@@ -55462,11 +55545,8 @@ const ScatterChart = ({
55462
55545
  };
55463
55546
  const initScale = () => {
55464
55547
  try {
55465
- let xStartValue = chartFormatOptions.xAxisLabel.xAxisIntervalsVisibility && chartFormatOptions.xAxisLabel.xAxisMinText !== "" ? parseFloat(chartFormatOptions.xAxisLabel.xAxisMinText) : minDimension > 0 ? 0 : minDimension * 1.1;
55466
- let xEndValue = chartFormatOptions.xAxisLabel.xAxisIntervalsVisibility && chartFormatOptions.xAxisLabel.xAxisMaxText !== "" ? parseFloat(chartFormatOptions.xAxisLabel.xAxisMaxText) : maxDimension * 1.1;
55467
55548
  let yStartValue = chartFormatOptions.yAxisLabel.yAxisIntervalsVisibility && chartFormatOptions.yAxisLabel.yAxisMinText !== "" ? parseFloat(chartFormatOptions.yAxisLabel.yAxisMinText) : minMeasure > 0 ? 0 : minMeasure * 1.1;
55468
55549
  let yEndValue = chartFormatOptions.yAxisLabel.yAxisIntervalsVisibility && chartFormatOptions.yAxisLabel.yAxisMaxText !== "" ? parseFloat(chartFormatOptions.yAxisLabel.yAxisMaxText) : maxMeasure * 1.1;
55469
- xScale = linear$1().domain([xStartValue, xEndValue]).range([0, innerWidth2]);
55470
55550
  yScale = linear$1().domain([yStartValue, yEndValue]).range([innerHeight2, 0]);
55471
55551
  sizeScale = linear$1().domain([sizeValueMin, sizeValueMax]).range([1, 10]);
55472
55552
  } catch (e) {
@@ -55475,6 +55555,8 @@ const ScatterChart = ({
55475
55555
  };
55476
55556
  const drawXAxis = () => {
55477
55557
  try {
55558
+ const tickHeightPercentage = parseFloat(formatOptions.plotArea.ticksHeight) || 100;
55559
+ const tickSize = tickHeightPercentage / 100 * innerHeight2;
55478
55560
  let { xAxisLabelArray, customTickValue } = responsiveXaxisLabelForNumericValue(
55479
55561
  maxDimension,
55480
55562
  minDimension,
@@ -55485,6 +55567,11 @@ const ScatterChart = ({
55485
55567
  innerHeight2,
55486
55568
  false
55487
55569
  );
55570
+ if (xAxisLabelArray.length > 0) {
55571
+ xScale = linear$1().domain([xAxisLabelArray[0], xAxisLabelArray[xAxisLabelArray.length - 1]]).range([0, innerWidth2]);
55572
+ } else {
55573
+ xScale = linear$1().domain([customXaxisMinValue, customXaxisMaxValue]).range([0, innerWidth2]);
55574
+ }
55488
55575
  const xAxis = axisBottom(xScale).tickFormat(
55489
55576
  getNumberWithFormatFunction(
55490
55577
  formatOptions.xAxisLabel.xAxisDisplayUnits,
@@ -55492,7 +55579,7 @@ const ScatterChart = ({
55492
55579
  formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"
55493
55580
  )
55494
55581
  ).tickSize(
55495
- chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesVertical ? chartFormatOptions.xAxisLabel.xAxisPosition === "0" ? -innerHeight2 : chartFormatOptions.xAxisLabel.xAxisPosition === "1" ? innerHeight2 : 0 : 0 : 0
55582
+ chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesVertical ? chartFormatOptions.xAxisLabel.xAxisPosition === "0" ? -tickSize : chartFormatOptions.xAxisLabel.xAxisPosition === "1" ? tickSize : 0 : 0 : 0
55496
55583
  ).tickValues(xAxisLabelArray.length > 0 ? xAxisLabelArray : null).ticks(customTickValue).tickPadding(8).tickSizeOuter(0);
55497
55584
  initXaxis(
55498
55585
  chartAreaTagG,
@@ -55511,6 +55598,8 @@ const ScatterChart = ({
55511
55598
  };
55512
55599
  const drawYAxis = () => {
55513
55600
  try {
55601
+ const tickWidthPercentage = parseFloat(formatOptions.plotArea.ticksWidth) || 100;
55602
+ const tickSize = tickWidthPercentage / 100 * innerWidth2;
55514
55603
  let { yAxisLabelArray, customTickValue } = responsiveYaxisLabel(
55515
55604
  maxMeasure,
55516
55605
  minMeasure,
@@ -55526,7 +55615,7 @@ const ScatterChart = ({
55526
55615
  formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? "2"
55527
55616
  )
55528
55617
  ).tickSize(
55529
- chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesHorizontal ? -innerWidth2 : 0 : 0
55618
+ chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesHorizontal ? -tickSize : 0 : 0
55530
55619
  ).tickValues(yAxisLabelArray.length > 0 ? yAxisLabelArray : null).ticks(customTickValue).tickPadding(8).tickSizeOuter(0);
55531
55620
  initYaxis(
55532
55621
  chartAreaTagG,
@@ -55709,10 +55798,12 @@ const ScatterChart = ({
55709
55798
  ).style("flex-wrap", "nowrap").style("padding-left", "3px");
55710
55799
  ColorList.forEach((d, i) => {
55711
55800
  let innerdiv = div.append("div").style("display", "inline-flex").style("justify-content", "flex-start").style("align-items", "center").style("margin", "3px 0px").style("width", "fit-content").style("flex-wrap", "nowrap").style("white-space", "nowrap").style("font-size", chartFormatOptions.legends.legendFontSize + "px").style("font-family", chartFormatOptions.legends.legendFontFamily).on("mousemove", function(d2) {
55712
- svg.selectAll(".parentGroup").classed("highlight", false).classed("unhighlight", true);
55713
- svg.selectAll(
55714
- '[colorId="' + getJQuerySelector2(this.textContent.replace(/ /g, "-")) + '"]'
55715
- ).classed("highlight", true).classed("unhighlight", false);
55801
+ if (chartFormatOptions.legends.onHoverEffect) {
55802
+ svg.selectAll(".parentGroup").classed("highlight", false).classed("unhighlight", true);
55803
+ svg.selectAll(
55804
+ '[colorId="' + getJQuerySelector2(this.textContent.replace(/ /g, "-")) + '"]'
55805
+ ).classed("highlight", true).classed("unhighlight", false);
55806
+ }
55716
55807
  }).on("mouseout", function(d2) {
55717
55808
  svg.selectAll(".parentGroup").classed("highlight", false).classed("unhighlight", false);
55718
55809
  svg.selectAll(
@@ -55795,35 +55886,24 @@ const ScatterChart = ({
55795
55886
  logError$2(fileName, "shapeListWithScroll", e);
55796
55887
  }
55797
55888
  };
55798
- const shapesForScatterPlot = (innerdiv, shapes) => {
55889
+ const shapesForScatterPlot = (innerdiv, shape) => {
55799
55890
  try {
55800
- shapes = shapes.toLowerCase();
55801
- switch (shapes) {
55802
- case "circle":
55803
- case "none":
55804
- innerdiv.append("svg").attr("height", "10px").attr("width", "10px").append("circle").attr("cx", "5px").attr("cy", "5px").attr("r", "5px").style("fill", "black");
55805
- break;
55806
- case "square":
55807
- innerdiv.append("div").style("height", "10px").style("width", "10px").style("background", "black").style("border-radius", "1px");
55808
- break;
55809
- case "triangle":
55810
- innerdiv.append("div").style("border-left", "6px solid transparent").style("border-right", "6px solid transparent").style("border-bottom", "10px solid black");
55811
- break;
55812
- case "cross":
55813
- innerdiv.append("div").style("height", "4px").style("width", "10px").style("background", "black").style("border-radius", "1px").append("div").style("height", "10px").style("width", "4px").style("background", "black").style("border-radius", "1px").style("position", "relative").style("top", "-3px").style("left", "3px");
55814
- break;
55815
- case "diamond":
55816
- innerdiv.append("div").style("height", "10px").style("width", "10px").style("background", "black").style("border-radius", "1px").style("transform", "rotate(45deg)");
55817
- break;
55818
- case "star":
55819
- innerdiv.append("div").style("border-left", "6px solid transparent").style("border-right", "6px solid transparent").style("border-bottom", "10px solid black").style("position", "relative").style("top", "-2px").style("transform", "rotate(0deg)").append("div").style("border-left", "6px solid transparent").style("border-right", "6px solid transparent").style("border-top", "10px solid black").style("position", "absolute").style("top", "2px").style("left", "-5.5px").style("transform", "rotate(360deg)");
55820
- break;
55821
- case "wye":
55822
- innerdiv.append("div").style("height", "6.5px").style("width", "3px").style("background", "black").append("div").style("height", "5px").style("width", "3px").style("background", "black").style("transform", "rotate(-55deg)").style("position", "relative").style("top", "-2px").style("left", "-2px").append("div").style("height", "5px").style("width", "3px").style("background", "black").style("transform", "rotate(108deg)").style("position", "relative").style("top", "3px").style("left", "2px");
55823
- break;
55824
- default:
55825
- break;
55826
- }
55891
+ const symbolMap = {
55892
+ none: circle,
55893
+ circle,
55894
+ square,
55895
+ triangle,
55896
+ cross,
55897
+ diamond,
55898
+ star,
55899
+ wye
55900
+ };
55901
+ const symbolType = symbolMap[shape?.toLowerCase()] || circle;
55902
+ const size = 80;
55903
+ innerdiv.append("svg").attr("width", 14).attr("height", 14).append("path").attr(
55904
+ "d",
55905
+ Symbol$1().type(symbolType).size(size)()
55906
+ ).attr("transform", "translate(7,7)").attr("fill", "black");
55827
55907
  } catch (error) {
55828
55908
  logError$2(fileName, "shapesForScatterPlot", error);
55829
55909
  }
@@ -11264,7 +11264,7 @@
11264
11264
  dataLabelsCoordinates: [],
11265
11265
  hideInsignificantValue: false,
11266
11266
  sortBy: "default",
11267
- chartDirection: "top",
11267
+ chartDirection: "right",
11268
11268
  plotAreaRangeFilter: {
11269
11269
  enabled: false,
11270
11270
  condition: "lt",
@@ -13100,7 +13100,7 @@
13100
13100
  let object2 = svg.append("foreignObject").attr(
13101
13101
  "visibility",
13102
13102
  formatOptions.chartTitle.chartTitleVisibility ? "visible" : "hidden"
13103
- ).attr("transform", `translate(2,2)`).attr("class", "chartTitle").attr("width", width).attr("height", chartTitleHeight + "px");
13103
+ ).attr("transform", `translate(2,2)`).attr("class", "chartTitle").attr("width", width - 4).attr("height", chartTitleHeight + "px");
13104
13104
  const parseHTMLText = (html) => {
13105
13105
  const temp = document.createElement("div");
13106
13106
  temp.innerHTML = html;
@@ -21003,19 +21003,20 @@
21003
21003
  let maxLegendWidth = maxLegendDimensions[0];
21004
21004
  let legendMargin = width15Percent < maxLegendWidth + 10 ? width15Percent : maxLegendWidth + 10;
21005
21005
  let totalHeight = formatOptions.plotArea.numberOfBubbles ? 20 : 0;
21006
- let dimensionHeightWidth = preCalculateTextDimensions(
21007
- getNumberWithFormatFunction(
21008
- formatOptions.xAxisLabel.xAxisDisplayUnits,
21009
- formatOptions.xAxisLabel.xAxisNumberFormat,
21010
- formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"
21011
- )(
21012
- maxDimension
21013
- ).toString(),
21014
- convertStringToNumber(formatOptions.xAxisLabel.xAxisLabelFontSize),
21006
+ const maxDim = getNumberWithFormatFunction(
21007
+ formatOptions.xAxisLabel.xAxisDisplayUnits,
21008
+ formatOptions.xAxisLabel.xAxisNumberFormat,
21009
+ formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"
21010
+ )(
21011
+ maxDimension
21012
+ ).toString();
21013
+ let dimensionHeightWidth = calculateWidthHeightDynamically(
21014
+ maxDim,
21015
+ formatOptions.xAxisLabel.xAxisLabelFontSize,
21015
21016
  formatOptions.xAxisLabel.xAxisLabelFontFamily,
21016
21017
  formatOptions.xAxisLabel.xAxisLabelRotation
21017
21018
  );
21018
- let maxDimensionWidth = dimensionHeightWidth.width + 10;
21019
+ let maxDimensionWidth = dimensionHeightWidth[3] + 10;
21019
21020
  let xTitle = formatOptions.xAxisTitle.xAxisTitleVisibility ? formatOptions.xAxisTitle.xAxisDynamicTitleText.length !== 0 ? preCalculateTextDimensions(
21020
21021
  formatOptions.xAxisTitle.xAxisTitleHTML,
21021
21022
  void 0,
@@ -54275,6 +54276,12 @@
54275
54276
  let chartData = [];
54276
54277
  let scrollWidth = 0;
54277
54278
  let scrollHeight = 0;
54279
+ let legendListWidth;
54280
+ let displayedLegends = /* @__PURE__ */ new Map();
54281
+ let maxLegendDimensions;
54282
+ let maxMeasure = Number.NEGATIVE_INFINITY;
54283
+ let minMeasure = Number.POSITIVE_INFINITY;
54284
+ let heatMapScale;
54278
54285
  require$$0$1.useEffect(() => {
54279
54286
  drawChart();
54280
54287
  }, [chartId, data, formatOptions]);
@@ -54283,19 +54290,64 @@
54283
54290
  svgRef,
54284
54291
  formatOptions
54285
54292
  ));
54286
- ({ margins, chartTitleHeight, innerHeight, innerWidth } = marginCalculationsForChartsWithoutLegends(
54293
+ dataPreparation();
54294
+ maxLegendDimensions = calculateLegendsMaxPossibleWidth2(displayedLegends);
54295
+ ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } = marginCalculationsForChartsWithoutAxis(
54287
54296
  chartFormatOptions,
54297
+ width,
54288
54298
  height,
54289
- width
54299
+ maxLegendDimensions,
54300
+ margins
54290
54301
  ));
54291
54302
  initSvg(svgRef, width, height, chartFormatOptions);
54292
54303
  drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
54293
- dataPreparation();
54294
54304
  scrollWidthHeightCalculation();
54295
54305
  drawOrganizationChart(chartData);
54306
+ initLegendListForOrganizationChart();
54307
+ };
54308
+ const calculateLegendsMaxPossibleWidth2 = (displayedLegendsMap) => {
54309
+ const legends = [];
54310
+ displayedLegendsMap.forEach((_value, key) => {
54311
+ legends.push(key);
54312
+ });
54313
+ const longestLegend = legends.reduce((a2, b) => a2.length > b.length ? a2 : b, "");
54314
+ const legendDims = preCalculateTextDimensions(
54315
+ longestLegend,
54316
+ convertStringToNumber(chartFormatOptions.legends.legendFontSize),
54317
+ chartFormatOptions.legends.legendFontFamily
54318
+ );
54319
+ return [legendDims.width, legendDims.height];
54320
+ };
54321
+ const initLegendListForOrganizationChart = () => {
54322
+ let seriesData = [];
54323
+ displayedLegends.forEach((colors2, label) => {
54324
+ const color2 = `linear-gradient(90deg, ${colors2.join(", ")})`;
54325
+ seriesData.push({
54326
+ properties: {
54327
+ ...legendEntries[0],
54328
+ name: label,
54329
+ alias: label,
54330
+ color: color2
54331
+ }
54332
+ });
54333
+ });
54334
+ initLegendListWithTotalValueAllowance(
54335
+ chartFormatOptions,
54336
+ svg,
54337
+ seriesData,
54338
+ width,
54339
+ height,
54340
+ legendListWidth,
54341
+ chartTitleHeight,
54342
+ chartId,
54343
+ margins,
54344
+ staticLegendShape.rectangle,
54345
+ void 0
54346
+ );
54296
54347
  };
54297
54348
  const dataPreparation = () => {
54298
54349
  try {
54350
+ const sortType = formatOptions?.plotArea?.sortBy ?? "default";
54299
54351
  chartDirection = chartFormatOptions.plotArea.chartDirection || orgChartDirection.left;
54300
54352
  var sum2 = 0;
54301
54353
  var absoluteSum = 0;
@@ -54306,9 +54358,19 @@
54306
54358
  let tempData = getFlattenedData(rootNode).filter(
54307
54359
  (data2) => data2.value !== null
54308
54360
  );
54361
+ if (sortType !== "default") {
54362
+ tempData = tempData.sort(
54363
+ (a2, b) => sortType === "asc" ? a2.value - b.value : b.value - a2.value
54364
+ );
54365
+ }
54309
54366
  createIdIndexMap(tempData);
54310
54367
  generateUID(tempData);
54311
54368
  chartData = addStyleObjectToChartData(tempData);
54369
+ if (chartFormatOptions.heatMap.showHeatMap) {
54370
+ heatMapScale = sequential().domain([minMeasure, maxMeasure]).interpolator(
54371
+ interpolateRgb$1(chartFormatOptions.heatMap.heatMapMinColor, chartFormatOptions.heatMap.heatMapMaxColor)
54372
+ );
54373
+ }
54312
54374
  } catch (error) {
54313
54375
  logError$2(fileName$1, "dataPreparation", error);
54314
54376
  }
@@ -54365,11 +54427,22 @@
54365
54427
  indexMapForStyleObject.set(styleObject.name, styleObject);
54366
54428
  });
54367
54429
  Object.keys(data2).forEach((key) => {
54368
- const legendObject = indexMapForStyleObject.get(data2[key].UID ?? data2[key].nodeLabel);
54430
+ const nodeObj = data2[key];
54431
+ const legendObject = indexMapForStyleObject.get(nodeObj.UID ?? nodeObj.nodeLabel) ?? legendEntries[0];
54369
54432
  data2[key] = {
54370
- ...data2[key],
54371
- styleObject: legendObject || legendEntries[0]
54433
+ ...nodeObj,
54434
+ styleObject: legendObject
54372
54435
  };
54436
+ if (nodeObj.label) {
54437
+ if (displayedLegends.has(nodeObj.label)) {
54438
+ const colors2 = displayedLegends.get(nodeObj.label);
54439
+ displayedLegends.set(nodeObj.label, [...colors2, legendObject.color ?? "#eedddd"]);
54440
+ } else {
54441
+ displayedLegends.set(nodeObj.label, [legendObject.color ?? "#eedddd"]);
54442
+ }
54443
+ }
54444
+ maxMeasure = Math.max(maxMeasure, nodeObj.value);
54445
+ minMeasure = Math.min(minMeasure, nodeObj.value);
54373
54446
  });
54374
54447
  return data2;
54375
54448
  } catch (error) {
@@ -54410,6 +54483,7 @@
54410
54483
  let connectorVisibility = parseInt(
54411
54484
  chartFormatOptions.connector.connectorLineThickness
54412
54485
  );
54486
+ select$2(floatingSvgRef.current).selectAll("*").remove();
54413
54487
  let organizationalChart = new OrgChart();
54414
54488
  organizationalChart.container(`#floating-${chartId}`).svgWidth(scrollWidth).svgHeight(scrollHeight).nodeHeight((d) => calculateNodeHeight(d)).nodeWidth((d) => calculateNodeWidth(d, true)).layout(chartDirection).diagonal((s2, t, m, offsets = { sy: 0 }) => {
54415
54489
  if (chartDirection == "top" || chartDirection == "bottom" || !chartDirection) {
@@ -54583,7 +54657,7 @@
54583
54657
  justify-content: center;
54584
54658
  align-items: center;
54585
54659
  text-align: center;
54586
- background-color: ${d.data.styleObject.color ? d.data.styleObject.color : d.data.styleObject.backgroundColor};
54660
+ background-color: ${chartFormatOptions.heatMap.showHeatMap ? heatMapScale(d.data.value) : chartFormatOptions.nodes.nodesSingleColor ? chartFormatOptions.nodes.nodesColor : d.data.styleObject.color};
54587
54661
  z-index: 99;
54588
54662
  transform: ${transform};
54589
54663
  transition: unset;">
@@ -55319,6 +55393,15 @@
55319
55393
  ));
55320
55394
  initSvg(svgRef, width, height, chartFormatOptions);
55321
55395
  chartAreaTagG = initChartArea(svg, margins);
55396
+ initPlotArea(
55397
+ chartAreaTagG,
55398
+ formatOptions,
55399
+ 0,
55400
+ innerWidth2,
55401
+ innerHeight2,
55402
+ "Scatter",
55403
+ chartId
55404
+ );
55322
55405
  drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
55323
55406
  initScale();
55324
55407
  drawXAxis();
@@ -55465,11 +55548,8 @@
55465
55548
  };
55466
55549
  const initScale = () => {
55467
55550
  try {
55468
- let xStartValue = chartFormatOptions.xAxisLabel.xAxisIntervalsVisibility && chartFormatOptions.xAxisLabel.xAxisMinText !== "" ? parseFloat(chartFormatOptions.xAxisLabel.xAxisMinText) : minDimension > 0 ? 0 : minDimension * 1.1;
55469
- let xEndValue = chartFormatOptions.xAxisLabel.xAxisIntervalsVisibility && chartFormatOptions.xAxisLabel.xAxisMaxText !== "" ? parseFloat(chartFormatOptions.xAxisLabel.xAxisMaxText) : maxDimension * 1.1;
55470
55551
  let yStartValue = chartFormatOptions.yAxisLabel.yAxisIntervalsVisibility && chartFormatOptions.yAxisLabel.yAxisMinText !== "" ? parseFloat(chartFormatOptions.yAxisLabel.yAxisMinText) : minMeasure > 0 ? 0 : minMeasure * 1.1;
55471
55552
  let yEndValue = chartFormatOptions.yAxisLabel.yAxisIntervalsVisibility && chartFormatOptions.yAxisLabel.yAxisMaxText !== "" ? parseFloat(chartFormatOptions.yAxisLabel.yAxisMaxText) : maxMeasure * 1.1;
55472
- xScale = linear$1().domain([xStartValue, xEndValue]).range([0, innerWidth2]);
55473
55553
  yScale = linear$1().domain([yStartValue, yEndValue]).range([innerHeight2, 0]);
55474
55554
  sizeScale = linear$1().domain([sizeValueMin, sizeValueMax]).range([1, 10]);
55475
55555
  } catch (e) {
@@ -55478,6 +55558,8 @@
55478
55558
  };
55479
55559
  const drawXAxis = () => {
55480
55560
  try {
55561
+ const tickHeightPercentage = parseFloat(formatOptions.plotArea.ticksHeight) || 100;
55562
+ const tickSize = tickHeightPercentage / 100 * innerHeight2;
55481
55563
  let { xAxisLabelArray, customTickValue } = responsiveXaxisLabelForNumericValue(
55482
55564
  maxDimension,
55483
55565
  minDimension,
@@ -55488,6 +55570,11 @@
55488
55570
  innerHeight2,
55489
55571
  false
55490
55572
  );
55573
+ if (xAxisLabelArray.length > 0) {
55574
+ xScale = linear$1().domain([xAxisLabelArray[0], xAxisLabelArray[xAxisLabelArray.length - 1]]).range([0, innerWidth2]);
55575
+ } else {
55576
+ xScale = linear$1().domain([customXaxisMinValue, customXaxisMaxValue]).range([0, innerWidth2]);
55577
+ }
55491
55578
  const xAxis = axisBottom(xScale).tickFormat(
55492
55579
  getNumberWithFormatFunction(
55493
55580
  formatOptions.xAxisLabel.xAxisDisplayUnits,
@@ -55495,7 +55582,7 @@
55495
55582
  formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"
55496
55583
  )
55497
55584
  ).tickSize(
55498
- chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesVertical ? chartFormatOptions.xAxisLabel.xAxisPosition === "0" ? -innerHeight2 : chartFormatOptions.xAxisLabel.xAxisPosition === "1" ? innerHeight2 : 0 : 0 : 0
55585
+ chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesVertical ? chartFormatOptions.xAxisLabel.xAxisPosition === "0" ? -tickSize : chartFormatOptions.xAxisLabel.xAxisPosition === "1" ? tickSize : 0 : 0 : 0
55499
55586
  ).tickValues(xAxisLabelArray.length > 0 ? xAxisLabelArray : null).ticks(customTickValue).tickPadding(8).tickSizeOuter(0);
55500
55587
  initXaxis(
55501
55588
  chartAreaTagG,
@@ -55514,6 +55601,8 @@
55514
55601
  };
55515
55602
  const drawYAxis = () => {
55516
55603
  try {
55604
+ const tickWidthPercentage = parseFloat(formatOptions.plotArea.ticksWidth) || 100;
55605
+ const tickSize = tickWidthPercentage / 100 * innerWidth2;
55517
55606
  let { yAxisLabelArray, customTickValue } = responsiveYaxisLabel(
55518
55607
  maxMeasure,
55519
55608
  minMeasure,
@@ -55529,7 +55618,7 @@
55529
55618
  formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? "2"
55530
55619
  )
55531
55620
  ).tickSize(
55532
- chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesHorizontal ? -innerWidth2 : 0 : 0
55621
+ chartFormatOptions.plotArea.gridLinesVisibility ? chartFormatOptions.plotArea.gridLinesHorizontal ? -tickSize : 0 : 0
55533
55622
  ).tickValues(yAxisLabelArray.length > 0 ? yAxisLabelArray : null).ticks(customTickValue).tickPadding(8).tickSizeOuter(0);
55534
55623
  initYaxis(
55535
55624
  chartAreaTagG,
@@ -55712,10 +55801,12 @@
55712
55801
  ).style("flex-wrap", "nowrap").style("padding-left", "3px");
55713
55802
  ColorList.forEach((d, i) => {
55714
55803
  let innerdiv = div.append("div").style("display", "inline-flex").style("justify-content", "flex-start").style("align-items", "center").style("margin", "3px 0px").style("width", "fit-content").style("flex-wrap", "nowrap").style("white-space", "nowrap").style("font-size", chartFormatOptions.legends.legendFontSize + "px").style("font-family", chartFormatOptions.legends.legendFontFamily).on("mousemove", function(d2) {
55715
- svg.selectAll(".parentGroup").classed("highlight", false).classed("unhighlight", true);
55716
- svg.selectAll(
55717
- '[colorId="' + getJQuerySelector2(this.textContent.replace(/ /g, "-")) + '"]'
55718
- ).classed("highlight", true).classed("unhighlight", false);
55804
+ if (chartFormatOptions.legends.onHoverEffect) {
55805
+ svg.selectAll(".parentGroup").classed("highlight", false).classed("unhighlight", true);
55806
+ svg.selectAll(
55807
+ '[colorId="' + getJQuerySelector2(this.textContent.replace(/ /g, "-")) + '"]'
55808
+ ).classed("highlight", true).classed("unhighlight", false);
55809
+ }
55719
55810
  }).on("mouseout", function(d2) {
55720
55811
  svg.selectAll(".parentGroup").classed("highlight", false).classed("unhighlight", false);
55721
55812
  svg.selectAll(
@@ -55798,35 +55889,24 @@
55798
55889
  logError$2(fileName, "shapeListWithScroll", e);
55799
55890
  }
55800
55891
  };
55801
- const shapesForScatterPlot = (innerdiv, shapes) => {
55892
+ const shapesForScatterPlot = (innerdiv, shape) => {
55802
55893
  try {
55803
- shapes = shapes.toLowerCase();
55804
- switch (shapes) {
55805
- case "circle":
55806
- case "none":
55807
- innerdiv.append("svg").attr("height", "10px").attr("width", "10px").append("circle").attr("cx", "5px").attr("cy", "5px").attr("r", "5px").style("fill", "black");
55808
- break;
55809
- case "square":
55810
- innerdiv.append("div").style("height", "10px").style("width", "10px").style("background", "black").style("border-radius", "1px");
55811
- break;
55812
- case "triangle":
55813
- innerdiv.append("div").style("border-left", "6px solid transparent").style("border-right", "6px solid transparent").style("border-bottom", "10px solid black");
55814
- break;
55815
- case "cross":
55816
- innerdiv.append("div").style("height", "4px").style("width", "10px").style("background", "black").style("border-radius", "1px").append("div").style("height", "10px").style("width", "4px").style("background", "black").style("border-radius", "1px").style("position", "relative").style("top", "-3px").style("left", "3px");
55817
- break;
55818
- case "diamond":
55819
- innerdiv.append("div").style("height", "10px").style("width", "10px").style("background", "black").style("border-radius", "1px").style("transform", "rotate(45deg)");
55820
- break;
55821
- case "star":
55822
- innerdiv.append("div").style("border-left", "6px solid transparent").style("border-right", "6px solid transparent").style("border-bottom", "10px solid black").style("position", "relative").style("top", "-2px").style("transform", "rotate(0deg)").append("div").style("border-left", "6px solid transparent").style("border-right", "6px solid transparent").style("border-top", "10px solid black").style("position", "absolute").style("top", "2px").style("left", "-5.5px").style("transform", "rotate(360deg)");
55823
- break;
55824
- case "wye":
55825
- innerdiv.append("div").style("height", "6.5px").style("width", "3px").style("background", "black").append("div").style("height", "5px").style("width", "3px").style("background", "black").style("transform", "rotate(-55deg)").style("position", "relative").style("top", "-2px").style("left", "-2px").append("div").style("height", "5px").style("width", "3px").style("background", "black").style("transform", "rotate(108deg)").style("position", "relative").style("top", "3px").style("left", "2px");
55826
- break;
55827
- default:
55828
- break;
55829
- }
55894
+ const symbolMap = {
55895
+ none: circle,
55896
+ circle,
55897
+ square,
55898
+ triangle,
55899
+ cross,
55900
+ diamond,
55901
+ star,
55902
+ wye
55903
+ };
55904
+ const symbolType = symbolMap[shape?.toLowerCase()] || circle;
55905
+ const size = 80;
55906
+ innerdiv.append("svg").attr("width", 14).attr("height", 14).append("path").attr(
55907
+ "d",
55908
+ Symbol$1().type(symbolType).size(size)()
55909
+ ).attr("transform", "translate(7,7)").attr("fill", "black");
55830
55910
  } catch (error) {
55831
55911
  logError$2(fileName, "shapesForScatterPlot", error);
55832
55912
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pace-chart-lib",
3
- "version": "1.0.64",
3
+ "version": "1.0.66",
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",