Reputation: 213
I have a chart application where I show frequency distribution of certain entities based on their values. I am displaying the chart in BarSeries(Telerik). I am using LinearGradientBrush as coloring the Bar based on each entity's weight in a certain bucket. The colors are unique for one entity. The LinearGradientBrush works perfectly as per its functionality but, my requirement is that separate color needs to be highlighted for separate entity and hence, the colors need not get mixed. Is there a way to achieve this in WPF?
Upvotes: 1
Views: 191
Reputation: 725
This is actually relatively easily done, all you have to do is get two of the colour you want and put the last point of the colour next to the next colour along. You'll get something like this
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterY="0.5" CenterX="0.5"/>
<SkewTransform CenterY="0.5" CenterX="0.5"/>
<RotateTransform Angle="-90" CenterY="0.5" CenterX="0.5"/>
<TranslateTransform/>
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="#FFBD1717" Offset="0"/>
<GradientStop Color="#FF970EB6" Offset="1"/>
<GradientStop Color="#FFBD1717" Offset="0.299"/>
<GradientStop Color="#FF175BBD" Offset="0.3"/>
<GradientStop Color="#FF089722" Offset="0.79"/>
<GradientStop Color="#FF175BBD" Offset="0.567"/>
<GradientStop Color="#FF089722" Offset="0.568"/>
<GradientStop Color="#FF970EB6" Offset="0.791"/>
</LinearGradientBrush>
Upvotes: 2