ChartItem Gradient

4 posts, 0 answers
  1. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 19 Oct 2010 Link to this post

    Hi,

    Is it possible to remove the default gradient applied on a ChartItem?

    Cheers,
    Ganesh
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 20 Oct 2010 Link to this post

    Hi Ganesh,

    Can you please supply some additional details concerning your implementation?
    What type of chart are you using? 
    Any additional information will help us better address the question at hand.

    Kind regards,
    Evgenia
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 20 Oct 2010 Link to this post

    Hi Evgenia,

    I want to disable the jewel look in the chart item. For that we could do this

    <UserControl.Resources
            <Style x:Name="CustomStyle" TargetType="telerik:Bar"
                <Setter Property="Template"
                    <Setter.Value
                        <ControlTemplate TargetType="telerik:Bar"
                            <Canvas
                                <Rectangle x:Name="PART_DefiningGeometry"
                                       RadiusX="5" 
                                       RadiusY="5" 
                                           Height="{TemplateBinding ItemActualHeight}"
                                   Width="{TemplateBinding ItemActualWidth}"
                                       StrokeThickness="2"
                                       Fill="Blue" /> 
                            </Canvas
                        </ControlTemplate
                    </Setter.Value
                </Setter
            </Style
        </UserControl.Resources>

    But notice that I have set Fill to Blue. That will result in all items to become blue. I am using the CustomItemStyleDelegate to selective apply style (basically brush) for each chart item. But that doesnt seem to work anymore because of the hardcoding of "Blue" in the PART_DefiningGeometry.

    Cheers,
    Ganesh 
  4. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 22 Oct 2010 Link to this post

    Hello Ganesh,

    I'm pasting the answer I gave in your support ticket:
    You can't disable jewel look of the Bars by applying CustomtItemStyleDelegate as this will only change the color of the Bar. Instead you should re-template the bars with this Style by setting it in your App.xaml Resources:
    <Style x:Name="CustomStyle" TargetType="telerik:Bar"
                <Setter Property="Template"
                    <Setter.Value
                        <ControlTemplate TargetType="telerik:Bar"
                            <Canvas
                                <Rectangle x:Name="PART_DefiningGeometry"
                               Height="{TemplateBinding ItemActualHeight}"
                                   Width="{TemplateBinding ItemActualWidth}"
                                       StrokeThickness="2"
                                       Fill="Blue" /> 
                            </Canvas
                        </ControlTemplate
                    </Setter.Value
                </Setter
            </Style

    Set the style to your series in CreateDataSeriesFromDataPoints method of your class MyChart.cs :
    Copy Code
    private void CreateDataSeriesFromDataPoints(IEnumerable<int> dataPointValues)
            {
                var index = 0;
                foreach(var dataPointValue in dataPointValues)
                {
                    var dataPoint = new DataPoint {YValue = dataPointValue, DataItem = DataItem};
                    var series = new DataSeries {Definition = new HorizontalStackedBarSeriesDefinition()};                
      
                    series.Definition.ItemStyle = Application.Current.Resources["CustomStyle"] as Style;
      
                    series.Add(dataPoint);
      
                    _dataSeries.Add(series);
                    index++;
                }
      
                (_dataSeries[0].Definition as HorizontalStackedBarSeriesDefinition).Appearance.Fill = new SolidColorBrush(Colors.Purple);
            }
    NOTE that your first series will have Purple color and your second series - the color set in your App.xaml (Blue). Feel free to change these colors so that they apply your needs.

    As a side note - please choose one of the threads(Forum or Support) so that it's easier for me and you to follow the correspondence.

    All the best,
    Evgenia
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top