Articles in this section
Category / Section

How to set the gradient color for the Javascript Area Chart?

2 mins read

Description

This article shows how to set the gradient color for the Area chart.

Solution

A gradient color is a visual representation of the range of colors arranged in a smooth transition from one color to another. This gradient color is filled in the Chart by using the fill property in the series of a chart. You can create a linear-gradient SVG and then set the ID of it to the fill property in the series.

Code Snippet

The following code shows how to add the gradient color to the series.

index.html

<svg>
<defs>
   <linearGradient id="grad1" x1="100%" y1="0%" x2="0%" y2="100%">
   <stop offset="0%" style="stop-color: #85e6b9;stop-opacity:1" />
   <stop offset="100%" style="stop-color:#d8f7e8;stop-opacity:0.5" />
   </linearGradient>
</defs>
</svg>

index.ts

series: [
 {
     dataSource: [
        { x: "Mon", y: 0.5 }, { x: "Tue", y: 1 },
        { x: "Wed", y: 2 }, { x: "Thur", y: 1.2 },
        { x: "Fri", y: 2.3 }, { x: "Sat", y: 0.5 },
        { x: "Sun", y: 1 }
     ],
     fill: "url('#grad1')",
     xName: 'x', yName: 'y', type: 'SplineArea',
     border: { color: "transparent" },
          opacity: 1
   }
]

The following image illustrates the output of the above code.

image.png

View Sample in Stackblitz

Conclusion

You can refer to our Javascript Charts feature tour page to learn about its other features and documentation, and how to quickly get started for configuration specifications. You can also explore our Javascript Charts example to understand how to create and visualize 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 comment 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
Please  to leave a comment
Access denied
Access denied