Articles in this section

How to customize chart with svg gradient background in Blazor Charts?

This article explains how to customize a chart with a svg gradient background in Blazor Charts.

Customize a Chart with an SVG Gradient Background

Blazor Charts provides an option to customize a chart with a svg gradient background.

This can be achieved by using an SVG linear gradient to customize the chart component and changing specific chart properties.

The below code example demonstrates how to customize a chart with a svg gradient background.

Index.razor

In this code snippet, an SVG linear gradient is used to create a smooth transition effect for the chart’s background. This gradient is applied by referencing it in the chart’s ChartArea component

The chart itself is customized with various properties to enhance its functionality and appearance. The axes are configured to display a range of values, and crosshair tooltips are enabled to provide detailed information when users interact with the chart.

<SfChart>
   <ChartArea Background="url(#grad1)">
   </ChartArea>
   <ChartPrimaryXAxis Minimum="0" Maximum="2040" Interval="200">
       <ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
       <ChartAxisCrosshairTooltip Enable="true"></ChartAxisCrosshairTooltip>
   </ChartPrimaryXAxis>
   <ChartPrimaryYAxis IsInversed="true" OpposedPosition="true" Minimum="0" Maximum="2040" Interval="200">
       <ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
       <ChartAxisCrosshairTooltip Enable="true"></ChartAxisCrosshairTooltip>
   </ChartPrimaryYAxis>
   <ChartCrosshairSettings Enable="true" LineType="Syncfusion.Blazor.Charts.LineType.Both">
       <ChartCrosshairLine Color="white"></ChartCrosshairLine>
   </ChartCrosshairSettings>
</SfChart>

<svg style="height: 0">
   <defs>
       <linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
           <stop offset="20%" style="stop-color:orange;stop-opacity:1" />
           <stop offset="100%" style="stop-color:black;stop-opacity:1" />
       </linearGradient>
   </defs>
</svg>

The following screenshot illustrates the output of the code snippet.

msedge_Fs6OQ87Ssi.png

Live sample for customize a chart with a svg gradient

Conclusion

I hope you enjoyed learning how to customize a chart with a svg gradient background in Blazor Charts.

You can refer to our Blazor Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Chart example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied