diff --git a/articles/chart2d/annotationsAPIs/Annotations APIs.md b/articles/chart2d/annotationsAPIs/Annotations APIs.md index a0482b0..308e7f2 100644 --- a/articles/chart2d/annotationsAPIs/Annotations APIs.md +++ b/articles/chart2d/annotationsAPIs/Annotations APIs.md @@ -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. | @@ -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. diff --git a/articles/chart2d/annotationsAPIs/BrushAnnotation.md b/articles/chart2d/annotationsAPIs/BrushAnnotation.md new file mode 100644 index 0000000..a88ef70 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/BrushAnnotation.md @@ -0,0 +1,45 @@ +--- +uid: "annotationsAPIs.BrushAnnotation" +--- + +# The BrushAnnotation +The 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 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 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. diff --git a/articles/chart2d/annotationsAPIs/BrushAnnotationCreationModifier.md b/articles/chart2d/annotationsAPIs/BrushAnnotationCreationModifier.md new file mode 100644 index 0000000..6783f94 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/BrushAnnotationCreationModifier.md @@ -0,0 +1,45 @@ +--- +uid: "annotationsAPIs.BrushAnnotationCreationModifier" +--- + +# The BrushAnnotationCreationModifier +The is a chart modifier that allows for freehand creation of instances. + +## Overview +When this modifier is enabled and added to a , 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 : + +- [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. diff --git a/articles/chart2d/annotationsAPIs/PitchforkAnnotation.md b/articles/chart2d/annotationsAPIs/PitchforkAnnotation.md new file mode 100644 index 0000000..a19fc7c --- /dev/null +++ b/articles/chart2d/annotationsAPIs/PitchforkAnnotation.md @@ -0,0 +1,47 @@ +--- +uid: "annotationsAPIs.PitchforkAnnotation" +--- + +# The PitchforkAnnotation +The (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 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. diff --git a/articles/chart2d/annotationsAPIs/PitchforkAnnotationCreationModifier.md b/articles/chart2d/annotationsAPIs/PitchforkAnnotationCreationModifier.md new file mode 100644 index 0000000..b7ef455 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/PitchforkAnnotationCreationModifier.md @@ -0,0 +1,47 @@ +--- +uid: "annotationsAPIs.PitchforkAnnotationCreationModifier" +--- + +# The PitchforkAnnotationCreationModifier +The is a chart modifier that allows for interactive creation of 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 : + +- [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. diff --git a/articles/chart2d/annotationsAPIs/XabcdAnnotation.md b/articles/chart2d/annotationsAPIs/XabcdAnnotation.md new file mode 100644 index 0000000..a2d2816 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/XabcdAnnotation.md @@ -0,0 +1,47 @@ +--- +uid: "annotationsAPIs.XabcdAnnotation" +--- + +# The XabcdAnnotation +The is a specialized multi-point annotation used for drawing harmonic patterns (such as Gartley, Butterfly, Bat, and Crab patterns) which consist of 5 points: **X, A, B, C,** and **D**. + +![Xabcd Annotation](images/xabcd-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/) + +## Points and Ratios +The `XabcdAnnotation` requires 5 points to be placed. Once all points are set, it automatically calculates and displays the following Fibonacci-style ratios: +- **XB Ratio**: Calculated as `|B - A| / |A - X|` +- **AC Ratio**: Calculated as `|C - B| / |B - A|` +- **BD Ratio**: Calculated as `|D - C| / |C - B|` +- **XD Ratio**: Calculated as `|D - A| / |A - X|` + +These ratios are calculated based on the values on the specified [ratioAxisId](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.XabcdAnnotation.setRatioAxisId(java.lang.String)). If no axis ID is specified, the primary Y-Axis is used. + +## Appearance Properties +The following properties can be used to customize the appearance of the `XabcdAnnotation`: +- [stroke](xref:com.scichart.charting.visuals.annotations.AnnotationBase.setStroke(com.scichart.drawing.common.PenStyle)): Sets the pen style for the primary lines (XA, AB, BC, CD) and the secondary dashed lines (XB, AC, BD, XD). +- [fill](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.XabcdAnnotation.setFill(com.scichart.drawing.common.BrushStyle)): Sets the brush style for the two filled triangular areas (XAB and BCD). + +## Create an XabcdAnnotation +An can be added onto a chart using the following code: + +# [Java](#tab/java) +[!code-java[AddXabcdAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationFragment.java#AddXabcdAnnotation)] +# [Java with Builders API](#tab/javaBuilder) +[!code-java[AddXabcdAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/XabcdAnnotationFragment.java#AddXabcdAnnotation)] +# [Kotlin](#tab/kotlin) +[!code-swift[AddXabcdAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationFragment.kt#AddXabcdAnnotation)] +*** + +> [!NOTE] +> For interactive creation of the `XabcdAnnotation`, use the [XabcdAnnotationCreationModifier](xref:annotationsAPIs.XabcdAnnotationCreationModifier). + +> [!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. diff --git a/articles/chart2d/annotationsAPIs/XabcdAnnotationCreationModifier.md b/articles/chart2d/annotationsAPIs/XabcdAnnotationCreationModifier.md new file mode 100644 index 0000000..8c3d4a8 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/XabcdAnnotationCreationModifier.md @@ -0,0 +1,47 @@ +--- +uid: "annotationsAPIs.XabcdAnnotationCreationModifier" +--- + +# The XabcdAnnotationCreationModifier +The is a chart modifier that allows for interactive creation of instances using a multi-tap workflow. + +## Overview +When this modifier is enabled, users can place the 5 required points (X, A, B, C, D) 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 fifth point (D) 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 `XabcdAnnotationCreationModifier`: + +| Property | Description | +| --- | --- | +| [xAxisId](xref:com.scichart.charting.modifiers.XabcdAnnotationCreationModifier.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.XabcdAnnotationCreationModifier.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.XabcdAnnotationCreationModifier.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 : + +- [setAnnotationCreationListener(OnAnnotationCreatedListener listener)](xref:com.scichart.charting.modifiers.XabcdAnnotationCreationModifier.setAnnotationCreationListener(com.scichart.charting.modifiers.OnAnnotationCreatedListener)): Passes the newly created annotation instance to the listener. + +## Using XabcdAnnotationCreationModifier +The following code demonstrates how to add and configure an `XabcdAnnotationCreationModifier`: + +# [Java](#tab/java) +[!code-java[AddXabcdAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationCreationModifierFragment.java#AddXabcdAnnotationCreationModifier)] +# [Kotlin](#tab/kotlin) +[!code-swift[AddXabcdAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationCreationModifierFragment.kt#AddXabcdAnnotationCreationModifier)] +*** + +## Customizing the Modifier +The `XabcdAnnotationCreationModifier` is designed for extensibility. You can customize its behavior by extending it and overriding its `protected` methods. This allows you to change the annotation type, customize the rubber-band preview, or add post-creation logic. + +### [Java](#tab/java) +[!code-java[CustomXabcdAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationCreationModifierFragment.java#CustomXabcdAnnotationCreationModifier)] +### [Kotlin](#tab/kotlin) +[!code-swift[CustomXabcdAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationCreationModifierFragment.kt#CustomXabcdAnnotationCreationModifier)] +*** + +> [!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. diff --git a/articles/chart2d/annotationsAPIs/images/brush-annotation.png b/articles/chart2d/annotationsAPIs/images/brush-annotation.png new file mode 100644 index 0000000..094f229 Binary files /dev/null and b/articles/chart2d/annotationsAPIs/images/brush-annotation.png differ diff --git a/articles/chart2d/annotationsAPIs/images/pitchfork-annotation.png b/articles/chart2d/annotationsAPIs/images/pitchfork-annotation.png new file mode 100644 index 0000000..76bbe5a Binary files /dev/null and b/articles/chart2d/annotationsAPIs/images/pitchfork-annotation.png differ diff --git a/articles/chart2d/annotationsAPIs/images/xabcd-annotation.png b/articles/chart2d/annotationsAPIs/images/xabcd-annotation.png new file mode 100644 index 0000000..8bbe1bf Binary files /dev/null and b/articles/chart2d/annotationsAPIs/images/xabcd-annotation.png differ diff --git a/articles/chart2d/annotationsAPIs/toc.yml b/articles/chart2d/annotationsAPIs/toc.yml index 0c0c4c2..376f712 100644 --- a/articles/chart2d/annotationsAPIs/toc.yml +++ b/articles/chart2d/annotationsAPIs/toc.yml @@ -1,6 +1,9 @@ - name: "BoxAnnotation" href: "BoxAnnotation.md" +- name: "BrushAnnotation" + href: "BrushAnnotation.md" + - name: "LineAnnotation" href: "LineAnnotation.md" @@ -28,4 +31,21 @@ - name: "CustomAnnotation" href: "CustomAnnotation.md" +- name: "XabcdAnnotation" + href: "XabcdAnnotation.md" + +- name: "PitchforkAnnotation" + href: "PitchforkAnnotation.md" + +- name: "Annotation Creation Modifiers" + items: + - name: "BrushAnnotationCreationModifier" + href: "BrushAnnotationCreationModifier.md" + + - name: "XabcdAnnotationCreationModifier" + href: "XabcdAnnotationCreationModifier.md" + + - name: "PitchforkAnnotationCreationModifier" + href: "PitchforkAnnotationCreationModifier.md" + diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationCreationModifierFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationCreationModifierFragment.java new file mode 100644 index 0000000..236ef06 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationCreationModifierFragment.java @@ -0,0 +1,68 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.modifiers.BrushAnnotationCreationModifier; +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.IAnnotation; +import com.scichart.core.utility.touch.ModifierTouchEventArgs; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class BrushAnnotationCreationModifierFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addBrushAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // + // Create a BrushAnnotationCreationModifier + final BrushAnnotationCreationModifier brushCreationModifier = new BrushAnnotationCreationModifier(); + + // Configure the modifier + brushCreationModifier.setBrushColor(Color.WHITE); + brushCreationModifier.setBrushThickness(4f); + + // Optional: Set a listener to be notified when an annotation is created + brushCreationModifier.setAnnotationCreationListener(newAnnotation -> { + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true); + }); + + // Add the modifier to the surface + surface.getChartModifiers().add(brushCreationModifier); + // + } + + // + // Define a custom BrushAnnotationCreationModifier + private static class CustomBrushAnnotationCreationModifier extends BrushAnnotationCreationModifier { + @Override + protected boolean onTouchDown(ModifierTouchEventArgs args) { + // Custom logic before creation + return super.onTouchDown(args); + } + + @Override + protected boolean onTouchMove(ModifierTouchEventArgs args) { + // Custom logic during creation + return super.onTouchMove(args); + } + + @Override + protected boolean onTouchUp(ModifierTouchEventArgs args) { + // Custom logic after creation + return super.onTouchUp(args); + } + } + + void useCustomBrushAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // Use the custom modifier + final CustomBrushAnnotationCreationModifier customModifier = new CustomBrushAnnotationCreationModifier(); + customModifier.setBrushColor(Color.YELLOW); + + surface.getChartModifiers().add(customModifier); + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationFragment.java new file mode 100644 index 0000000..edeb604 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/BrushAnnotationFragment.java @@ -0,0 +1,38 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class BrushAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addBrushAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create a BrushAnnotation + final BrushAnnotation brushAnnotation = new BrushAnnotation(getContext()); + + // Allow to interact with the annotation in run-time + brushAnnotation.setIsEditable(true); + + // Specify the brush color and thickness + brushAnnotation.setBrushColor(Color.WHITE); + brushAnnotation.setBrushThickness(4f); + + // Add points to the BrushAnnotation + brushAnnotation.setBasePoint(10, 30.6); + brushAnnotation.setBasePoint(30, 31.5); + brushAnnotation.setBasePoint(50, 30.3); + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(brushAnnotation); + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.java new file mode 100644 index 0000000..605c57b --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.java @@ -0,0 +1,64 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier; +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.IAnnotation; +import com.scichart.charting.visuals.annotations.LineAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import com.scichart.drawing.common.SolidPenStyle; +import android.graphics.Color; + +@ExampleDefinition() +public class PitchforkAnnotationCreationModifierFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addPitchforkAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // + // Create a PitchforkAnnotationCreationModifier + final PitchforkAnnotationCreationModifier pitchforkCreationModifier = new PitchforkAnnotationCreationModifier(); + + // Optional: Set a listener to be notified when an annotation is created + pitchforkCreationModifier.setAnnotationCreationListener(newAnnotation -> { + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true); + }); + + // Add the modifier to the surface + surface.getChartModifiers().add(pitchforkCreationModifier); + // + } + + // + // Define a custom PitchforkAnnotationCreationModifier + private static class CustomPitchforkAnnotationCreationModifier extends PitchforkAnnotationCreationModifier { + @Override + protected void configureRubberBandAnnotation(IAnnotation annotation) { + super.configureRubberBandAnnotation(annotation); + + // Customize the rubber-band styling + if (annotation instanceof LineAnnotation) { + ((LineAnnotation) annotation).setStroke(new SolidPenStyle(Color.YELLOW, true, 2f, new float[]{10, 5})); + } + } + + @Override + protected void onAnnotationCreated(IAnnotation newAnnotation) { + super.onAnnotationCreated(newAnnotation); + + // Custom logic after annotation is fully created + newAnnotation.setIsEditable(true); + } + } + + void useCustomPitchforkAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // Use the custom modifier + final CustomPitchforkAnnotationCreationModifier customModifier = new CustomPitchforkAnnotationCreationModifier(); + + surface.getChartModifiers().add(customModifier); + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationFragment.java new file mode 100644 index 0000000..fb54eff --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/PitchforkAnnotationFragment.java @@ -0,0 +1,41 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import com.scichart.drawing.common.SolidBrushStyle; +import com.scichart.drawing.common.SolidPenStyle; +import android.graphics.Color; + +@ExampleDefinition() +public class PitchforkAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addPitchforkAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create a PitchforkAnnotation + final PitchforkAnnotation pitchforkAnnotation = new PitchforkAnnotation(getContext()); + + // Allow to interact with the annotation in run-time + pitchforkAnnotation.setIsEditable(true); + + // Specify the stroke and fill styles + pitchforkAnnotation.setStroke(new SolidPenStyle(Color.RED, true, 2f, null)); + pitchforkAnnotation.setSidesFill(new SolidBrushStyle(Color.GREEN)); + pitchforkAnnotation.setMiddleFill(new SolidBrushStyle(Color.BLUE)); + + // Add 3 points to define the pitchfork + pitchforkAnnotation.setBasePoint(10, 30.6); // Handle (Point 0) + pitchforkAnnotation.setBasePoint(30, 31.5); // High (Point 1) + pitchforkAnnotation.setBasePoint(50, 30.3); // Low (Point 2) + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(pitchforkAnnotation); + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationCreationModifierFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationCreationModifierFragment.java new file mode 100644 index 0000000..70c7c6d --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationCreationModifierFragment.java @@ -0,0 +1,64 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.modifiers.XabcdAnnotationCreationModifier; +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.IAnnotation; +import com.scichart.charting.visuals.annotations.LineAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import com.scichart.drawing.common.SolidPenStyle; +import android.graphics.Color; + +@ExampleDefinition() +public class XabcdAnnotationCreationModifierFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addXabcdAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // + // Create an XabcdAnnotationCreationModifier + final XabcdAnnotationCreationModifier xabcdCreationModifier = new XabcdAnnotationCreationModifier(); + + // Optional: Set a listener to be notified when an annotation is created + xabcdCreationModifier.setAnnotationCreationListener(newAnnotation -> { + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true); + }); + + // Add the modifier to the surface + surface.getChartModifiers().add(xabcdCreationModifier); + // + } + + // + // Define a custom XabcdAnnotationCreationModifier + private static class CustomXabcdAnnotationCreationModifier extends XabcdAnnotationCreationModifier { + @Override + protected void configureRubberBandAnnotation(IAnnotation annotation) { + super.configureRubberBandAnnotation(annotation); + + // Customize the rubber-band styling + if (annotation instanceof LineAnnotation) { + ((LineAnnotation) annotation).setStroke(new SolidPenStyle(Color.YELLOW, true, 2f, new float[]{10, 5})); + } + } + + @Override + protected void onAnnotationCreated(IAnnotation newAnnotation) { + super.onAnnotationCreated(newAnnotation); + + // Custom logic after annotation is fully created + newAnnotation.setIsEditable(true); + } + } + + void useCustomXabcdAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // Use the custom modifier + final CustomXabcdAnnotationCreationModifier customModifier = new CustomXabcdAnnotationCreationModifier(); + + surface.getChartModifiers().add(customModifier); + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationFragment.java new file mode 100644 index 0000000..f16743c --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/XabcdAnnotationFragment.java @@ -0,0 +1,42 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.tradingAnnotations.XabcdAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import com.scichart.drawing.common.SolidBrushStyle; +import com.scichart.drawing.common.SolidPenStyle; +import android.graphics.Color; + +@ExampleDefinition() +public class XabcdAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addXabcdAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create an XabcdAnnotation + final XabcdAnnotation xabcdAnnotation = new XabcdAnnotation(getContext()); + + // Allow to interact with the annotation in run-time + xabcdAnnotation.setIsEditable(true); + + // Specify the stroke and fill + xabcdAnnotation.setStroke(new SolidPenStyle(Color.YELLOW, true, 2f, null)); + xabcdAnnotation.setFill(new SolidBrushStyle(Color.BLUE)); + + // Add 5 points (X, A, B, C, D) + xabcdAnnotation.setBasePoint(10, 30.6); // X + xabcdAnnotation.setBasePoint(30, 31.5); // A + xabcdAnnotation.setBasePoint(50, 30.3); // B + xabcdAnnotation.setBasePoint(70, 31.5); // C + xabcdAnnotation.setBasePoint(90, 30.6); // D + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(xabcdAnnotation); + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/BrushAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/BrushAnnotationFragment.java new file mode 100644 index 0000000..14a3c3e --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/BrushAnnotationFragment.java @@ -0,0 +1,33 @@ +package com.scichart.docsandbox.examples.javaBuilder.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class BrushAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addBrushAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create a BrushAnnotation using the SciChartBuilder + final BrushAnnotation brushAnnotation = sciChartBuilder.newBrushAnnotation() + .withBrushColor(Color.WHITE) + .withBrushThickness(4f) + .withBasePoint(10, 30.6) + .withBasePoint(30, 31.5) + .withBasePoint(50, 30.3) + .withIsEditable(true) + .build(); + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(brushAnnotation); + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/PitchforkAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/PitchforkAnnotationFragment.java new file mode 100644 index 0000000..ba81b6e --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/PitchforkAnnotationFragment.java @@ -0,0 +1,34 @@ +package com.scichart.docsandbox.examples.javaBuilder.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class PitchforkAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addPitchforkAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create a PitchforkAnnotation using the SciChartBuilder + final PitchforkAnnotation pitchforkAnnotation = sciChartBuilder.newPitchforkAnnotation() + .withStroke(Color.RED, 2f) + .withSidesFill(Color.GREEN) + .withMiddleFill(Color.BLUE) + .withBasePoint(10, 30.6) + .withBasePoint(30, 31.5) + .withBasePoint(50, 30.3) + .withIsEditable(true) + .build(); + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(pitchforkAnnotation); + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/XabcdAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/XabcdAnnotationFragment.java new file mode 100644 index 0000000..c4f37fc --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/XabcdAnnotationFragment.java @@ -0,0 +1,35 @@ +package com.scichart.docsandbox.examples.javaBuilder.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.visuals.SciChartSurface; +import com.scichart.charting.visuals.annotations.tradingAnnotations.XabcdAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class XabcdAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addXabcdAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create an XabcdAnnotation using the SciChartBuilder + final XabcdAnnotation xabcdAnnotation = sciChartBuilder.newXabcdAnnotation() + .withStroke(Color.YELLOW) + .withFill(Color.BLUE) + .withBasePoint(10, 30.6) + .withBasePoint(30, 31.5) + .withBasePoint(50, 30.3) + .withBasePoint(70, 31.5) + .withBasePoint(90, 30.6) + .withIsEditable(true) + .build(); + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(xabcdAnnotation); + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationCreationModifierFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationCreationModifierFragment.kt new file mode 100644 index 0000000..455712d --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationCreationModifierFragment.kt @@ -0,0 +1,61 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.modifiers.BrushAnnotationCreationModifier +import com.scichart.charting.visuals.SciChartSurface +import com.scichart.core.utility.touch.ModifierTouchEventArgs +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import android.graphics.Color + +@ExampleDefinition() +class BrushAnnotationCreationModifierFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addBrushAnnotationCreationModifier(surface: SciChartSurface) { + // + // Create a BrushAnnotationCreationModifier + val brushCreationModifier = BrushAnnotationCreationModifier().apply { + // Configure the modifier + brushColor = Color.WHITE + brushThickness = 4f + + // Optional: Set a listener to be notified when an annotation is created + setAnnotationCreationListener { newAnnotation -> + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true) + } + } + + // Add the modifier to the surface + surface.chartModifiers.add(brushCreationModifier) + // + } + + // + // Define a custom BrushAnnotationCreationModifier + private class CustomBrushAnnotationCreationModifier : BrushAnnotationCreationModifier() { + override fun onTouchDown(args: ModifierTouchEventArgs): Boolean { + // Custom logic before creation + return super.onTouchDown(args) + } + + override fun onTouchMove(args: ModifierTouchEventArgs): Boolean { + // Custom logic during creation + return super.onTouchMove(args) + } + + override fun onTouchUp(args: ModifierTouchEventArgs): Boolean { + // Custom logic after creation + return super.onTouchUp(args) + } + } + + fun useCustomBrushAnnotationCreationModifier(surface: SciChartSurface) { + // Use the custom modifier + val customModifier = CustomBrushAnnotationCreationModifier() + customModifier.brushColor = Color.YELLOW + + surface.chartModifiers.add(customModifier) + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationFragment.kt new file mode 100644 index 0000000..a979231 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/BrushAnnotationFragment.kt @@ -0,0 +1,35 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.visuals.SciChartSurface +import com.scichart.charting.visuals.annotations.tradingAnnotations.BrushAnnotation +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import android.graphics.Color + +@ExampleDefinition() +class BrushAnnotationFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addBrushAnnotation(surface: SciChartSurface) { + // + // Assume a surface has been created and configured somewhere + // Create a BrushAnnotation + val brushAnnotation = BrushAnnotation(context) + + // Configure the annotation + brushAnnotation.brushColor = Color.WHITE + brushAnnotation.brushThickness = 4f + + // Add some points + brushAnnotation.setBasePoint(10, 30.6) + brushAnnotation.setBasePoint(30, 31.5) + brushAnnotation.setBasePoint(50, 30.3) + + // Allow to interact with the annotation in run-time + brushAnnotation.setIsEditable(true) + + // Add the annotation to the AnnotationsCollection of a surface + surface.annotations.add(brushAnnotation) + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.kt new file mode 100644 index 0000000..75db81a --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationCreationModifierFragment.kt @@ -0,0 +1,59 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.modifiers.PitchforkAnnotationCreationModifier +import com.scichart.charting.visuals.SciChartSurface +import com.scichart.charting.visuals.annotations.IAnnotation +import com.scichart.charting.visuals.annotations.LineAnnotation +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import com.scichart.drawing.common.SolidPenStyle +import android.graphics.Color + +@ExampleDefinition() +class PitchforkAnnotationCreationModifierFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addPitchforkAnnotationCreationModifier(surface: SciChartSurface) { + // + // Create a PitchforkAnnotationCreationModifier + val pitchforkCreationModifier = PitchforkAnnotationCreationModifier().apply { + // Optional: Set a listener to be notified when an annotation is created + setAnnotationCreationListener { newAnnotation -> + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true) + } + } + + // Add the modifier to the surface + surface.chartModifiers.add(pitchforkCreationModifier) + // + } + + // + // Define a custom PitchforkAnnotationCreationModifier + private class CustomPitchforkAnnotationCreationModifier : PitchforkAnnotationCreationModifier() { + override fun configureRubberBandAnnotation(annotation: IAnnotation) { + super.configureRubberBandAnnotation(annotation) + + // Customize the rubber-band styling + if (annotation is LineAnnotation) { + annotation.stroke = SolidPenStyle(Color.YELLOW, true, 2f, floatArrayOf(10f, 5f)) + } + } + + override fun onAnnotationCreated(newAnnotation: IAnnotation) { + super.onAnnotationCreated(newAnnotation) + + // Custom logic after annotation is fully created + newAnnotation.setIsEditable(true) + } + } + + fun useCustomPitchforkAnnotationCreationModifier(surface: SciChartSurface) { + // Use the custom modifier + val customModifier = CustomPitchforkAnnotationCreationModifier() + + surface.chartModifiers.add(customModifier) + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationFragment.kt new file mode 100644 index 0000000..2859332 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/PitchforkAnnotationFragment.kt @@ -0,0 +1,38 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.visuals.SciChartSurface +import com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import android.graphics.Color +import com.scichart.drawing.common.SolidBrushStyle +import com.scichart.drawing.common.SolidPenStyle + +@ExampleDefinition() +class PitchforkAnnotationFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addPitchforkAnnotation(surface: SciChartSurface) { + // + // Assume a surface has been created and configured somewhere + // Create a PitchforkAnnotation + val pitchforkAnnotation = PitchforkAnnotation(context) + + // Specify the stroke and fill styles + pitchforkAnnotation.stroke = SolidPenStyle(Color.RED, true, 2f, null) + pitchforkAnnotation.sidesFill = SolidBrushStyle(Color.GREEN) + pitchforkAnnotation.middleFill = SolidBrushStyle(Color.BLUE) + + // Add 3 points to define the pitchfork + pitchforkAnnotation.setBasePoint(10, 30.6) // Handle (Point 0) + pitchforkAnnotation.setBasePoint(30, 31.5) // High (Point 1) + pitchforkAnnotation.setBasePoint(50, 30.3) // Low (Point 2) + + // Allow to interact with the annotation in run-time + pitchforkAnnotation.setIsEditable(true) + + // Add the annotation to the AnnotationsCollection of a surface + surface.annotations.add(pitchforkAnnotation) + // + } +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationCreationModifierFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationCreationModifierFragment.kt new file mode 100644 index 0000000..de2f757 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationCreationModifierFragment.kt @@ -0,0 +1,59 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.modifiers.XabcdAnnotationCreationModifier +import com.scichart.charting.visuals.SciChartSurface +import com.scichart.charting.visuals.annotations.IAnnotation +import com.scichart.charting.visuals.annotations.LineAnnotation +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import com.scichart.drawing.common.SolidPenStyle +import android.graphics.Color + +@ExampleDefinition() +class XabcdAnnotationCreationModifierFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addXabcdAnnotationCreationModifier(surface: SciChartSurface) { + // + // Create an XabcdAnnotationCreationModifier + val xabcdCreationModifier = XabcdAnnotationCreationModifier().apply { + // Optional: Set a listener to be notified when an annotation is created + setAnnotationCreationListener { newAnnotation -> + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true) + } + } + + // Add the modifier to the surface + surface.chartModifiers.add(xabcdCreationModifier) + // + } + + // + // Define a custom XabcdAnnotationCreationModifier + private class CustomXabcdAnnotationCreationModifier : XabcdAnnotationCreationModifier() { + override fun configureRubberBandAnnotation(annotation: IAnnotation) { + super.configureRubberBandAnnotation(annotation) + + // Customize the rubber-band styling + if (annotation is LineAnnotation) { + annotation.stroke = SolidPenStyle(Color.YELLOW, true, 2f, floatArrayOf(10f, 5f)) + } + } + + override fun onAnnotationCreated(newAnnotation: IAnnotation) { + super.onAnnotationCreated(newAnnotation) + + // Custom logic after annotation is fully created + newAnnotation.setIsEditable(true) + } + } + + fun useCustomXabcdAnnotationCreationModifier(surface: SciChartSurface) { + // Use the custom modifier + val customModifier = CustomXabcdAnnotationCreationModifier() + + surface.chartModifiers.add(customModifier) + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationFragment.kt new file mode 100644 index 0000000..c345b63 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/XabcdAnnotationFragment.kt @@ -0,0 +1,39 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.visuals.SciChartSurface +import com.scichart.charting.visuals.annotations.tradingAnnotations.XabcdAnnotation +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import android.graphics.Color +import com.scichart.drawing.common.SolidBrushStyle +import com.scichart.drawing.common.SolidPenStyle + +@ExampleDefinition() +class XabcdAnnotationFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addXabcdAnnotation(surface: SciChartSurface) { + // + // Assume a surface has been created and configured somewhere + // Create an XabcdAnnotation + val xabcdAnnotation = XabcdAnnotation(context) + + // Specify the stroke and fill + xabcdAnnotation.stroke = SolidPenStyle(Color.YELLOW, true, 2f, null) + xabcdAnnotation.fill = SolidBrushStyle(Color.BLUE) + + // Add 5 points (X, A, B, C, D) + xabcdAnnotation.setBasePoint(10, 30.6) + xabcdAnnotation.setBasePoint(30, 31.5) + xabcdAnnotation.setBasePoint(50, 30.3) + xabcdAnnotation.setBasePoint(70, 31.5) + xabcdAnnotation.setBasePoint(90, 30.6) + + // Allow to interact with the annotation in run-time + xabcdAnnotation.setIsEditable(true) + + // Add the annotation to the AnnotationsCollection of a surface + surface.annotations.add(xabcdAnnotation) + // + } +} diff --git a/templates/SciChart.Web/partials/head.tmpl.partial b/templates/SciChart.Web/partials/head.tmpl.partial index 2a684a6..904b949 100644 --- a/templates/SciChart.Web/partials/head.tmpl.partial +++ b/templates/SciChart.Web/partials/head.tmpl.partial @@ -14,7 +14,7 @@ - + diff --git a/templates/SciChart.Web/partials/scripts.tmpl.partial b/templates/SciChart.Web/partials/scripts.tmpl.partial index cf9a5dc..74290b7 100644 --- a/templates/SciChart.Web/partials/scripts.tmpl.partial +++ b/templates/SciChart.Web/partials/scripts.tmpl.partial @@ -1,6 +1,6 @@ {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} - +