diff --git a/.jazzy.yaml b/.jazzy.yaml index cd39ab1..2922c7c 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -139,6 +139,9 @@ custom_categories: - Interactivity - SCISeriesSelectionModifier - Legend Modifier - Series Value Modifier + - Trading Annotation - SCIPitchforkCreationModifier + - Trading Annotation - SCIXabcdCreationModifier + - Trading Annotation - SCIFreehandDrawingModifier - name: Annotations APIs children: @@ -154,6 +157,10 @@ custom_categories: - AxisMarkerCustomAnnotation - CustomAnnotation - CustomGrip + - CompositeAnnotation + - PitchforkAnnotation + - XabcdAnnotation + - FreehandDrawingAnnotation # - name: Advanced 2D chart Topics # children: @@ -472,6 +479,9 @@ custom_categories: - SCIAxisDragModifierBase - SCIXAxisDragModifier - SCIYAxisDragModifier + - SCIPitchforkCreationModifier + - SCIXabcdCreationModifier + - SCIFreehandDrawingModifier # Series Value Modifier - ISCISeriesValueMarker @@ -684,6 +694,17 @@ custom_categories: - SCIAxisMarkerAnnotation - SCIAxisMarkerCustomAnnotation + # Trading Annotations + - ISCITradingAnnotation + - SCITradingAnnotationBase + - SCIElliotWaveAnnotationBase + - ISCIPolyLineAnnotation + - SCIPolyLineAnnotation + - SCICompositeAnnotation + - SCIXabcdAnnotation + - SCIPitchforkAnnotation + - SCIFreehandDrawingAnnotation + - ISCIAnnotationDragListener - SCIAnnotationIsHiddenChangedListener - SCIAnnotationSelectionChangedListener diff --git a/guides/Annotations API/CompositeAnnotation.md b/guides/Annotations API/CompositeAnnotation.md new file mode 100644 index 0000000..27208d2 --- /dev/null +++ b/guides/Annotations API/CompositeAnnotation.md @@ -0,0 +1,173 @@ +# The CompositeAnnotation +A `SCICompositeAnnotation` is a container annotation specific `X1, X2, Y1, Y2` coordinates that allows you to group multiple child annotations and render them as a single logical unit on an SCIChartSurface. Each child annotation can use relative coordinate space (0–1) within the composite bounds, enabling scalable and reusable annotation layouts. +It inherits from SCIBoxAnnotation, meaning it also provides a resizable, draggable rectangular boundary that defines the coordinate space for its children. + +![Composite Annotation](img/annotations/composite-annotation.png) + +> **_NOTE:_** Examples of the **`Annotations`** usage can be found in the [SciChart iOS Examples Suite](https://www.scichart.com/examples/ios-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.iOS.Examples): +> +> - Composite Annotation - [Obj-C/Swift](https://www.scichart.com/example/ios-chart-chart-composite-annotations-example/) ̰ + +The `SCICompositeAnnotation` class provides the `SCICompositeAnnotation.borderPen` and `SCICompositeAnnotation.fillBrush` properties, which are used for the annotation outline and background and expects the `SCIPenStyle` and `SCIBrushStyle` correspondingly. +To learn more about **Pens** and **Brushes** and how to utilize them, please refer to the [SCIPenStyle, SCIBrushStyle and SCIFontStyle](scipenstyle-scibrushstyle-and-scifontstyle.html) article. + +> **_NOTE:_** To learn more about **Annotations** in general - please see the [Common Annotation Features](Annotations APIs.html#common-annotations-features) article. + +A `SCICompositeAnnotation` is placed on a chart at the position determined by its `[X1, Y1]` and `[X2, Y2]` coordinates, which correspond to the **top-left** and **bottom-right** corners of the drawn rectangle. +Those can be accessed via the following properties: +- `ISCIAnnotation.x1` +- `ISCIAnnotation.y1` +- `ISCIAnnotation.x2` +- `ISCIAnnotation.y2` + +> **_NOTE:_** The **xAxisId** and **yAxisId** must be supplied if you have axis with **non-default** Axis Ids, e.g. in **multi-axis** scenario. + +## Create a CompositeAnnotation +A `SCICompositeAnnotation` can be added onto a chart using the following code: + +
+ + +
+
+ // Assume a surface has been created and configured somewhere +id surface = self.surface; + +// Create a CompositeAnnotation +SCICompositeAnnotation *compositeAnnotation = [SCICompositeAnnotation new]; + +// Allow interaction at runtime +compositeAnnotation.isEditable = YES; + +// In multi-axis scenario, specify axis IDs +compositeAnnotation.xAxisId = TopAxisId; +compositeAnnotation.yAxisId = LeftAxisId; + +// Parent bounding box (chart coordinates) +// Defines the area where all child annotations live +[compositeAnnotation setX1:@(185.0)]; +[compositeAnnotation setY1:@(12300.0)]; +[compositeAnnotation setX2:@(210.0)]; +[compositeAnnotation setY2:@(11100.0)]; + +// Fill color for composite background +compositeAnnotation.fillBrush = [[SCISolidBrushStyle alloc] initWithColorCode:0x33FF69BD]; + +// Optional: border styling (inherits from SCIBoxAnnotation) +compositeAnnotation.borderPen = [[SCISolidPenStyle alloc] initWithColorCode:0x99FF69BD thickness:2]; + + +// Child Annotations (RELATIVE SPACE) + +// Center Text Annotation +SCITextAnnotation *textAnnotationCenter = [SCITextAnnotation new]; + +// IMPORTANT: relative coordinate system (0 → 1 inside composite) +textAnnotationCenter.coordinateMode = SCIAnnotationCoordinateMode_Relative; + +// Position at center of composite +[textAnnotationCenter setX1:@(0.5)]; +[textAnnotationCenter setY1:@(0.5)]; + +textAnnotationCenter.text = @"Center\n(0.5, 0.5)"; +textAnnotationCenter.fontStyle = [[SCIFontStyle alloc] initWithFontSize:14 andTextColor:SCIColor.whiteColor]; + + +// Diagonal Line Annotation +SCILineAnnotation *lineAnnotation = [SCILineAnnotation new]; + +// Relative coordinates inside composite bounds +lineAnnotation.coordinateMode = SCIAnnotationCoordinateMode_Relative; + +// Draw diagonal line +[lineAnnotation setX1:@(0.2)]; +[lineAnnotation setY1:@(0.2)]; +[lineAnnotation setX2:@(0.8)]; +[lineAnnotation setY2:@(0.8)]; + +lineAnnotation.stroke = + [[SCISolidPenStyle alloc] initWithColor:SCIColor.whiteColor thickness:2]; + + +// Add child annotations to composite +compositeAnnotation.annotations = + [[SCIAnnotationCollection alloc] initWithCollection:@[ + textAnnotationCenter, + lineAnnotation + ]]; + + +// Add composite annotation to surface +[self.surface.annotations add:compositeAnnotation]; +
+
+// Assume a surface has been created and configured somewhere +let surface: ISCIChartSurface + +// Create a CompositeAnnotation +let compositeAnnotation = SCICompositeAnnotation() + +// Allow to interact with the annotation in run-time +compositeAnnotation.isEditable = true + +// In a multi-axis scenario, specify the XAxisId and YAxisId +compositeAnnotation.xAxisId = "TopAxisId" +compositeAnnotation.yAxisId = "LeftAxisId" + +// Specify a desired position by setting coordinates (parent bounding box) +// This defines the area in chart coordinates where all child annotations will live +compositeAnnotation.set(x1: 185.0) +compositeAnnotation.set(y1: 12300.0) +compositeAnnotation.set(x2: 210.0) +compositeAnnotation.set(y2: 11100.0) + +// Specify the fill color for the composite container (background box) +compositeAnnotation.fillBrush = SCISolidBrushStyle(color: 0x33FF69BD) + +// Optionally: border styling (since it inherits from SCIBoxAnnotation) +compositeAnnotation.borderPen = SCISolidPenStyle(color: 0x99FF69BD, thickness: 2) + + +// Child Annotations (ALL use relative coordinate space) + +// Center Text Annotation +let textAnnotationCenter = SCITextAnnotation() + +// IMPORTANT: child annotations use relative coordinates (0 → 1) +textAnnotationCenter.coordinateMode = .relative + +// Position inside composite (center) +textAnnotationCenter.set(x1: 0.5) +textAnnotationCenter.set(y1: 0.5) + +textAnnotationCenter.text = "Center\n(0.5, 0.5)" +textAnnotationCenter.fontStyle = SCIFontStyle(fontSize: 14, andTextColor: SCIColor.white) + + +// Diagonal Line Annotation +let lineAnnotation = SCILineAnnotation() + +// Relative coordinates inside composite bounds +lineAnnotation.coordinateMode = .relative + +// Draw a diagonal line across the composite area +lineAnnotation.set(x1: 0.2) +lineAnnotation.set(y1: 0.2) +lineAnnotation.set(x2: 0.8) +lineAnnotation.set(y2: 0.8) + +lineAnnotation.stroke = SCISolidPenStyle(color: SCIColor.white, thickness: 2) + + +// Add child annotations to composite +compositeAnnotation.annotations = + SCIAnnotationCollection(collection: [ + textAnnotationCenter, + lineAnnotation +]) + + +// Add composite to surface +self.surface.annotations.add(items: compositeAnnotation) +
+> **_NOTE:_** To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](Annotations APIs.html) article. diff --git a/guides/Annotations API/FreehandDrawingAnnotation.md b/guides/Annotations API/FreehandDrawingAnnotation.md new file mode 100644 index 0000000..3239551 --- /dev/null +++ b/guides/Annotations API/FreehandDrawingAnnotation.md @@ -0,0 +1,82 @@ +# The SCIFreehandDrawingAnnotation +he `SCIFreehandDrawingAnnotation` allows for freehand drawing directly on the chart surface by capturing a sequence of points that form a continuous brush stroke. + +![Freehand Drawing Annotation](img/annotations/freehand-drawing-annotation.png) + +> **_NOTE:_** Examples of the **`Annotations`** usage can be found in the [SciChart iOS Examples Suite](https://www.scichart.com/examples/ios-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.iOS.Examples): +> +> - Freehand Drawing Annotation - [Obj-C/Swift](https://www.scichart.com/example/ios-chart-chart-freehand-drawing-annotations-example/) ̰ + +A `SCIFreehandDrawingAnnotation` is a multi-point annotation that stores a collection of points to represent a freehand path drawn by the user. + +The SCIFreehandDrawingAnnotation can be configured using the properties and method listed in the table below: + +| **Field** | **Description** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `SCIFreehandDrawingAnnotation.stroke` | Defines the stroke style (color and thickness) of the pen. | +| `SCIFreehandDrawingAnnotation.drawId` | A unique identifier for the annotation instance. | +| `SCIFreehandDrawingAnnotation.selectionOffset` | Extra padding applied around the selection bounds. | + +To learn more about **Pens** and **Brushes** and how to utilize them, please refer to the [SCIPenStyle, SCIBrushStyle](scipenstyle-scibrushstyle-and-scifontstyle.html) article. + +> **_NOTE:_** To learn more about **Annotations** in general - please see the [Common Annotation Features](Annotations APIs.html#common-annotations-features) article. + +## Adding Points +Points for a `SCIFreehandDrawingAnnotation` are defined sequentially using the `[appendPointWithX:y:]` method, which appends each new coordinate to the existing path to form a continuous freehand stroke. +The `clearPoints` method can be used to remove all previously added points, resetting the annotation so that it no longer renders until new points are appended. + +> **_NOTE:_** The **xAxisId** and **yAxisId** must be supplied if you have axis with **non-default** Axis Ids, e.g. in **multi-axis** scenario. + +## Create a FreehandDrawingAnnotation +A `SCIFreehandDrawingAnnotation` can be added onto a chart using the following code: + +
+ + +
+
+// Assume a surface has been created and configured somewhere +id surface; + +SCIFreehandDrawingAnnotation *freehandDrawing = [SCIFreehandDrawingAnnotation new]; + +// Append points for the path +[freehandDrawing appendPointWithX:@(224) y:@(11000)]; +[freehandDrawing appendPointWithX:@(250) y:@(12000)]; +[freehandDrawing appendPointWithX:@(220) y:@(11400)]; +[freehandDrawing appendPointWithX:@(224) y:@(11000)]; + +// Customize appearance +freehandDrawing.stroke = [[SCISolidPenStyle alloc] initWithColorCode:0xFFFF0000 thickness:3]; + +// Enable interaction +freehandDrawing.isEditable = YES; + +// Add to chart surface +[surface.annotations add: freehandDrawing]; +
+
+// Assume a surface has been created and configured somewhere +let surface: ISCIChartSurface + +let freehandDrawing = SCIFreehandDrawingAnnotation() + +// Append points for the path +freehandDrawing.appendPointWith(x: NSNumber(value: 224), y: NSNumber(value: 11000)) +freehandDrawing.appendPointWith(x: NSNumber(value: 250), y: NSNumber(value: 12000)) +freehandDrawing.appendPointWith(x: NSNumber(value: 220), y: NSNumber(value: 11400)) +freehandDrawing.appendPointWith(x: NSNumber(value: 224), y: NSNumber(value: 11000)) + +// Customize appearance +freehandDrawing.stroke = SCISolidPenStyle(color: SCIColor.red, thickness: 3) + +// Enable interaction +freehandDrawing.isEditable = true + +// Add to chart surface +surface.annotations.add(freehandDrawing) +
+ +> **_NOTE:_** For interactive creation of SCIFreehandDrawingAnnotation, use the corresponding annotation creation modifier [SCIFreehandDrawingModifier](trading-annotation---sciFreehandDrawingModifier.html) available in SciChart iOS. + +> **_NOTE:_** To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](Annotations APIs.html) article. diff --git a/guides/Annotations API/PitchforkAnnotation.md b/guides/Annotations API/PitchforkAnnotation.md new file mode 100644 index 0000000..2683d53 --- /dev/null +++ b/guides/Annotations API/PitchforkAnnotation.md @@ -0,0 +1,90 @@ +# The SCIPitchforkAnnotation +The `SCIPitchforkAnnotation` (also known as Andrew’s Pitchfork) is a specialized trading annotation for iOS charts that uses three points to visualize potential support and resistance levels. It consists of a median line and two parallel outer lines (tines), forming a "pitchfork" shape. It supports interactive grips for dragging, polygon fills for highlighting regions, and customizable stroke/fill styles. + +![Pitchfork Annotation](img/annotations/pitchfork-annotation.png) + +> **_NOTE:_** Examples of the **`Annotations`** usage can be found in the [SciChart iOS Examples Suite](https://www.scichart.com/examples/ios-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.iOS.Examples): +> +> - Composite Annotation - [Obj-C/Swift](https://www.scichart.com/example/ios-chart-chart-composite-annotations-example/) ̰ + +## Structure and Points +The SCIPitchforkAnnotation is defined by three base points: +- Point 0 (Handle / Pivot): The starting point of the median line. +- Point 1 (Upper): The first point defining the outer boundary. +- Point 2 (Lower): The second point defining the outer boundary. + +## Behavior +- The median line begins at Point 0 and passes through the midpoint between Point 1 and Point 2. +- Two additional lines (tines) are drawn parallel to the median line, originating from Point 1 and Point 2. +- The space between these lines can be filled to highlight trading zones. + +The SCIPitchforkAnnotation can be configured using the properties and method listed in the table below: + +| **Field** | **Description** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `SCIPitchforkAnnotation.tineStroke` | Defines the SCIPenStyle used to draw the pitchfork lines (outer 4 tines). | +| `SCIPitchforkAnnotation.halfWidthZoneFill` | Defines the SCIBrushStyle used to fill the central region around the median line. | +| `SCIPitchforkAnnotation.fullWidthZoneFill` | Defines the SCIBrushStyle used to fill the outer regions on either side. | + + +To learn more about **Pens** and **Brushes** and how to utilize them, please refer to the [SCIPenStyle, SCIBrushStyle](scipenstyle-scibrushstyle-and-scifontstyle.html) article. + +> **_NOTE:_** To learn more about **Annotations** in general - please see the [Common Annotation Features](Annotations APIs.html#common-annotations-features) article. + +Points for a `SCIPitchforkAnnotation` are defined sequentially using the setBasePointWithX(:y) method. The median line is drawn from the first point through the midpoint between the second and third points. Two additional parallel lines (tines) extend from the second and third points, forming the characteristic pitchfork structure. + +> **_NOTE:_** The **xAxisId** and **yAxisId** must be supplied if you have axis with **non-default** Axis Ids, e.g. in **multi-axis** scenario. + +## Create a PitchforkAnnotation +A `SCIPitchforkAnnotation` can be added onto a chart using the following code: + +
+ + +
+
+// Assume a surface has been created and configured somewhere +id surface; + +SCIPitchforkAnnotation *pitchfork = [[SCIPitchforkAnnotation alloc] init]; + +// Define base points (pivot, upper, lower) +[pitchfork setBasePointWithX:@224 y:@11000]; +[pitchfork setBasePointWithX:@250 y:@11300]; +[pitchfork setBasePointWithX:@228 y:@11600]; + +// Customize appearance +pitchfork.halfWidthZoneFill = [[SCISolidBrushStyle alloc] initWithColorCode:0x401E90FF]; +pitchfork.fullWidthZoneFill = [[SCISolidBrushStyle alloc] initWithColorCode:0x4000AA00]; + +// Enable interaction +pitchfork.isEditable = YES; + +// Add to chart surface +[surface.annotations add: pitchfork]; +
+
+// Assume a surface has been created and configured somewhere +let surface: ISCIChartSurface + +let pitchfork = SCIPitchforkAnnotation() + +// Define base points (pivot, upper, lower) +pitchfork.setBasePointWithX(NSNumber(value: 224), y: NSNumber(value: 11000)) +pitchfork.setBasePointWithX(NSNumber(value: 250), y: NSNumber(value: 11300)) +pitchfork.setBasePointWithX(NSNumber(value: 228), y: NSNumber(value: 11600)) + +// Customize appearance +pitchfork.halfWidthZoneFill = SCISolidBrushStyle(color: 0x401E90FF) +pitchfork.fullWidthZoneFill = SCISolidBrushStyle(color: 0x4000AA00) + +// Enable interaction +pitchfork.isEditable = true + +// Add to chart surface +surface.annotations.add(pitchfork) +
+ +> **_NOTE:_** For interactive creation of SCIPitchforkAnnotation, use the corresponding annotation creation modifier [SCIPitchforkCreationModifier](trading-annotation---scipitchforkcreationmodifier.html) available in SciChart iOS. + +> **_NOTE:_** To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](Annotations APIs.html) article. diff --git a/guides/Annotations API/XabcdAnnotation.md b/guides/Annotations API/XabcdAnnotation.md new file mode 100644 index 0000000..5bc5928 --- /dev/null +++ b/guides/Annotations API/XabcdAnnotation.md @@ -0,0 +1,103 @@ +# The SCIXabcdAnnotation +The SCIXabcdAnnotation is a specialized multi-point trading annotation used to draw harmonic patterns such as Gartley, Butterfly, Bat, and Crab. These patterns consist of five key points: X, A, B, C, and D, which help identify potential reversal zones in financial charts. + +![Xabcd Annotation](img/annotations/xabcd-annotation.png) + +> **_NOTE:_** Examples of the **`Annotations`** usage can be found in the [SciChart iOS Examples Suite](https://www.scichart.com/examples/ios-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.iOS.Examples): +> +> - Xabcd Annotation - [Obj-C/Swift](https://www.scichart.com/example/ios-chart-chart-trading-annotations-example/) ̰ + +The `SCICompositeAnnotation` class provides the `SCICompositeAnnotation.borderPen` and `SCICompositeAnnotation.fillBrush` properties, which are used for the annotation outline and background and expects the `SCIPenStyle` and `SCIBrushStyle` correspondingly. +To learn more about **Pens** and **Brushes** and how to utilize them, please refer to the [SCIPenStyle, SCIBrushStyle and SCIFontStyle](scipenstyle-scibrushstyle-and-scifontstyle.html) article. + +> **_NOTE:_** To learn more about **Annotations** in general - please see the [Common Annotation Features](Annotations APIs.html#common-annotations-features) article. + +## Structure and Points +The SCIXabcdAnnotation is defined by five base points, added sequentially using the setBasePointWithX(:y) method: +- Point 0 (X): Starting point of the pattern +- Point 1 (A): First leg of the pattern +- Point 2 (B): Retracement from A +- Point 3 (C): Extension from B +- Point 4 (D): Final point completing the harmonic structure +kDPointIndex = 4 indicates the index of the final D point. + +## Behavior +- Lines are drawn between XA, AB, BC, and CD. +- Additional helper (often dashed) lines may connect XB, AC, BD, and XD. +- Two filled regions are typically formed: + * Triangle XAB + * Triangle BCD + +The SCIPitchforkAnnotation can be configured using the properties and method listed in the table below: + +| **Field** | **Description** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `SCIXabcdAnnotation.showRatios` | Determines whether calculated harmonic ratios are displayed on the chart. | + + +## Define Points +Points are added sequentially using `[annotation setBasePointWithX: y:];`. Each call adds the next point in order (X → A → B → C → D). +The annotation is fully formed once all five points are provided. + + +> **_NOTE:_** The **xAxisId** and **yAxisId** must be supplied if you have axis with **non-default** Axis Ids, e.g. in **multi-axis** scenario. + +## Create a XabcdAnnotation +A `SCIXabcdAnnotation` can be added onto a chart using the following code: + +
+ + +
+
+// Assume a surface has been created and configured somewhere +id surface = self.surface; + +SCIXabcdAnnotation *xAbcdAnn = [[SCIXabcdAnnotation alloc] init]; + +// Define points (X, A, B, C, D) +[xAbcdAnn setBasePointWithX:@224 y:@7]; // X +[xAbcdAnn setBasePointWithX:@230 y:@4]; // A +[xAbcdAnn setBasePointWithX:@235 y:@5]; // B +[xAbcdAnn setBasePointWithX:@240 y:@6]; // C +[xAbcdAnn setBasePointWithX:@245 y:@7]; // D + +// Customize appearance +xAbcdAnn.fillBrush = [[SCISolidBrushStyle alloc] initWithColorCode:0x55AAAA00]; +xAbcdAnn.stroke = [[SCISolidPenStyle alloc] initWithColorCode:0xFFe97064 thickness:2.0]; + +// Enable interaction and ratios +xAbcdAnn.isEditable = YES; +xAbcdAnn.showRatios = YES; + +// Add to chart surface +[self.surface.annotations add:xAbcdAnn]; +
+
+// Assume a surface has been created and configured somewhere +let surface: ISCIChartSurface + +let xAbcdAnn = SCIXabcdAnnotation() + +// Add points +xAbcdAnn.setBasePointWithX(NSNumber(value: 224), y: NSNumber(value: 7)) // X +xAbcdAnn.setBasePointWithX(NSNumber(value: 230), y: NSNumber(value: 4)) // A +xAbcdAnn.setBasePointWithX(NSNumber(value: 235), y: NSNumber(value: 5)) // B +xAbcdAnn.setBasePointWithX(NSNumber(value: 240), y: NSNumber(value: 6)) // C +xAbcdAnn.setBasePointWithX(NSNumber(value: 245), y: NSNumber(value: 7)) // D + +// Customize appearance +xAbcdAnn.fillBrush = SCISolidBrushStyle(color: 0x55AAAA00) +xAbcdAnn.stroke = SCISolidPenStyle(color: 0xFFe97064, thickness: 2) + +// Enable interaction and ratios +xAbcdAnn.isEditable = true +xAbcdAnn.showRatios = true + +// Add to chart surface +self.surface.annotations.add(items: xAbcdAnn) +
+ +> **_NOTE:_** For interactive creation of SCIPitchforkAnnotation, use the corresponding annotation creation modifier [SCIXabcdCreationModifier](trading-annotation---scixabcdcreationmodifier.html) available in SciChart iOS. + +> **_NOTE:_** To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](Annotations APIs.html) article. diff --git a/guides/Chart Modifier API/Trading Annotation - SCIFreehandDrawingModifier.md b/guides/Chart Modifier API/Trading Annotation - SCIFreehandDrawingModifier.md new file mode 100644 index 0000000..8e5eeb4 --- /dev/null +++ b/guides/Chart Modifier API/Trading Annotation - SCIFreehandDrawingModifier.md @@ -0,0 +1,66 @@ +# The SCIFreehandDrawingModifier +The `SCIFreehandDrawingModifier` is a gesture modifier that enables freehand drawing directly on a SciChartSurface. + +![Freehand Drawing Modifier](img/annotations/freehand-drawing-modifier.png) + +> **_NOTE:_** Examples of the **`Annotations`** usage can be found in the [SciChart iOS Examples Suite](https://www.scichart.com/examples/ios-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.iOS.Examples): +> +> - Freehand Drawing Modifier - [Obj-C/Swift](https://www.scichart.com/example/ios-chart-chart-freehand-drawing-modifier-example/) ̰ + +## Overview +When this modifier is attached to a SciChartSurface, users can draw freehand strokes on the chart using touch gestures. As the user drags across the surface, a freehand drawing annotation is dynamically created and populated with a series of points representing the path of the gesture. + +This is useful for scenarios such as: +- Marking regions of interest +- Freeform technical analysis +- Drawing custom overlays on charts + +## API Reference + +| **Field** | **Description** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `SCIFreehandDrawingModifier.stroke` | The pen style used to draw the annotation | +| `SCIFreehandDrawingModifier.selectionOffset` | Specifies extra padding around the selection bounds of the annotation.. | +| `SCIFreehandDrawingModifier.deleteSelectedAnnotations()` | Removes all currently selected freehand drawing annotations from the chart surface. | + +To learn more about **Pens** and **Brushes** and how to utilize them, please refer to the [SCIPenStyle, SCIBrushStyle and SCIFontStyle](scipenstyle-scibrushstyle-and-scifontstyle.html) article. + +> **_NOTE:_** To learn more about **Annotations** in general - please see the [Common Annotation Features](Annotations APIs.html#common-annotations-features) article. + +> **_NOTE:_** The **xAxisId** and **yAxisId** must be supplied if you have axis with **non-default** Axis Ids, e.g. in **multi-axis** scenario. + +## Usage Example +A `SCIFreehandDrawingModifier` can be added onto a chart using the following code: + +
+ + +
+
+ // Assume a surface has been created and configured somewhere +id surface = self.surface; + +SCIFreehandDrawingModifier *freehandModifier = [SCIFreehandDrawingModifier new]; +freehandModifier.stroke = [[SCISolidPenStyle alloc] initWithColorCode:0xFFFF0000 thickness:2]; + +// Add to chart modifiers collection +[surface.chartModifiers add:freehandModifier]; +
+
+// Assume a surface has been created and configured somewhere +let surface: ISCIChartSurface + +let freehandModifier = SCIFreehandDrawingModifier() +freehandModifier.stroke = SCISolidPenStyle(color: SCIColor.red, thickness: 2.0) + +// Add to chart modifiers collection +surface.chartModifiers.add(freehandModifier) +
+ +## Behavior +- Touch down begins a new freehand drawing annotation. +- Moving the finger continuously adds points to the annotation path. +- Releasing the touch finalizes the annotation. +- Annotations can be selected and removed using deleteSelectedAnnotations(). + +> **_NOTE:_** To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](Annotations APIs.html) article. diff --git a/guides/Chart Modifier API/Trading Annotation - SCIPitchforkCreationModifier.md b/guides/Chart Modifier API/Trading Annotation - SCIPitchforkCreationModifier.md new file mode 100644 index 0000000..f02f389 --- /dev/null +++ b/guides/Chart Modifier API/Trading Annotation - SCIPitchforkCreationModifier.md @@ -0,0 +1,142 @@ +# SCIPitchforkCreationModifier +The `SCIPitchforkCreationModifier` is a custom gesture modifier used for interactive creation of **Pitchfork annotations** on a SciChart surface. +It enables users to define a pitchfork using a two-stage pan gesture workflow, producing a `SCIPitchforkAnnotation` with real-time visual feedback during construction. + +## Overview +The modifier manages the full lifecycle of pitchfork creation: +- Two-step gesture interaction (A → B → C) +- Real-time rendering while dragging points +- Automatic annotation finalization after point C is set +- Immediate reset for continuous creation of multiple pitchforks + +Once completed, the annotation is added to the chart and a completion callback is triggered. + +## Interaction Behavior +The creation flow is split into two sequential pan gestures. + +### State Machine + +| State | Description | +| -------------------------------------- | ---------------------------------------------------- | +| `SCIPitchforkCreationStateIdle` | Waiting for first touch input | +| `SCIPitchforkCreationStateDrawingAB` | Point A is locked, user is dragging to define B | +| `SCIPitchforkCreationStateWaitingForC` | A and B are locked, waiting for second gesture | +| `SCIPitchforkCreationStateDrawingC` | User is dragging to define C; pitchfork updates live | + +### Gesture Flow (A → B → C) + +#### 1. First Pan Gesture (A → B) + +| Gesture | Behavior | +| -------------- | ----------------------------------------------- | +| **Touch Down** | Locks point **A** at touch location | +| **Drag** | Dynamically updates point **B** | +| **Touch Up** | Finalizes A and B, transitions to waiting state | + +#### 2. Second Pan Gesture (C) + +| Gesture | Behavior | +| -------------- | ---------------------------------------------- | +| **Touch Down** | Begins defining point **C** | +| **Drag** | Pitchfork updates in real time with C movement | +| **Touch Up** | Finalizes annotation and completes creation | + +### Completion + +- After point **C** is set, a `SCIPitchforkAnnotation` is created +- The `onCompleted` callback is invoked on the main thread +- The modifier automatically resets to `Idle` and is ready for the next pitchfork + +## Retrieving Annotation Data + +After completion, the resulting `SCIPitchforkAnnotation` contains the defining points of the structure. + +You can extract its geometry using base data methods exposed by the annotation: + +### getBaseDataValues() + +- Returns pitchfork anchor points in **data space** +- Values correspond to chart axis coordinates +- Best for storage, analytics, and reconstruction + +### getBasePoints() + +- Returns pitchfork points in **pixel space** +- Values correspond to rendered screen coordinates +- Useful for UI overlays and screen-level calculations + +## API Reference + +| **Field** | **Description** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `SCIPitchforkCreationModifier.creationState` | Current state of the pitchfork creation lifecycle. | +| `SCIPitchforkCreationModifier.onCompleted` | A callback invoked when a full pitchfork annotation is completed. | +| `SCIPitchforkCreationModifier.reset()` | Cancels any in-progress gesture and returns the modifier to `Idle`. | +| `SCIPitchforkCreationModifier.halfWidthZoneFill` | Fill colour for the central (middle) polygon section. | +| `SCIPitchforkCreationModifier.fullWidthZoneFill` | Fill colour for the two outer polygon sections. | +| `SCIPitchforkCreationModifier.tineStroke` | The pen style used to draw the four tine lines. | +| `SCIPitchforkCreationModifier.mainStroke` | The pen style used to draw the main pivot line. | + +## Usage Example + +
+ + +
+ +
+ +// Create pitchfork creation modifier +SCIPitchforkCreationModifier *modifier = [SCIPitchforkCreationModifier new]; + +// Handle completion +modifier.onCompleted = ^(SCIPitchforkAnnotation *annotation) { +NSLog(@"Pitchfork created: %@", annotation); + +NSArray *points = [annotation getBaseDataValues]; + +NSLog(@"Point A: %@", points[0]); +NSLog(@"Point B: %@", points[1]); +NSLog(@"Point C: %@", points[2]); + +}; + +// Add to chart +[self.surface.chartModifiers add:modifier]; + +
+ +
+ +// Create pitchfork creation modifier +let modifier = SCIPitchforkCreationModifier() + +// Handle completion +modifier.onCompleted = { annotation in +print("Pitchfork created: (annotation)") + +let points = annotation.getBaseDataValues() + +print("Point A: \(points[0])") +print("Point B: \(points[1])") +print("Point C: \(points[2])") + +} + +// Add to chart +surface.chartModifiers.add(modifier) + +
+ +## Best Practices + +- Disable conflicting gesture modifiers during pitchfork creation for smoother interaction +- Use `onCompleted` to persist or analyze completed annotations +- Call `reset()` when switching tools or exiting drawing mode +- Use distinct styling for pitchfork annotations to improve chart readability + +## Notes + +- Only one pitchfork is created per interaction cycle +- The modifier automatically resets after completion +- Designed for financial charting tools where trend structure visualization is required diff --git a/guides/Chart Modifier API/Trading Annotation - SCIXabcdCreationModifier.md b/guides/Chart Modifier API/Trading Annotation - SCIXabcdCreationModifier.md new file mode 100644 index 0000000..c728e9d --- /dev/null +++ b/guides/Chart Modifier API/Trading Annotation - SCIXabcdCreationModifier.md @@ -0,0 +1,125 @@ +# SCIXabcdCreationModifier +The `SCIXabcdCreationModifier` is a custom gesture modifier used for interactive creation of **XABCD annotations** on a SciChart surface. + +It enables users to place five key points (X → A → B → C → D) using touch gestures, with real-time visual feedback during placement. + +## Overview +The modifier handles the full lifecycle of XABCD annotation creation: + +- Sequential point placement via touch interaction +- Real-time dragging feedback for each point +- Automatic completion after the final point (D) +- Immediate reset for continuous drawing + +Once completed, the annotation remains on the chart and a callback is triggered. + +## Interaction Behavior + +The creation flow follows a structured sequence: + +### Per Point Interaction (X → A → B → C → D) + +| Gesture | Behavior | +|----------------|----------| +| **Touch Down** | Places the current point at the touch location | +| **Drag** | Moves the point dynamically in real-time | +| **Touch Up** | Locks the point and advances to the next one | + +### Completion + +- After placing point **D**, the annotation is finalized +- The `onCompleted` callback is invoked +- The modifier resets immediately, ready for a new annotation + +![Xabcd Annotation](img/annotations/xabcd-annotation.png) + +## Retrieving Annotation Points After Drawing Completion +After an annotation drawing is completed, you can retrieve its underlying points using: +getBaseDataValues() +getBasePoints() +Both methods return the annotation’s defining points, but in different coordinate spaces. + +### getBaseDataValues() +- Returns the annotation points in data space (axis values). +- X and Y values correspond to the chart’s actual data coordinates +- Independent of pixel resolution or screen scaling +- Useful for storing, analysis, or reloading annotations + +### getBasePoints() +- Returns annotation points in pixel space (rendered screen coordinates). +- X and Y values correspond to screen pixels +- Useful for rendering overlays or UI alignment + +## Usage Example +
+ + +
+
+// Create a new XABCD creation modifier instance +SCIXabcdCreationModifier *modifier = [SCIXabcdCreationModifier new]; + +// Set the stroke (outline) style for the XABCD annotation lines +modifier.annotationStroke = [[SCISolidPenStyle alloc] initWithColorCode:0xFFE97064 thickness:2]; + +// Set the fill style for the annotation +modifier.annotationFill = [[SCISolidBrushStyle alloc] initWithColorCode:0x55AAAA00]; + +// Callback triggered when the user completes placing all 5 points (X, A, B, C, D) +// Provides access to the fully created annotation object +modifier.onCompleted = ^(SCIXabcdAnnotation *annotation) { + NSLog(@"XABCD annotation created: %@", annotation); + NSArray *arrPoints = [annotation getBaseDataValues]; + + NSLog(@"XABCD point X: %@, %@",[arrPoints[0].x toDate],arrPoints[0].y); + NSLog(@"XABCD point A: %@, %@",arrPoints[1].x,arrPoints[1].y); +}; + +// Add the modifier to the chart surface +[self.surface.chartModifiers add:modifier]; +
+
+// Create a new XABCD creation modifier instance +let modifier = SCIXabcdCreationModifier() + +// Set the stroke (outline) style for the XABCD annotation lines +modifier.annotationStroke = SCISolidPenStyle(color: 0xFFE97064, thickness: 2) + +// Set the fill style for the annotation +modifier.annotationFill = SCISolidBrushStyle(color: 0x55AAAA00) + +// Callback triggered when all points (X, A, B, C, D) are placed +// Gives access to the completed annotation object +modifier.onCompleted = { annotation in + print("XABCD annotation created: \(annotation)") + let arrPoints = annotation.getBaseDataValues() + print("XABCD point X: \(arrPoints[0].x.toDate), \(arrPoints[0].y)") + print("XABCD point A: \(arrPoints[1].x), \(arrPoints[1].y)") +} + +// Add the modifier to the chart surface +surface.chartModifiers.add(modifier) +
+ + +The SCIXabcdCreationModifier can be configured using the properties and method listed in the table below: + +| **Field** | **Description** | +| --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `SCIXabcdCreationModifier.annotationFill` | Defines the stroke style for newly created annotations. | +| `SCIXabcdCreationModifier.annotationFill` | Defines the fill style for newly created annotations. | +| `SCIXabcdCreationModifier.isInSourceBounds` | Reports whether the event occurred within the **Source**. | +| `SCIXabcdCreationModifier.isDragging` | Indicates whether the user is actively dragging a point. | +| `SCIXabcdCreationModifier.activePointIndex` | Represents the index of the point currently being placed. | +| `SCIXabcdCreationModifier.onCompleted` | A callback invoked on the main thread when a full XABCD annotation is completed. | + +> **_Behavior Notes:_** +- The modifier automatically resets after completing point D +- Only one annotation is created per interaction cycle +- Designed for real-time financial charting and harmonic pattern visualization + +> **_Best Practices:_** +- Disable conflicting gesture modifiers during drawing for better UX +- Use onCompleted to validate or store annotations +- Customize stroke/fill for better visual distinction +- Call cancel when switching tools or modes diff --git a/scichart-theme/assets/img/annotations/composite-annotation.png b/scichart-theme/assets/img/annotations/composite-annotation.png new file mode 100644 index 0000000..9db40a9 Binary files /dev/null and b/scichart-theme/assets/img/annotations/composite-annotation.png differ diff --git a/scichart-theme/assets/img/annotations/freehand-drawing-annotation.png b/scichart-theme/assets/img/annotations/freehand-drawing-annotation.png new file mode 100644 index 0000000..a5d0bc4 Binary files /dev/null and b/scichart-theme/assets/img/annotations/freehand-drawing-annotation.png differ diff --git a/scichart-theme/assets/img/annotations/freehand-drawing-modifier.png b/scichart-theme/assets/img/annotations/freehand-drawing-modifier.png new file mode 100644 index 0000000..7c41ade Binary files /dev/null and b/scichart-theme/assets/img/annotations/freehand-drawing-modifier.png differ diff --git a/scichart-theme/assets/img/annotations/pitchfork-annotation.png b/scichart-theme/assets/img/annotations/pitchfork-annotation.png new file mode 100644 index 0000000..1299363 Binary files /dev/null and b/scichart-theme/assets/img/annotations/pitchfork-annotation.png differ diff --git a/scichart-theme/assets/img/annotations/xabcd-annotation.png b/scichart-theme/assets/img/annotations/xabcd-annotation.png new file mode 100644 index 0000000..0b601bd Binary files /dev/null and b/scichart-theme/assets/img/annotations/xabcd-annotation.png differ