pace-chart-lib 1.0.64 → 1.0.65

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",
@@ -54272,6 +54272,12 @@ const OrganizationChart = ({
54272
54272
  let chartData = [];
54273
54273
  let scrollWidth = 0;
54274
54274
  let scrollHeight = 0;
54275
+ let legendListWidth;
54276
+ let displayedLegends = /* @__PURE__ */ new Map();
54277
+ let maxLegendDimensions;
54278
+ let maxMeasure = Number.NEGATIVE_INFINITY;
54279
+ let minMeasure = Number.POSITIVE_INFINITY;
54280
+ let heatMapScale;
54275
54281
  useEffect(() => {
54276
54282
  drawChart();
54277
54283
  }, [chartId, data, formatOptions]);
@@ -54280,16 +54286,60 @@ const OrganizationChart = ({
54280
54286
  svgRef,
54281
54287
  formatOptions
54282
54288
  ));
54283
- ({ margins, chartTitleHeight, innerHeight, innerWidth } = marginCalculationsForChartsWithoutLegends(
54289
+ dataPreparation();
54290
+ maxLegendDimensions = calculateLegendsMaxPossibleWidth2(displayedLegends);
54291
+ ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } = marginCalculationsForChartsWithoutAxis(
54284
54292
  chartFormatOptions,
54293
+ width,
54285
54294
  height,
54286
- width
54295
+ maxLegendDimensions,
54296
+ margins
54287
54297
  ));
54288
54298
  initSvg(svgRef, width, height, chartFormatOptions);
54289
54299
  drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
54290
- dataPreparation();
54291
54300
  scrollWidthHeightCalculation();
54292
54301
  drawOrganizationChart(chartData);
54302
+ initLegendListForOrganizationChart();
54303
+ };
54304
+ const calculateLegendsMaxPossibleWidth2 = (displayedLegendsMap) => {
54305
+ const legends = [];
54306
+ displayedLegendsMap.forEach((_value, key) => {
54307
+ legends.push(key);
54308
+ });
54309
+ const longestLegend = legends.reduce((a2, b) => a2.length > b.length ? a2 : b, "");
54310
+ const legendDims = preCalculateTextDimensions(
54311
+ longestLegend,
54312
+ convertStringToNumber(chartFormatOptions.legends.legendFontSize),
54313
+ chartFormatOptions.legends.legendFontFamily
54314
+ );
54315
+ return [legendDims.width, legendDims.height];
54316
+ };
54317
+ const initLegendListForOrganizationChart = () => {
54318
+ let seriesData = [];
54319
+ displayedLegends.forEach((colors2, label) => {
54320
+ const color2 = `linear-gradient(90deg, ${colors2.join(", ")})`;
54321
+ seriesData.push({
54322
+ properties: {
54323
+ ...legendEntries[0],
54324
+ name: label,
54325
+ alias: label,
54326
+ color: color2
54327
+ }
54328
+ });
54329
+ });
54330
+ initLegendListWithTotalValueAllowance(
54331
+ chartFormatOptions,
54332
+ svg,
54333
+ seriesData,
54334
+ width,
54335
+ height,
54336
+ legendListWidth,
54337
+ chartTitleHeight,
54338
+ chartId,
54339
+ margins,
54340
+ staticLegendShape.rectangle,
54341
+ void 0
54342
+ );
54293
54343
  };
54294
54344
  const dataPreparation = () => {
54295
54345
  try {
@@ -54306,6 +54356,11 @@ const OrganizationChart = ({
54306
54356
  createIdIndexMap(tempData);
54307
54357
  generateUID(tempData);
54308
54358
  chartData = addStyleObjectToChartData(tempData);
54359
+ if (chartFormatOptions.heatMap.showHeatMap) {
54360
+ heatMapScale = sequential().domain([minMeasure, maxMeasure]).interpolator(
54361
+ interpolateRgb$1(chartFormatOptions.heatMap.heatMapMaxColor, chartFormatOptions.heatMap.heatMapMinColor)
54362
+ );
54363
+ }
54309
54364
  } catch (error) {
54310
54365
  logError$2(fileName$1, "dataPreparation", error);
54311
54366
  }
@@ -54362,11 +54417,22 @@ const OrganizationChart = ({
54362
54417
  indexMapForStyleObject.set(styleObject.name, styleObject);
54363
54418
  });
54364
54419
  Object.keys(data2).forEach((key) => {
54365
- const legendObject = indexMapForStyleObject.get(data2[key].UID ?? data2[key].nodeLabel);
54420
+ const nodeObj = data2[key];
54421
+ const legendObject = indexMapForStyleObject.get(nodeObj.UID ?? nodeObj.nodeLabel) ?? legendEntries[0];
54366
54422
  data2[key] = {
54367
- ...data2[key],
54368
- styleObject: legendObject || legendEntries[0]
54423
+ ...nodeObj,
54424
+ styleObject: legendObject
54369
54425
  };
54426
+ if (nodeObj.label) {
54427
+ if (displayedLegends.has(nodeObj.label)) {
54428
+ const colors2 = displayedLegends.get(nodeObj.label);
54429
+ displayedLegends.set(nodeObj.label, [...colors2, legendObject.color ?? "#eedddd"]);
54430
+ } else {
54431
+ displayedLegends.set(nodeObj.label, [legendObject.color ?? "#eedddd"]);
54432
+ }
54433
+ }
54434
+ maxMeasure = Math.max(maxMeasure, nodeObj.value);
54435
+ minMeasure = Math.min(minMeasure, nodeObj.value);
54370
54436
  });
54371
54437
  return data2;
54372
54438
  } catch (error) {
@@ -54407,6 +54473,7 @@ const OrganizationChart = ({
54407
54473
  let connectorVisibility = parseInt(
54408
54474
  chartFormatOptions.connector.connectorLineThickness
54409
54475
  );
54476
+ select$2(floatingSvgRef.current).selectAll("*").remove();
54410
54477
  let organizationalChart = new OrgChart();
54411
54478
  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
54479
  if (chartDirection == "top" || chartDirection == "bottom" || !chartDirection) {
@@ -54580,7 +54647,7 @@ const OrganizationChart = ({
54580
54647
  justify-content: center;
54581
54648
  align-items: center;
54582
54649
  text-align: center;
54583
- background-color: ${d.data.styleObject.color ? d.data.styleObject.color : d.data.styleObject.backgroundColor};
54650
+ background-color: ${chartFormatOptions.heatMap.showHeatMap ? heatMapScale(d.data.value) : chartFormatOptions.nodes.nodesSingleColor ? chartFormatOptions.nodes.nodesColor : d.data.styleObject.color};
54584
54651
  z-index: 99;
54585
54652
  transform: ${transform};
54586
54653
  transition: unset;">
@@ -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",
@@ -54275,6 +54275,12 @@
54275
54275
  let chartData = [];
54276
54276
  let scrollWidth = 0;
54277
54277
  let scrollHeight = 0;
54278
+ let legendListWidth;
54279
+ let displayedLegends = /* @__PURE__ */ new Map();
54280
+ let maxLegendDimensions;
54281
+ let maxMeasure = Number.NEGATIVE_INFINITY;
54282
+ let minMeasure = Number.POSITIVE_INFINITY;
54283
+ let heatMapScale;
54278
54284
  require$$0$1.useEffect(() => {
54279
54285
  drawChart();
54280
54286
  }, [chartId, data, formatOptions]);
@@ -54283,16 +54289,60 @@
54283
54289
  svgRef,
54284
54290
  formatOptions
54285
54291
  ));
54286
- ({ margins, chartTitleHeight, innerHeight, innerWidth } = marginCalculationsForChartsWithoutLegends(
54292
+ dataPreparation();
54293
+ maxLegendDimensions = calculateLegendsMaxPossibleWidth2(displayedLegends);
54294
+ ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } = marginCalculationsForChartsWithoutAxis(
54287
54295
  chartFormatOptions,
54296
+ width,
54288
54297
  height,
54289
- width
54298
+ maxLegendDimensions,
54299
+ margins
54290
54300
  ));
54291
54301
  initSvg(svgRef, width, height, chartFormatOptions);
54292
54302
  drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
54293
- dataPreparation();
54294
54303
  scrollWidthHeightCalculation();
54295
54304
  drawOrganizationChart(chartData);
54305
+ initLegendListForOrganizationChart();
54306
+ };
54307
+ const calculateLegendsMaxPossibleWidth2 = (displayedLegendsMap) => {
54308
+ const legends = [];
54309
+ displayedLegendsMap.forEach((_value, key) => {
54310
+ legends.push(key);
54311
+ });
54312
+ const longestLegend = legends.reduce((a2, b) => a2.length > b.length ? a2 : b, "");
54313
+ const legendDims = preCalculateTextDimensions(
54314
+ longestLegend,
54315
+ convertStringToNumber(chartFormatOptions.legends.legendFontSize),
54316
+ chartFormatOptions.legends.legendFontFamily
54317
+ );
54318
+ return [legendDims.width, legendDims.height];
54319
+ };
54320
+ const initLegendListForOrganizationChart = () => {
54321
+ let seriesData = [];
54322
+ displayedLegends.forEach((colors2, label) => {
54323
+ const color2 = `linear-gradient(90deg, ${colors2.join(", ")})`;
54324
+ seriesData.push({
54325
+ properties: {
54326
+ ...legendEntries[0],
54327
+ name: label,
54328
+ alias: label,
54329
+ color: color2
54330
+ }
54331
+ });
54332
+ });
54333
+ initLegendListWithTotalValueAllowance(
54334
+ chartFormatOptions,
54335
+ svg,
54336
+ seriesData,
54337
+ width,
54338
+ height,
54339
+ legendListWidth,
54340
+ chartTitleHeight,
54341
+ chartId,
54342
+ margins,
54343
+ staticLegendShape.rectangle,
54344
+ void 0
54345
+ );
54296
54346
  };
54297
54347
  const dataPreparation = () => {
54298
54348
  try {
@@ -54309,6 +54359,11 @@
54309
54359
  createIdIndexMap(tempData);
54310
54360
  generateUID(tempData);
54311
54361
  chartData = addStyleObjectToChartData(tempData);
54362
+ if (chartFormatOptions.heatMap.showHeatMap) {
54363
+ heatMapScale = sequential().domain([minMeasure, maxMeasure]).interpolator(
54364
+ interpolateRgb$1(chartFormatOptions.heatMap.heatMapMaxColor, chartFormatOptions.heatMap.heatMapMinColor)
54365
+ );
54366
+ }
54312
54367
  } catch (error) {
54313
54368
  logError$2(fileName$1, "dataPreparation", error);
54314
54369
  }
@@ -54365,11 +54420,22 @@
54365
54420
  indexMapForStyleObject.set(styleObject.name, styleObject);
54366
54421
  });
54367
54422
  Object.keys(data2).forEach((key) => {
54368
- const legendObject = indexMapForStyleObject.get(data2[key].UID ?? data2[key].nodeLabel);
54423
+ const nodeObj = data2[key];
54424
+ const legendObject = indexMapForStyleObject.get(nodeObj.UID ?? nodeObj.nodeLabel) ?? legendEntries[0];
54369
54425
  data2[key] = {
54370
- ...data2[key],
54371
- styleObject: legendObject || legendEntries[0]
54426
+ ...nodeObj,
54427
+ styleObject: legendObject
54372
54428
  };
54429
+ if (nodeObj.label) {
54430
+ if (displayedLegends.has(nodeObj.label)) {
54431
+ const colors2 = displayedLegends.get(nodeObj.label);
54432
+ displayedLegends.set(nodeObj.label, [...colors2, legendObject.color ?? "#eedddd"]);
54433
+ } else {
54434
+ displayedLegends.set(nodeObj.label, [legendObject.color ?? "#eedddd"]);
54435
+ }
54436
+ }
54437
+ maxMeasure = Math.max(maxMeasure, nodeObj.value);
54438
+ minMeasure = Math.min(minMeasure, nodeObj.value);
54373
54439
  });
54374
54440
  return data2;
54375
54441
  } catch (error) {
@@ -54410,6 +54476,7 @@
54410
54476
  let connectorVisibility = parseInt(
54411
54477
  chartFormatOptions.connector.connectorLineThickness
54412
54478
  );
54479
+ select$2(floatingSvgRef.current).selectAll("*").remove();
54413
54480
  let organizationalChart = new OrgChart();
54414
54481
  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
54482
  if (chartDirection == "top" || chartDirection == "bottom" || !chartDirection) {
@@ -54583,7 +54650,7 @@
54583
54650
  justify-content: center;
54584
54651
  align-items: center;
54585
54652
  text-align: center;
54586
- background-color: ${d.data.styleObject.color ? d.data.styleObject.color : d.data.styleObject.backgroundColor};
54653
+ background-color: ${chartFormatOptions.heatMap.showHeatMap ? heatMapScale(d.data.value) : chartFormatOptions.nodes.nodesSingleColor ? chartFormatOptions.nodes.nodesColor : d.data.styleObject.color};
54587
54654
  z-index: 99;
54588
54655
  transform: ${transform};
54589
54656
  transition: unset;">
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.65",
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",