@oliasoft-open-source/charts-library 4.3.12 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22516,6 +22516,18 @@ const DEFAULT_CHART_NAME = "new_chart";
22516
22516
  const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
22517
22517
  const DECIMAL_POINT_TOLERANCE = 9;
22518
22518
  const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
22519
+ const GRADIENT_COLORS = [
22520
+ { offset: 0, color: "rgba(144,238,144,0.8)" },
22521
+ // Light green
22522
+ { offset: 0.6, color: "rgba(255,255,224,0.8)" },
22523
+ // Light yellow
22524
+ { offset: 0.8, color: "rgba(255,255,224,0.8)" },
22525
+ // Light yellow
22526
+ { offset: 0.92, color: "rgba(255,182,193,0.5)" },
22527
+ // Light red
22528
+ { offset: 0.99, color: "rgba(255,182,193,0.8)" }
22529
+ // Light red
22530
+ ];
22519
22531
  const chartAreaBorderPlugin = {
22520
22532
  id: "chartAreaBorder",
22521
22533
  beforeDraw(chart2, _2, options) {
@@ -40312,7 +40324,9 @@ const useScatterChartConfig = (chart2, chartRef) => {
40312
40324
  onHover
40313
40325
  },
40314
40326
  scales: getScatterChartScales(chart2 == null ? void 0 : chart2.options),
40315
- animation: chartStyling.performanceMode ? false : {
40327
+ animation: chartStyling.performanceMode ? {
40328
+ duration: ANIMATION_DURATION.NO
40329
+ } : {
40316
40330
  duration: ANIMATION_DURATION.FAST,
40317
40331
  onComplete: interactions == null ? void 0 : interactions.onAnimationComplete
40318
40332
  },
@@ -40336,12 +40350,29 @@ const useScatterChartConfig = (chart2, chartRef) => {
40336
40350
  scatterOptions
40337
40351
  };
40338
40352
  };
40353
+ var GradientDirection = /* @__PURE__ */ ((GradientDirection2) => {
40354
+ GradientDirection2[GradientDirection2["TopToBottom"] = 0] = "TopToBottom";
40355
+ GradientDirection2[GradientDirection2["BottomToTop"] = 1] = "BottomToTop";
40356
+ GradientDirection2[GradientDirection2["LeftToRight"] = 2] = "LeftToRight";
40357
+ GradientDirection2[GradientDirection2["RightToLeft"] = 3] = "RightToLeft";
40358
+ GradientDirection2[GradientDirection2["TopLeftToBottomRight"] = 4] = "TopLeftToBottomRight";
40359
+ GradientDirection2[GradientDirection2["BottomRightToTopLeft"] = 5] = "BottomRightToTopLeft";
40360
+ GradientDirection2[GradientDirection2["BottomLeftToTopRight"] = 6] = "BottomLeftToTopRight";
40361
+ GradientDirection2[GradientDirection2["TopRightToBottomLeft"] = 7] = "TopRightToBottomLeft";
40362
+ return GradientDirection2;
40363
+ })(GradientDirection || {});
40364
+ const defaultChartGradient = (gradient) => ({
40365
+ display: (gradient == null ? void 0 : gradient.display) ?? false,
40366
+ gradientColors: (gradient == null ? void 0 : gradient.gradientColors) ?? GRADIENT_COLORS,
40367
+ direction: (gradient == null ? void 0 : gradient.direction) ?? GradientDirection.BottomLeftToTopRight
40368
+ });
40339
40369
  const defaultChartStyling = (styling) => ({
40340
40370
  width: (styling == null ? void 0 : styling.width) ?? AUTO,
40341
40371
  height: (styling == null ? void 0 : styling.height) ?? AUTO,
40342
40372
  maintainAspectRatio: (styling == null ? void 0 : styling.maintainAspectRatio) || false,
40343
40373
  staticChartHeight: (styling == null ? void 0 : styling.staticChartHeight) || false,
40344
- performanceMode: (styling == null ? void 0 : styling.performanceMode) ?? true
40374
+ performanceMode: (styling == null ? void 0 : styling.performanceMode) ?? true,
40375
+ gradient: defaultChartGradient(styling == null ? void 0 : styling.gradient)
40345
40376
  });
40346
40377
  const defaultTooltip = (tooltip) => ({
40347
40378
  enabled: (tooltip == null ? void 0 : tooltip.enabled) ?? true,
@@ -40421,6 +40452,57 @@ const getDefaultProps = (props) => {
40421
40452
  }
40422
40453
  };
40423
40454
  };
40455
+ const getGradientCoordinates = (direction, chartArea) => {
40456
+ switch (direction) {
40457
+ case GradientDirection.TopToBottom:
40458
+ return [chartArea.left, chartArea.top, chartArea.left, chartArea.bottom];
40459
+ case GradientDirection.BottomToTop:
40460
+ return [chartArea.left, chartArea.bottom, chartArea.left, chartArea.top];
40461
+ case GradientDirection.LeftToRight:
40462
+ return [chartArea.left, chartArea.top, chartArea.right, chartArea.top];
40463
+ case GradientDirection.RightToLeft:
40464
+ return [chartArea.right, chartArea.top, chartArea.left, chartArea.top];
40465
+ case GradientDirection.TopLeftToBottomRight:
40466
+ return [chartArea.left, chartArea.top, chartArea.right, chartArea.bottom];
40467
+ case GradientDirection.BottomRightToTopLeft:
40468
+ return [chartArea.right, chartArea.bottom, chartArea.left, chartArea.top];
40469
+ case GradientDirection.BottomLeftToTopRight:
40470
+ return [chartArea.left, chartArea.bottom, chartArea.right, chartArea.top];
40471
+ case GradientDirection.TopRightToBottomLeft:
40472
+ return [chartArea.right, chartArea.top, chartArea.left, chartArea.bottom];
40473
+ default:
40474
+ return [chartArea.left, chartArea.bottom, chartArea.right, chartArea.top];
40475
+ }
40476
+ };
40477
+ const gradientBackgroundPlugin = {
40478
+ id: "gradientBackgroundPlugin",
40479
+ beforeDraw: (chart2) => {
40480
+ const { ctx, chartArea, options } = chart2;
40481
+ const gradientOptions = options.gradient;
40482
+ const {
40483
+ display = false,
40484
+ gradientColors,
40485
+ direction = GradientDirection.BottomLeftToTopRight
40486
+ } = gradientOptions ?? {};
40487
+ if (!display || !gradientColors || gradientColors.length === 0)
40488
+ return;
40489
+ const [x0, y0, x1, y1] = getGradientCoordinates(direction, chartArea);
40490
+ const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
40491
+ gradientColors.forEach(({ offset, color: color2 }) => {
40492
+ gradient.addColorStop(offset, color2);
40493
+ });
40494
+ ctx.save();
40495
+ ctx.globalCompositeOperation = "destination-over";
40496
+ ctx.fillStyle = gradient;
40497
+ ctx.fillRect(
40498
+ chartArea.left,
40499
+ chartArea.top,
40500
+ chartArea.right - chartArea.left,
40501
+ chartArea.bottom - chartArea.top
40502
+ );
40503
+ ctx.restore();
40504
+ }
40505
+ };
40424
40506
  const chart = "_chart_1jdnu_1";
40425
40507
  const fixedHeight = "_fixedHeight_1jdnu_13";
40426
40508
  const stretchHeight = "_stretchHeight_1jdnu_19";
@@ -40446,7 +40528,8 @@ Chart$2.register(
40446
40528
  plugin_title,
40447
40529
  plugin$1,
40448
40530
  plugin,
40449
- annotation
40531
+ annotation,
40532
+ gradientBackgroundPlugin
40450
40533
  );
40451
40534
  const ScatterChart = (props) => {
40452
40535
  setDefaultTheme();