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

How to add a Gap between Horizontal Bar Chart Series ?

1 Answer 207 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Devid
Top achievements
Rank 1
Devid asked on 31 May 2019, 09:42 AM
In a Horizontal Bar Chart I want to add a small gap between the bar series. I have managed to do it in Vertical Bar Chart like this:

01.FrameworkElementFactory borderFramework = new FrameworkElementFactory(typeof(Border));
02.            borderFramework.SetValue(Border.BackgroundProperty, brush);
03.            borderFramework.SetValue(Border.OpacityProperty, 0.7D);
04. 
05.// set a small space between the bar/columns just like chartjs does it
06.                borderFramework.SetValue(Border.BorderThicknessProperty, new Thickness(2, 0, 2, 0));
07. 
08....  new BarSeries(){
09....
10. PointTemplate = new DataTemplate()
11.                {
12.                    VisualTree = borderFramework,
13.                },
14.}

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 05 Jun 2019, 06:17 AM
Hello Devid,

Thank you for sharing this solution. As for the horizontal bars, you can use the same approach, but instead of left and right border, you can apply top and bottom. Here is an example:
FrameworkElementFactory borderFramework1 = new FrameworkElementFactory(typeof(Border));
borderFramework1.SetValue(Border.BackgroundProperty, Brushes.Red);
borderFramework1.SetValue(Border.OpacityProperty, 0.7D);           
borderFramework1.SetValue(Border.BorderThicknessProperty, new Thickness(0, 2, 0, 2));
 
this.series1.PointTemplate = new DataTemplate()
{
    VisualTree = borderFramework1,
};

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ChartView
Asked by
Devid
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or