This is a migrated thread and some comments may be shown as answers.

ChartItem Gradient

3 Answers 89 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Ganesh Shivshankar
Top achievements
Rank 1
Ganesh Shivshankar asked on 19 Oct 2010, 11:29 AM
Hi,

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

Cheers,
Ganesh

3 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 20 Oct 2010, 03:17 PM
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
0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 21 Oct 2010, 04:24 AM
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 
0
Evgenia
Telerik team
answered on 22 Oct 2010, 02:13 PM
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
Tags
Chart
Asked by
Ganesh Shivshankar
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Ganesh Shivshankar
Top achievements
Rank 1
Share this question
or