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

Image_5757_1731548448675


3 Replies

DG Durga Gopalakrishnan Syncfusion Team November 14, 2024 08:18 AM UTC

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.



PD Praveen D November 15, 2024 04:36 AM UTC

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




KP Krithiga Perumal Syncfusion Team November 18, 2024 01:33 PM UTC

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.


Loader.
Up arrow icon