react-klinecharts-ui 0.4.0 → 0.6.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.
@@ -931,18 +931,14 @@ var ray = {
931
931
  needDefaultYAxisFigure: true,
932
932
  createPointFigures: ({ coordinates, bounding }) => {
933
933
  if (coordinates.length > 1) {
934
- let coordinate = { x: 0, y: 0 };
935
- if (coordinates[0].x === coordinates[1].x && coordinates[0].y !== coordinates[1].y) {
936
- if (coordinates[0].y < coordinates[1].y) {
937
- coordinate = { x: coordinates[0].x, y: bounding.height };
938
- } else {
939
- coordinate = { x: coordinates[0].x, y: 0 };
934
+ const coordinate = (() => {
935
+ if (coordinates[0].x === coordinates[1].x && coordinates[0].y !== coordinates[1].y) {
936
+ return coordinates[0].y < coordinates[1].y ? { x: coordinates[0].x, y: bounding.height } : { x: coordinates[0].x, y: 0 };
940
937
  }
941
- } else {
942
938
  const x = coordinates[0].x < coordinates[1].x ? bounding.width : 0;
943
939
  const y = (coordinates[1].y - coordinates[0].y) / (coordinates[1].x - coordinates[0].x) * (x - coordinates[0].x) + coordinates[0].y;
944
- coordinate = { x, y };
945
- }
940
+ return { x, y };
941
+ })();
946
942
  return [
947
943
  {
948
944
  type: "line",
@@ -1952,14 +1948,7 @@ var macdTv = {
1952
1948
  styles: (data) => {
1953
1949
  const current = data.current?.histogram ?? 0;
1954
1950
  const pre = data.prev?.histogram ?? 0;
1955
- let color = "#26A69A";
1956
- if (current > 0) {
1957
- color = current > pre ? "#26A69A" : "#B2DFDB";
1958
- } else if (current < 0) {
1959
- color = current < pre ? "#FF5252" : "#FFCDD2";
1960
- } else {
1961
- color = "#B2DFDB";
1962
- }
1951
+ const color = current > 0 ? current > pre ? "#26A69A" : "#B2DFDB" : current < 0 ? current < pre ? "#FF5252" : "#FFCDD2" : "#B2DFDB";
1963
1952
  return { color };
1964
1953
  }
1965
1954
  },
@@ -2454,19 +2443,134 @@ var depthOverlay = {
2454
2443
  };
2455
2444
  var depthOverlay_default = depthOverlay;
2456
2445
 
2446
+ // src/extensions/overlays/alertLine.ts
2447
+ var DEFAULT_FONT_FAMILY2 = "Helvetica Neue, Arial, sans-serif";
2448
+ var DEFAULT_COLOR = "#ff9800";
2449
+ var BELL_MARK = "\u{1F514}";
2450
+ var alertLine = {
2451
+ name: "alertLine",
2452
+ totalStep: 2,
2453
+ needDefaultPointFigure: false,
2454
+ needDefaultXAxisFigure: false,
2455
+ needDefaultYAxisFigure: false,
2456
+ createYAxisFigures: ({ chart, overlay, coordinates }) => {
2457
+ if (coordinates.length < 1) return [];
2458
+ const y = coordinates[0].y;
2459
+ const price = overlay.points[0]?.value;
2460
+ if (price == null) return [];
2461
+ const d = overlay.extendData ?? {};
2462
+ const color = d.color ?? DEFAULT_COLOR;
2463
+ const m = d.mark;
2464
+ const precision = chart.getSymbol()?.pricePrecision ?? 2;
2465
+ return [
2466
+ {
2467
+ type: "text",
2468
+ attrs: {
2469
+ x: 0,
2470
+ y,
2471
+ text: price.toFixed(precision),
2472
+ align: "left",
2473
+ baseline: "middle"
2474
+ },
2475
+ styles: {
2476
+ color: m?.color ?? "#ffffff",
2477
+ size: m?.font?.size ?? 11,
2478
+ family: m?.font?.family ?? DEFAULT_FONT_FAMILY2,
2479
+ weight: m?.font?.weight ?? "bold",
2480
+ paddingLeft: m?.padding?.x ?? 4,
2481
+ paddingRight: m?.padding?.x ?? 4,
2482
+ paddingTop: m?.padding?.y ?? 4,
2483
+ paddingBottom: m?.padding?.y ?? 4,
2484
+ backgroundColor: m?.bg ?? color,
2485
+ borderRadius: m?.borderRadius ?? 2
2486
+ }
2487
+ }
2488
+ ];
2489
+ },
2490
+ createPointFigures: ({ chart, coordinates, bounding, overlay }) => {
2491
+ if (coordinates.length < 1) return [];
2492
+ const y = coordinates[0].y;
2493
+ const d = overlay.extendData ?? {};
2494
+ const color = d.color ?? DEFAULT_COLOR;
2495
+ const ln = d.line;
2496
+ const figures = [
2497
+ {
2498
+ type: "line",
2499
+ attrs: {
2500
+ coordinates: [
2501
+ { x: 0, y },
2502
+ { x: bounding.width, y }
2503
+ ]
2504
+ },
2505
+ styles: {
2506
+ style: ln?.style ?? "dashed",
2507
+ color,
2508
+ size: ln?.width ?? 1,
2509
+ dashedValue: ln?.dashedValue ?? [4, 2]
2510
+ }
2511
+ }
2512
+ ];
2513
+ const price = overlay.points[0]?.value;
2514
+ const precision = chart.getSymbol()?.pricePrecision ?? 2;
2515
+ const baseText = d.text ?? (price != null ? price.toFixed(precision) : "");
2516
+ const showBell = d.showBell ?? true;
2517
+ const text = baseText ? showBell ? `${BELL_MARK} ${baseText}` : baseText : showBell ? BELL_MARK : "";
2518
+ if (text) {
2519
+ const lb = d.label;
2520
+ figures.push({
2521
+ type: "text",
2522
+ ignoreEvent: true,
2523
+ attrs: {
2524
+ x: lb?.offset?.x ?? 8,
2525
+ y: y - (lb?.offset?.y ?? 3),
2526
+ text,
2527
+ align: "left",
2528
+ baseline: "bottom"
2529
+ },
2530
+ styles: {
2531
+ color: lb?.color ?? color,
2532
+ size: lb?.font?.size ?? 11,
2533
+ family: lb?.font?.family ?? DEFAULT_FONT_FAMILY2,
2534
+ weight: lb?.font?.weight ?? "normal",
2535
+ paddingLeft: lb?.padding?.x ?? 0,
2536
+ paddingRight: lb?.padding?.x ?? 0,
2537
+ paddingTop: lb?.padding?.y ?? 0,
2538
+ paddingBottom: lb?.padding?.y ?? 0,
2539
+ backgroundColor: lb?.bg ?? "transparent",
2540
+ borderRadius: lb?.borderRadius ?? 0
2541
+ }
2542
+ });
2543
+ }
2544
+ return figures;
2545
+ },
2546
+ performEventPressedMove: ({ points, performPoint }) => {
2547
+ points[0].value = performPoint.value;
2548
+ }
2549
+ };
2550
+ var alertLine_default = alertLine;
2551
+
2457
2552
  // src/extensions/index.ts
2458
2553
  var overlays = Object.values(overlays_exports);
2554
+ var featureOverlays = [orderLine_default, depthOverlay_default, alertLine_default];
2459
2555
  var indicators = Object.values(indicators_exports);
2460
2556
  var registered = false;
2461
2557
  function registerExtensions() {
2462
2558
  if (registered) return;
2463
2559
  overlays.forEach((overlay) => reactKlinecharts.registerOverlay(overlay));
2560
+ featureOverlays.forEach((overlay) => reactKlinecharts.registerOverlay(overlay));
2464
2561
  indicators.forEach((indicator) => reactKlinecharts.registerIndicator(indicator));
2465
2562
  registered = true;
2466
2563
  }
2564
+ var alertLineRegistered = false;
2565
+ function ensureAlertLineRegistered() {
2566
+ if (alertLineRegistered) return;
2567
+ reactKlinecharts.registerOverlay(alertLine_default);
2568
+ alertLineRegistered = true;
2569
+ }
2467
2570
 
2468
2571
  exports.TA_default = TA_default;
2469
2572
  exports.abcd_default = abcd_default;
2573
+ exports.alertLine_default = alertLine_default;
2470
2574
  exports.anyWaves_default = anyWaves_default;
2471
2575
  exports.arrow_default = arrow_default;
2472
2576
  exports.bollTv_default = bollTv_default;
@@ -2476,6 +2580,8 @@ exports.circle_default = circle_default;
2476
2580
  exports.depthOverlay_default = depthOverlay_default;
2477
2581
  exports.eightWaves_default = eightWaves_default;
2478
2582
  exports.elliottWave_default = elliottWave_default;
2583
+ exports.ensureAlertLineRegistered = ensureAlertLineRegistered;
2584
+ exports.featureOverlays = featureOverlays;
2479
2585
  exports.fibRetracement_default = fibRetracement_default;
2480
2586
  exports.fibonacciCircle_default = fibonacciCircle_default;
2481
2587
  exports.fibonacciExtension_default = fibonacciExtension_default;
@@ -2508,5 +2614,5 @@ exports.threeWaves_default = threeWaves_default;
2508
2614
  exports.triangle_default = triangle_default;
2509
2615
  exports.vwap_default = vwap_default;
2510
2616
  exports.xabcd_default = xabcd_default;
2511
- //# sourceMappingURL=chunk-PIFLJKYF.cjs.map
2512
- //# sourceMappingURL=chunk-PIFLJKYF.cjs.map
2617
+ //# sourceMappingURL=chunk-FSHI2ZDB.cjs.map
2618
+ //# sourceMappingURL=chunk-FSHI2ZDB.cjs.map