Ticket T978783
Visible to All Users

Chart - How to apply a gradient background color to each Area series

created 4 years ago

Hi, is it possible to add a subtle gradient to the Area series of a dxChart as shown in the image attached?

If not, is this something that is likely to be implemented soon? Or something I could implement myself? We already use Chart.js elsewhere on the site and it supports this functionality, so I really need to be able to replicate it somehow.

Many thanks

Answers approved by DevExpress Support

created 4 years ago (modified 2 years ago)

Hi Chris,

You can do this by adding a gradient via svg and linking it to a chart series via the color option. For example:

Razor
<svg> <defs> <linearGradient id="Gradient2" x1="0" x2="1" y1="0" y2="0"> <stop offset="0%" stop-color="red"/> <stop offset="50%" stop-color="black" stop-opacity="0"/> <stop offset="100%" stop-color="blue"/> </linearGradient> </defs> </svg> // series configuration s.Add()....Color("url('#Gradient2')")

Updated:
We created a Chart example that demonstrates how to customize the component appearance by configuring different SVG patterns: Chart for DevExtreme - How to configure different SVG patterns for appearance customization.

Regards,
Luis

    Show previous comments (13)
    DevExpress Support Team 4 years ago

      Hi,

      Thank you for the screenshot. I tested your solution in this CodePen sample and the Chart exports properly. So, could you please send us a simple sample illustrating your current scenario? You can modify this sample as a starting point. It will help us find the most suitable solution for you.

      Regards,
      Patrick

        Hi Patrick,

        Thanks for getting back to me - your sample has provided clarification.
        The specific issue is with the stop-opacity attribute on the gradient e.g.:

        XML
        <stop offset="0%" stop-color="red" stop-opacity="0"/> <stop offset="100%" stop-color="red" stop-opacity="1"/>

        This gets drawn in the chart but is not rendered in the export. Presumably the stop-opacity attribute is not supported by the export markup to PNG functionality. I can replace it with the colours directly if this is the case.

        Many thanks again!

        DevExpress Support Team 4 years ago

          Hi,

          You're welcome! Please feel free to contact us if you encounter any further issues.

          Regards,
          Patrick

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.