Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions articles/chart2d/annotationsAPIs/Annotations APIs.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ The annotations which are available out the box in SciChart are listed below:
| **Annotation Type** | **Description** |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| [BoxAnnotation](xref:annotationsAPIs.BoxAnnotation) | Draws a **rectangle** at specific `X1, X2, Y1, Y2` coordinates. |
| [BrushAnnotation](xref:annotationsAPIs.BrushAnnotation) | Allows for **freehand drawing** on the chart. |
| [XabcdAnnotation](xref:annotationsAPIs.XabcdAnnotation) | Draws **harmonic patterns** (X, A, B, C, D) with automatic **Fibonacci-style ratios**. |
| [PitchforkAnnotation](xref:annotationsAPIs.PitchforkAnnotation) | Draws **Andrew's Pitchfork** patterns using **3 points** (Handle, High, Low). |
| [LineAnnotation](xref:annotationsAPIs.LineAnnotation) | Draws a **line** between `[X1, Y1]` and `[X2, Y2]` coordinates. |
| [LineArrowAnnotation](xref:annotationsAPIs.LineArrowAnnotation) | Draws an **arrow** from `[X1, Y1]` to `[X2, Y2]` coordinates. |
| [HorizontalLineAnnotation](xref:annotationsAPIs.HorizontalLineAnnotation) | Draws a **horizontal line** between `[X1, Y1]` and `[X2, Y2]` coordinates. |
Expand Down Expand Up @@ -120,3 +123,8 @@ As mentioned [above](#common-annotations-features) - that's can be controlled vi
> This is demonstrated in the **Interaction with Annotations** example which can be found in the [SciChart Android Examples Suite](https://www.scichart.com/examples/Android-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.Android.Examples):
> - [Native Example](https://www.scichart.com/example/android-chart/android-chart-interaction-with-annotations-example/)
> - [Xamarin Example](https://www.scichart.com/example/xamarin-chart/xamarin-chart-interaction-with-annotations-example/)

## Annotation Creation Modifiers
SciChart also provides a set of specialized **Chart Modifiers** that allow users to create annotations interactively on the chart using touch gestures.

To learn more about available creation modifiers, please refer to the corresponding articles in the **Annotation Creation Modifiers** section.
45 changes: 45 additions & 0 deletions articles/chart2d/annotationsAPIs/BrushAnnotation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
uid: "annotationsAPIs.BrushAnnotation"
---

# The BrushAnnotation
The <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation> allows for freehand drawing on the chart:

![Brush Annotation](images/brush-annotation.png)

> [!NOTE]
> Examples of the **Annotations** usage can be found in the [SciChart Android Examples Suite](https://www.scichart.com/examples/Android-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.Android.Examples):
> - [Native Android Chart Annotations Example](https://www.scichart.com/example/android-chart/android-chart-annotations-example/)
> - [Native Android Chart Interactive Annotations Example](https://www.scichart.com/example/android-chart/android-chart-interaction-with-annotations-example/)
>
> - [Xamarin Android Chart Annotations Example](https://www.scichart.com/example/xamarin-chart/xamarin-chart-annotations-example/)
> - [Xamarin Android Chart Interactive Annotations Example](https://www.scichart.com/example/xamarin-chart/xamarin-chart-interaction-with-annotations-example/)

A <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation> is a multi-point annotation that stores a collection of points to form a freehand stroke.
It provides properties to customize its appearance:
- [brushColor](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation.setBrushColor(int)): Sets the color of the brush stroke.
- [brushThickness](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation.setBrushThickness(float)): Sets the thickness of the brush stroke.

Points can be added or updated using the following methods:
- [setBasePoint(Comparable<?> x, Comparable<?> y)](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation.setBasePoint(java.lang.Comparable, java.lang.Comparable)): Adds a new point to the annotation.
- [updateBasePoint(int index, Comparable<?> x, Comparable<?> y)](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation.updateBasePoint(int, java.lang.Comparable, java.lang.Comparable)): Updates an existing point at the specified index.

> [!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 BrushAnnotation
A <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation> can be added onto a chart using the following code:

# [Java](#tab/java)
[!code-java[AddBrushAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationFragment.java#AddBrushAnnotation)]
# [Java with Builders API](#tab/javaBuilder)
[!code-java[AddBrushAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/BrushAnnotationFragment.java#AddBrushAnnotation)]
# [Kotlin](#tab/kotlin)
[!code-swift[AddBrushAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationFragment.kt#AddBrushAnnotation)]
***

> [!NOTE]
> For interactive creation of the `BrushAnnotation`, use the [BrushAnnotationCreationModifier](xref:annotationsAPIs.BrushAnnotationCreationModifier).

> [!NOTE]
> To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](xref:annotationsAPIs.AnnotationsAPIs) article.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
uid: "annotationsAPIs.BrushAnnotationCreationModifier"
---

# The BrushAnnotationCreationModifier
The <xref:com.scichart.charting.modifiers.BrushAnnotationCreationModifier> is a chart modifier that allows for freehand creation of <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation> instances.

## Overview
When this modifier is enabled and added to a <xref:com.scichart.charting.visuals.SciChartSurface>, users can draw freehand strokes directly on the chart using touch gestures. The modifier automatically creates a new `BrushAnnotation` and populates it with points based on the user's movement.

## Properties
The following properties can be used to configure the `BrushAnnotationCreationModifier`:

| Property | Description |
| --- | --- |
| [brushColor](xref:com.scichart.charting.modifiers.BrushAnnotationCreationModifier.setBrushColor(int)) | Sets the color of the brush stroke for the annotations created by this modifier. |
| [brushThickness](xref:com.scichart.charting.modifiers.BrushAnnotationCreationModifier.setBrushThickness(float)) | Sets the thickness of the brush stroke for the annotations created by this modifier. |
| [xAxisId](xref:com.scichart.charting.modifiers.BrushAnnotationCreationModifier.setXAxisId(java.lang.String)) | Sets the ID of the X-Axis that the created annotations should be measured against. |
| [yAxisId](xref:com.scichart.charting.modifiers.BrushAnnotationCreationModifier.setYAxisId(java.lang.String)) | Sets the ID of the Y-Axis that the created annotations should be measured against. |

## Event Listeners
You can receive a notification when an annotation is created by setting an <xref:com.scichart.charting.modifiers.OnAnnotationCreatedListener>:

- [setAnnotationCreationListener(OnAnnotationCreatedListener listener)](xref:com.scichart.charting.modifiers.BrushAnnotationCreationModifier.setAnnotationCreationListener(com.scichart.charting.modifiers.OnAnnotationCreatedListener)): Passes the newly created annotation instance to the listener.

## Using BrushAnnotationCreationModifier
The following code demonstrates how to add and configure a `BrushAnnotationCreationModifier`:

# [Java](#tab/java)
[!code-java[AddBrushAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationCreationModifierFragment.java#AddBrushAnnotationCreationModifier)]
# [Kotlin](#tab/kotlin)
[!code-swift[AddBrushAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationCreationModifierFragment.kt#AddBrushAnnotationCreationModifier)]
***

## Customizing the Modifier
You can customize the behavior of the `BrushAnnotationCreationModifier` by extending it and overriding its touch event methods. This allows you to add custom logic before or after an annotation is created.

### [Java](#tab/java)
[!code-java[CustomBrushAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationCreationModifierFragment.java#CustomBrushAnnotationCreationModifier)]
### [Kotlin](#tab/kotlin)
[!code-swift[CustomBrushAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationCreationModifierFragment.kt#CustomBrushAnnotationCreationModifier)]
***

> [!NOTE]
> To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](xref:annotationsAPIs.AnnotationsAPIs) article.
47 changes: 47 additions & 0 deletions articles/chart2d/annotationsAPIs/PitchforkAnnotation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
uid: "annotationsAPIs.PitchforkAnnotation"
---

# The PitchforkAnnotation
The <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation> (also known as Andrew's Pitchfork) is a specialized trading annotation that uses three points to identify support and resistance levels.

![Pitchfork Annotation](images/pitchfork-annotation.png)

> [!NOTE]
> Examples of the **Annotations** usage can be found in the [SciChart Android Examples Suite](https://www.scichart.com/examples/Android-chart/) as well as on [GitHub](https://github.com/ABTSoftware/SciChart.Android.Examples):
> - [Native Android Chart Annotations Example](https://www.scichart.com/example/android-chart/android-chart-annotations-example/)
> - [Native Android Chart Interactive Annotations Example](https://www.scichart.com/example/android-chart/android-chart-interaction-with-annotations-example/)
>
> - [Xamarin Android Chart Annotations Example](https://www.scichart.com/example/xamarin-chart/xamarin-chart-annotations-example/)
> - [Xamarin Android Chart Interactive Annotations Example](https://www.scichart.com/example/xamarin-chart/xamarin-chart-interaction-with-annotations-example/)

## Structure and Points
The `PitchforkAnnotation` is defined by 3 base points:
- **Point 0 (Handle)**: The starting point of the median line.
- **Point 1 (High/Low)**: The first point of the cross-line.
- **Point 2 (Low/High)**: The second point of the cross-line.

The median line starts at Point 0 and passes through the midpoint of the segment connecting Point 1 and Point 2. Two additional lines are drawn parallel to the median line, starting from Point 1 and Point 2.

## Appearance Properties
The following properties can be used to customize the appearance of the `PitchforkAnnotation`:
- [stroke](xref:com.scichart.charting.visuals.annotations.AnnotationBase.setStroke(com.scichart.drawing.common.PenStyle)): Sets the pen style for all the lines in the pitchfork.
- [sidesFill](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation.setSidesFill(com.scichart.drawing.common.BrushStyle)): Sets the brush style for the outer filled areas.
- [middleFill](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation.setMiddleFill(com.scichart.drawing.common.BrushStyle)): Sets the brush style for the inner filled area around the median line.

## Create a PitchforkAnnotation
A <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation> can be added onto a chart using the following code:

# [Java](#tab/java)
[!code-java[AddPitchforkAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationFragment.java#AddPitchforkAnnotation)]
# [Java with Builders API](#tab/javaBuilder)
[!code-java[AddPitchforkAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/PitchforkAnnotationFragment.java#AddPitchforkAnnotation)]
# [Kotlin](#tab/kotlin)
[!code-swift[AddPitchforkAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationFragment.kt#AddPitchforkAnnotation)]
***

> [!NOTE]
> For interactive creation of the `PitchforkAnnotation`, use the [PitchforkAnnotationCreationModifier](xref:annotationsAPIs.PitchforkAnnotationCreationModifier).

> [!NOTE]
> To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](xref:annotationsAPIs.AnnotationsAPIs) article.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
uid: "annotationsAPIs.PitchforkAnnotationCreationModifier"
---

# The PitchforkAnnotationCreationModifier
The <xref:com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier> is a chart modifier that allows for interactive creation of <xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation> instances using a 3-tap workflow.

## Overview
When this modifier is enabled, users can place the 3 required points (Handle, High, Low) by tapping on the chart.
- Each tap confirms the position of the next point.
- A "rubber-band" dashed line provides a preview of the next segment between the last confirmed point and the current touch position.
- Once the third point is placed, the annotation is finalized, and the modifier automatically resets to create the next one.

## Properties
The following properties can be used to configure the `PitchforkAnnotationCreationModifier`:

| Property | Description |
| --- | --- |
| [xAxisId](xref:com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier.setXAxisId(java.lang.String)) | Sets the ID of the X-Axis that the created annotations should be measured against. |
| [yAxisId](xref:com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier.setYAxisId(java.lang.String)) | Sets the ID of the Y-Axis that the created annotations should be measured against. |
| [rubberBandStroke](xref:com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier.setRubberBandStroke(com.scichart.drawing.common.PenStyle)) | Sets the pen style for the preview line shown during creation. |

## Event Listeners
You can receive a notification when an annotation is fully created by setting an <xref:com.scichart.charting.modifiers.OnAnnotationCreatedListener>:

- [setAnnotationCreationListener(OnAnnotationCreatedListener listener)](xref:com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier.setAnnotationCreationListener(com.scichart.charting.modifiers.OnAnnotationCreatedListener)): Passes the newly created annotation instance to the listener.

## Using PitchforkAnnotationCreationModifier
The following code demonstrates how to add and configure a `PitchforkAnnotationCreationModifier`:

# [Java](#tab/java)
[!code-java[AddPitchforkAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.java#AddPitchforkAnnotationCreationModifier)]
# [Kotlin](#tab/kotlin)
[!code-swift[AddPitchforkAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.kt#AddPitchforkAnnotationCreationModifier)]
***

## Customizing the Modifier
The `PitchforkAnnotationCreationModifier` is designed for extensibility. You can customize its behavior by extending it and overriding its `protected` methods.

### [Java](#tab/java)
[!code-java[CustomPitchforkAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.java#CustomPitchforkAnnotationCreationModifier)]
### [Kotlin](#tab/kotlin)
[!code-swift[CustomPitchforkAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.kt#CustomPitchforkAnnotationCreationModifier)]
***

> [!NOTE]
> To learn more about other **Annotation Types**, available out of the box in SciChart, please find the comprehensive list in the [Annotation APIs](xref:annotationsAPIs.AnnotationsAPIs) article.
Loading