Remove opacity from bar char series

Thread is closed for posting
3 posts, 1 answers
  1. Ryan
    Ryan avatar
    9 posts
    Member since:
    Jun 2012

    Posted 05 Apr 2013 Link to this post

    Is there any way to make the bar chartseriesitem non transparent when using the gradient fillstye?  It doesn't seem like this should be the default, and the main / second color opacity is read only.  I have a simple function that builds a couple of series for the chart, and the user wants the bars to not have transparency.

    Public Sub SetChartSeries()
        Dim oList As New List(Of tblDashboardStat)
        Dim db As New BusIntDataContext
        Dim oSeriesPrior As New ChartSeries
        Dim oSeriesCur As New ChartSeries
        oList = (From d In db.tblDashboardStats
                 Where d.statGroupID = 1
                 Order By d.statSeriesName Descending, d.statSeriesOrder Ascending).ToList
        For Each item As tblDashboardStat In oList
            Dim oChartSeriesItem As New ChartSeriesItem((item.statSeriesValue1) / 1000000)
            oChartSeriesItem.Appearance.Border.Color = Drawing.ColorTranslator.FromHtml(item.statSeriesColor)
            oChartSeriesItem.Appearance.FillStyle.FillType = Styles.FillType.Gradient
            'oChartSeriesItem.Appearance.FillStyle.MainColorOpacity   --->  THIS IS READ ONLY
            oChartSeriesItem.Appearance.FillStyle.MainColor = Drawing.ColorTranslator.FromHtml(item.statSeriesColor)
            oChartSeriesItem.ActiveRegion.Tooltip = String.Format("{0:n1}", item.statSeriesValue1)
            If item.statSeriesName = "Prior" Then
                hdnColor1.Value = item.statSeriesColor
                hdnColor2.Value = item.statSeriesColor
            End If
    End Sub
  2. Answer
    Petar Kirov
    Petar Kirov avatar
    425 posts

    Posted 10 Apr 2013 Link to this post

    Hi Ryan,

    To make the bars non-transparent, when creating the series items, just set the oChartSeriesItem.Appearance.FillStyle.SecondColor property to Color.White or to any other color with alpha = 255 (the default second color for some chart skins is transparent).

    I hope this helps.
    Petar Kirov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
  4. Ryan
    Ryan avatar
    9 posts
    Member since:
    Jun 2012

    Posted 10 Apr 2013 Link to this post

    Thanks this works.  I also got around this by adding a complex gradient.

    Dim oChartSeriesItem As New ChartSeriesItem((item.statSeriesValue1) / 1000000)
    oChartSeriesItem.Appearance.Border.Color = Drawing.ColorTranslator.FromHtml(item.statSeriesColor)
    oChartSeriesItem.Appearance.FillStyle.FillType = Styles.FillType.ComplexGradient
    oChartSeriesItem.Appearance.FillStyle.FillSettings.ComplexGradient.Add(New GradientElement(Drawing.ColorTranslator.FromHtml(item.statSeriesColor), 0))
    oChartSeriesItem.Appearance.FillStyle.FillSettings.ComplexGradient.Add(New GradientElement(Drawing.ColorTranslator.FromHtml(item.statSeriesColor), 0.5))
    oChartSeriesItem.Appearance.FillStyle.FillSettings.ComplexGradient.Add(New GradientElement(Drawing.Color.White, 1))
Back to Top