Show last value of line chart on y axis
Is it possible to show last value of the line chart at the right side of the chart or on y Axis?
See screenshot for examples
Hi Praveen,
Your requirement can be achieved by specifying ChartPrimaryYAxis RangePadding as None. This displays the axis minimum and maximum range based on data. We have prepared sample for your reference. Please check with the below snippet and screenshot.
|
<SfChart> <ChartPrimaryYAxis RangePadding="ChartRangePadding.None"></ChartPrimaryYAxis> </SfChart> |
Sample : https://blazorplayground.syncfusion.com/BtVziCWzrbKQQIYw
UG : https://blazor.syncfusion.com/documentation/chart/numeric-axis#range-padding
Kindly revert us if you have any concerns.
Regards,
Durga Gopalakrishnan.
Thanks for padding but I am looking to show the last Numeric Value of the line on Y Axis
In example screenshot I have is 470.82 shown in Green color
thanks
Praveen,
Your requirement can be achieved using annotations. We recommend assigning the maximum value of the Y-axis range to the annotation content in the `OnAxisActualRangeCalculated` event. Please refer to the snippet and sample provided below for implementation details.
|
<SfChart> <ChartEvents OnAxisActualRangeCalculated="RangeCalculated"></ChartEvents> <ChartAnnotations> <ChartAnnotation X="@xVal" Y="5%" CoordinateUnits="Units.Pixel"> <ContentTemplate> <div style="background-color: green; color:white; font-size: 13px;">@data</div> </ContentTemplate> </ChartAnnotation> </ChartAnnotations> </SfChart> @code { public void RangeCalculated(AxisRangeCalculatedEventArgs args) { if(args.AxisName == "PrimaryYAxis") { data = args.Maximum.ToString(); } } string data = ""; public string xVal = "102%"; } |
Sample : https://blazorplayground.syncfusion.com/hthpissvgvaNmOwo
UG : https://blazor.syncfusion.com/documentation/chart/chart-annotations
Please let us know if you have any concerns.
- 3 Replies
- 3 Participants
-
PD Praveen D
- Nov 14, 2024 01:41 AM UTC
- Nov 18, 2024 01:33 PM UTC