@pipsend/charts 2.2.1 → 2.3.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.
package/README.md CHANGED
@@ -674,6 +674,34 @@ stopLoss.applyOptions({
674
674
  stopLoss.remove();
675
675
  ```
676
676
 
677
+ ### Position Lines
678
+
679
+ `createPositionLine` draws entry, take profit and stop loss as one unit: a
680
+ label per level carrying the size badge and the P&L, a close button, and a
681
+ connector tying the three together.
682
+
683
+ ```javascript
684
+ import { createPositionLine } from '@pipsend/charts';
685
+
686
+ const position = createPositionLine(series, chart, {
687
+ entry: { price: 4306.79, badge: '1', formatText: () => '+ 2.32 USD' },
688
+ takeProfit: { price: 4349.58, badge: '1', formatText: (p) => `+ ${(p - 4306.79).toFixed(2)} USD` },
689
+ stopLoss: { price: 4266.06, badge: '1', formatText: (p) => `- ${(4306.79 - p).toFixed(2)} USD` },
690
+ onDragEnd: (level, price) => updateOrderInBackend(level, price),
691
+ onClose: (level) => cancelOrder(level)
692
+ });
693
+
694
+ position.setPrice('takeProfit', 4360); // move a level
695
+ position.applyOptions({ stopLoss: undefined }); // drop a level
696
+ position.prices(); // { entry, takeProfit }
697
+ position.remove();
698
+ ```
699
+
700
+ Every level is draggable and closable by default; set `draggable: false` or
701
+ `closable: false` per level. The label's look is shared through `theme`
702
+ (`background`, `borderRadius`, `paddingX`, `fontSize`, …) and defaults to the
703
+ chart's own background, so it reads on light and dark themes alike.
704
+
677
705
  ---
678
706
 
679
707
  ## 🌐 Framework Integration Examples