diff --git a/articles/chart2d/annotationsAPIs/Annotations APIs.md b/articles/chart2d/annotationsAPIs/Annotations APIs.md index a0482b0..ff41f06 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. | +| [FreehandDrawingAnnotation](xref:annotationsAPIs.FreehandDrawingAnnotation) | 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/FreehandDrawingAnnotation.md b/articles/chart2d/annotationsAPIs/FreehandDrawingAnnotation.md new file mode 100644 index 0000000..a2b3097 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/FreehandDrawingAnnotation.md @@ -0,0 +1,45 @@ +--- +uid: "annotationsAPIs.FreehandDrawingAnnotation" +--- + +# The FreehandDrawingAnnotation +The allows for freehand drawing on the chart: + +![Freehand Drawing 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.FreehandDrawingAnnotation.setBrushColor(int)): Sets the color of the brush stroke. +- [brushThickness](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.FreehandDrawingAnnotation.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.FreehandDrawingAnnotation.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.FreehandDrawingAnnotation.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 FreehandDrawingAnnotation +A can be added onto a chart using the following code: + +# [Java](#tab/java) +[!code-java[AddFreehandDrawingAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationFragment.java#AddFreehandDrawingAnnotation)] +# [Java with Builders API](#tab/javaBuilder) +[!code-java[AddFreehandDrawingAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/FreehandDrawingAnnotationFragment.java#AddFreehandDrawingAnnotation)] +# [Kotlin](#tab/kotlin) +[!code-swift[AddFreehandDrawingAnnotation](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationFragment.kt#AddFreehandDrawingAnnotation)] +*** + +> [!NOTE] +> For interactive creation of the `FreehandDrawingAnnotation`, use the [FreehandDrawingAnnotationCreationModifier](xref:annotationsAPIs.FreehandDrawingAnnotationCreationModifier). + +> [!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/FreehandDrawingAnnotationCreationModifier.md b/articles/chart2d/annotationsAPIs/FreehandDrawingAnnotationCreationModifier.md new file mode 100644 index 0000000..0843c10 --- /dev/null +++ b/articles/chart2d/annotationsAPIs/FreehandDrawingAnnotationCreationModifier.md @@ -0,0 +1,45 @@ +--- +uid: "annotationsAPIs.FreehandDrawingAnnotationCreationModifier" +--- + +# The FreehandDrawingAnnotationCreationModifier +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 `FreehandDrawingAnnotation` and populates it with points based on the user's movement. + +## Properties +The following properties can be used to configure the `FreehandDrawingModifier`: + +| Property | Description | +| --- | --- | +| [brushColor](xref:com.scichart.charting.modifiers.FreehandDrawingModifier.setBrushColor(int)) | Sets the color of the brush stroke for the annotations created by this modifier. | +| [brushThickness](xref:com.scichart.charting.modifiers.FreehandDrawingModifier.setBrushThickness(float)) | Sets the thickness of the brush stroke for the annotations created by this modifier. | +| [xAxisId](xref:com.scichart.charting.modifiers.FreehandDrawingModifier.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.FreehandDrawingModifier.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.FreehandDrawingModifier.setAnnotationCreationListener(com.scichart.charting.modifiers.OnAnnotationCreatedListener)): Passes the newly created annotation instance to the listener. + +## Using FreehandDrawingModifier +The following code demonstrates how to add and configure a `FreehandDrawingModifier`: + +# [Java](#tab/java) +[!code-java[AddFreehandDrawingAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.java#AddFreehandDrawingAnnotationCreationModifier)] +# [Kotlin](#tab/kotlin) +[!code-swift[AddFreehandDrawingAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.kt#AddFreehandDrawingAnnotationCreationModifier)] +*** + +## Customizing the Modifier +You can customize the behavior of the `FreehandDrawingModifier` 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[CustomFreehandDrawingAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.java#CustomFreehandDrawingAnnotationCreationModifier)] +### [Kotlin](#tab/kotlin) +[!code-swift[CustomFreehandDrawingAnnotationCreationModifier](../../../samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.kt#CustomFreehandDrawingAnnotationCreationModifier)] +*** + +> [!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..9be4e26 --- /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. +- [fullWidthZoneFill](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation.setFullWidthZoneFill(com.scichart.drawing.common.BrushStyle)): Sets the brush style for the outer full-width filled zones (the regions alongside the outer tine lines). +- [halfWidthZoneFill](xref:com.scichart.charting.visuals.annotations.tradingAnnotations.PitchforkAnnotation.setHalfWidthZoneFill(com.scichart.drawing.common.BrushStyle)): Sets the brush style for the inner half-width filled zone 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..33bb104 100644 --- a/articles/chart2d/annotationsAPIs/toc.yml +++ b/articles/chart2d/annotationsAPIs/toc.yml @@ -1,6 +1,9 @@ - name: "BoxAnnotation" href: "BoxAnnotation.md" +- name: "FreehandDrawingAnnotation" + href: "FreehandDrawingAnnotation.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: "FreehandDrawingAnnotationCreationModifier" + href: "FreehandDrawingAnnotationCreationModifier.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/FreehandDrawingAnnotationCreationModifierFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.java new file mode 100644 index 0000000..70b6ea4 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.java @@ -0,0 +1,68 @@ +package com.scichart.docsandbox.examples.java.annotationsAPIs; + +import androidx.annotation.NonNull; + +import com.scichart.charting.modifiers.FreehandDrawingModifier; +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 FreehandDrawingAnnotationCreationModifierFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addFreehandDrawingAnnotationCreationModifier(@NonNull SciChartSurface surface) { + // + // Create a FreehandDrawingModifier + final FreehandDrawingModifier freehandModifier = new FreehandDrawingModifier(); + + // Configure the modifier + freehandModifier.setBrushColor(Color.WHITE); + freehandModifier.setBrushThickness(4f); + + // Optional: Set a listener to be notified when an annotation is created + freehandModifier.setAnnotationCreationListener(newAnnotation -> { + // Configure the newly created annotation if needed + newAnnotation.setIsEditable(true); + }); + + // Add the modifier to the surface + surface.getChartModifiers().add(freehandModifier); + // + } + + // + // Define a custom FreehandDrawingModifier + private static class CustomFreehandDrawingModifier extends FreehandDrawingModifier { + @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 useCustomFreehandDrawingModifier(@NonNull SciChartSurface surface) { + // Use the custom modifier + final CustomFreehandDrawingModifier customModifier = new CustomFreehandDrawingModifier(); + customModifier.setBrushColor(Color.YELLOW); + + surface.getChartModifiers().add(customModifier); + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationFragment.java new file mode 100644 index 0000000..ba2c021 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/java/annotationsAPIs/FreehandDrawingAnnotationFragment.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.FreehandDrawingAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class FreehandDrawingAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addFreehandDrawingAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create a FreehandDrawingAnnotation + final FreehandDrawingAnnotation freehandAnnotation = new FreehandDrawingAnnotation(getContext()); + + // Allow to interact with the annotation in run-time + freehandAnnotation.setIsEditable(true); + + // Specify the brush color and thickness + freehandAnnotation.setBrushColor(Color.WHITE); + freehandAnnotation.setBrushThickness(4f); + + // Add points to the FreehandDrawingAnnotation + freehandAnnotation.setBasePoint(10, 30.6); + freehandAnnotation.setBasePoint(30, 31.5); + freehandAnnotation.setBasePoint(50, 30.3); + + // Add the annotation to the AnnotationsCollection of a surface + surface.getAnnotations().add(freehandAnnotation); + // + } +} 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..0c8a186 --- /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.setFullWidthZoneFill(new SolidBrushStyle(Color.GREEN)); + pitchforkAnnotation.setHalfWidthZoneFill(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/FreehandDrawingAnnotationFragment.java b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/FreehandDrawingAnnotationFragment.java new file mode 100644 index 0000000..22ea207 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/javaBuilder/annotationsAPIs/FreehandDrawingAnnotationFragment.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.FreehandDrawingAnnotation; +import com.scichart.docsandbox.core.ExampleDefinition; +import com.scichart.docsandbox.examples.base.SingleChart2DFragment; +import android.graphics.Color; + +@ExampleDefinition() +public class FreehandDrawingAnnotationFragment extends SingleChart2DFragment { + @Override + protected void initExample(@NonNull SciChartSurface surface) { } + + void addFreehandDrawingAnnotation(@NonNull SciChartSurface surface) { + // + // Assume a surface has been created and configured somewhere + // Create a FreehandDrawingAnnotation using the SciChartBuilder + final FreehandDrawingAnnotation freehandAnnotation = sciChartBuilder.newFreehandDrawingAnnotation() + .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(freehandAnnotation); + // + } +} 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..3f27527 --- /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) + .withFullWidthZoneFill(Color.GREEN) + .withHalfWidthZoneFill(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/FreehandDrawingAnnotationCreationModifierFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.kt new file mode 100644 index 0000000..765c440 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationCreationModifierFragment.kt @@ -0,0 +1,61 @@ +package com.scichart.docsandbox.examples.kotlin.annotationsAPIs + +import com.scichart.charting.modifiers.FreehandDrawingModifier +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 FreehandDrawingAnnotationCreationModifierFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addFreehandDrawingAnnotationCreationModifier(surface: SciChartSurface) { + // + // Create a FreehandDrawingModifier + val freehandModifier = FreehandDrawingModifier().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(freehandModifier) + // + } + + // + // Define a custom FreehandDrawingModifier + private class CustomFreehandDrawingModifier : FreehandDrawingModifier() { + 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 useCustomFreehandDrawingModifier(surface: SciChartSurface) { + // Use the custom modifier + val customModifier = CustomFreehandDrawingModifier() + customModifier.brushColor = Color.YELLOW + + surface.chartModifiers.add(customModifier) + } + // +} diff --git a/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationFragment.kt b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationFragment.kt new file mode 100644 index 0000000..a2b7812 --- /dev/null +++ b/samples/sandbox/app/src/main/java/com/scichart/docsandbox/examples/kotlin/annotationsAPIs/FreehandDrawingAnnotationFragment.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.FreehandDrawingAnnotation +import com.scichart.docsandbox.core.ExampleDefinition +import com.scichart.docsandbox.examples.base.SingleChart2DFragment +import android.graphics.Color + +@ExampleDefinition() +class FreehandDrawingAnnotationFragment : SingleChart2DFragment() { + override fun initExample(surface: SciChartSurface) {} + + fun addFreehandDrawingAnnotation(surface: SciChartSurface) { + // + // Assume a surface has been created and configured somewhere + // Create a FreehandDrawingAnnotation + val freehandAnnotation = FreehandDrawingAnnotation(context) + + // Configure the annotation + freehandAnnotation.brushColor = Color.WHITE + freehandAnnotation.brushThickness = 4f + + // Add some points + freehandAnnotation.setBasePoint(10, 30.6) + freehandAnnotation.setBasePoint(30, 31.5) + freehandAnnotation.setBasePoint(50, 30.3) + + // Allow to interact with the annotation in run-time + freehandAnnotation.setIsEditable(true) + + // Add the annotation to the AnnotationsCollection of a surface + surface.annotations.add(freehandAnnotation) + // + } +} 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..e97f35e --- /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.fullWidthZoneFill = SolidBrushStyle(Color.GREEN) + pitchforkAnnotation.halfWidthZoneFill = 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.}} - +