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

[Solved] Databinding XStripeBrushes

1 Answer 63 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dave
Top achievements
Rank 1
Dave asked on 27 Sep 2014, 07:58 AM
I have a chart that shows data over the last 30 days. The horizontal axis is set to a DateTimeCategoricalAxis I would like to display a solid colour brush as an XStripeBrush on any day that is a weekend and transparency on weekdays. Is it possible to achieve this? My current chart looks like this

<Chart:RadCartesianChart Grid.Row="1" PaletteName="DefaultDark" Margin="0,20,0,0">
                    <Chart:RadCartesianChart.Grid>
                        <Chart:CartesianChartGrid  StripLinesVisibility="X" MajorLinesVisibility="XY">
   
                            <Chart:CartesianChartGrid.XStripeBrushes>
                                <SolidColorBrush Color="#FF1B1B1B"/>
                                <SolidColorBrush Color="Transparent"/>
                            </Chart:CartesianChartGrid.XStripeBrushes>
                        </Chart:CartesianChartGrid>
                    </Chart:RadCartesianChart.Grid>
                    <Chart:RadCartesianChart.HorizontalAxis>
                        <Chart:DateTimeCategoricalAxis LabelFormat="{}{0:dd-MMM}" DateTimeComponent="Day" LabelInterval="7"/>
                    </Chart:RadCartesianChart.HorizontalAxis>
                    <Chart:BarSeries ItemsSource="{Binding totalSales}">
                        <Chart:BarSeries.VerticalAxis>
                            <Chart:LinearAxis HorizontalLocation="Right"/>
                        </Chart:BarSeries.VerticalAxis>
                        <Chart:BarSeries.CategoryBinding>
                            <Chart:PropertyNameDataPointBinding PropertyName="date"/>
                        </Chart:BarSeries.CategoryBinding>
                        <Chart:BarSeries.ValueBinding>
                            <Chart:PropertyNameDataPointBinding PropertyName="sales"/>
                        </Chart:BarSeries.ValueBinding>
                    </Chart:BarSeries>
 
                    <Chart:SplineSeries CombineMode="Stack"
                    ItemsSource="{Binding sales_list}">
                        <Chart:SplineSeries.VerticalAxis>
                            <Chart:LinearAxis/>
                        </Chart:SplineSeries.VerticalAxis>
                        <Chart:SplineSeries.PointTemplate>
                            <DataTemplate>
                                <Ellipse Fill="#FF1F7EB8" Height="10" Width="10"/>
                            </DataTemplate>
                        </Chart:SplineSeries.PointTemplate>
                        <Chart:SplineSeries.CategoryBinding>
                            <Chart:PropertyNameDataPointBinding PropertyName="date"/>
                        </Chart:SplineSeries.CategoryBinding>
                        <Chart:SplineSeries.ValueBinding>
                            <Chart:PropertyNameDataPointBinding PropertyName="units.app.downloads"/>
                        </Chart:SplineSeries.ValueBinding>
                    </Chart:SplineSeries>
                    
                </Chart:RadCartesianChart>

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 01 Oct 2014, 03:10 PM
Hi Dave,

RadChart has no intrinsic support for this. A possible workaround here would be to redefine the XStripeBrushes collection dynamically, knowing the first date shown in the chart. This collection should always contain 7 entries -- two for the weekend days and 5 for the week days and their order would depend on the first date in the X axis range. E.g. if the first day shown in the chart is Wednesday, the order of brushes should be like this: WorkdayBrush-WorkdayBrush-WorkdayBrush-WeekendBrush-WeekendBrush-WorkdayBrush-WorkdayBrush.

Best regards,
Ves
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart for XAML
Asked by
Dave
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or