How to set opacity to background

1 Answer 38 Views
Chart (HTML5)
Petr
Top achievements
Rank 1
Iron
Petr asked on 24 Nov 2023, 10:53 AM

I am not able to set opacity for the background of HTML Chart.

I tried to setup in page

<PlotArea>
        <Appearance>
          <FillStyle BackgroundColor="#32FFFFFF" />
        </Appearance>

or in code

PlotArea.Appearance.FillStyle.BackgroundColor = Color.FromArgb(50, 255, 255, 255);

But the alpha component is always ignored and I see only white background. Is it possible to define some other way?

Thank you,

Petr

1 Answer, 1 is accepted

Sort by
1
Accepted
Vasko
Telerik team
answered on 24 Nov 2023, 01:37 PM

Hello Petr,

The HTML Chart control uses SVG elements in order to present the data. To adjust the opacity, you will need to use the fill-opacity CSS property: 

<style>
    .RadHtmlChart svg g {
        fill-opacity: .3; /* Adjust based on your preference */
    }
</style>

Hope this helps you out. 

Kind regards,
Vasko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Petr
Top achievements
Rank 1
Iron
commented on 24 Nov 2023, 03:03 PM

It works fine for plot area, but it is affecting also the legend which I don't want. I modified to use exact child for my area and it looks this is working fine:

.RadHtmlChart svg > g:nth-child(2) > path:nth-child(2) {      
      fill-opacity: .3;
    }
Thanks for your help
Tags
Chart (HTML5)
Asked by
Petr
Top achievements
Rank 1
Iron
Answers by
Vasko
Telerik team
Share this question
or