How to add an avg line to a chart

Is there any possibility to add an avg line to my chart as per the example below?


Thanks in advance.

Regards.


1 Reply

GV Gopalakrishnan Veeraraghavan Syncfusion Team June 14, 2023 01:06 PM UTC

Hi Waldemar,


We have analyzed your query. We suggest rendering the chart with an average line by using the Stripline feature. Set the value to Dasharray API and set the value as pixels in the SizeType API in the Stripline property. Customize the text using the ChartStriplineTextStyle property and align the text using the HorizontalAlignment and VerticalAlignment APIs. We have attached a sample and screenshot for your reference. Please check with the below code snippet.



<ChartPrimaryYAxis Minimum="0" Maximum="3.5" Interval="0.5">

        <ChartStriplines>

            <ChartStripline DashArray="20,20" SizeType="SizeType.Pixel" Text="2.5 avg. hours" HorizontalAlignment="Anchor.Start" VerticalAlignment="Anchor.End" Start="2.5" Color="#3a69d3">

                <ChartStriplineTextStyle Size="15px" Color="#3a69d3" />

            </ChartStripline>       

        </ChartStriplines>

</ChartPrimaryYAxis>


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp41507048771.zip


Screenshot:

A picture containing screenshot, line, plot, text

Description automatically generated



UG: https://blazor.syncfusion.com/documentation/chart/strip-line#horizontal-striplines


Kindly revert us if you have any concerns.


Regards,

Gopalakrishnan Veeraraghavan


Loader.
Up arrow icon