This is a migrated thread and some comments may be shown as answers.
RadChart CustomGridLine
9 Answers 52 Views
This is a migrated thread and some comments may be shown as answers.
Amy
Top achievements
Rank 1
Amy asked on 14 Mar 2011, 07:35 PM
Hi,

Is it possible to set the YIntercept of a CustomGridLine in the RadChart DataBound event?

Thanks,
Amy

9 Answers, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 17 Mar 2011, 04:12 PM
Hi Amy,

You can achieve this by getting the CustomGridLine through the Annotations collection, for example:

<telerik:RadChart.DefaultView>
    <telerik:ChartDefaultView>
        <telerik:ChartDefaultView.ChartArea>
            <telerik:ChartArea>
                <telerik:ChartArea.Annotations>
                    <telerik:CustomGridLine
                                    YIntercept="2"
                                    Stroke="Red"
                                    StrokeThickness="2" />
                </telerik:ChartArea.Annotations>
            </telerik:ChartArea>
        </telerik:ChartDefaultView.ChartArea>
    </telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>

private void radChart_DataBound(object sender, ChartDataBoundEventArgs e)
{
    (radChart.DefaultView.ChartArea.Annotations[0] as CustomGridLine).YIntercept = 5;
}

Another way to set the YIntercept in the DataBound event is to create the CustomGridLine from the code behind:
private void radChart_DataBound(object sender, ChartDataBoundEventArgs e)
{
    CustomGridLine gridline = new CustomGridLine();
    gridline.YIntercept = 5;
    gridline.Stroke = new SolidColorBrush(Colors.Red);
    gridline.StrokeThickness = 2;
    radChart.DefaultView.ChartArea.Annotations.Add(gridline);
}

I hope this helps.

All the best,
Polina
the Telerik team
0
Amy
Top achievements
Rank 1
answered on 17 Mar 2011, 04:28 PM
Thank you Polina.

I actually tried the first method you described originally by setting the CustomGridLine in the XAML file and then setting the YIntercept in the DataBound event.  However, I was trying to access the CustomGridLine using the Name property of the CustomGridLine rather than an index in the Annotations collection - which did not work.

I then used the second method you described creating the CustomGridLine in code which worked just fine.

However, I've now decided to revert back to the first method since I'd rather define my controls in the XAML file.

Thanks again,
Amy
0
Missing User
answered on 22 Mar 2011, 02:38 PM
Hi Amy,

As I mentioned in the previous post, when you define CustomGridLine in the XAML file, the available approach to access the CustomGridLine in the DataBound event is via the Annotations collection.

All the best,
Polina
the Telerik team
0
Michael
Top achievements
Rank 1
answered on 11 Oct 2011, 06:05 PM
Hi Polina

I need your help on this matter:
For current WPF project I must create a report with an embedded Chart which must display horizontal gridlines (corresponding to Y axis) for certain values (not major or minor gridlines!). Please see attached file.

Short explanations: on X axis: time, on Y axis: weight (kg)

After one working day I couldn't find any solution.
Any help will be appreciated (an example would be great).

Thanks a lot!!
Dan
0
Sia
Telerik team
answered on 12 Oct 2011, 01:53 PM
Hello Michael,

Please check the following example. The line you see there is a custom gridline. The same example (with shared source code) is available in our demos for WPF.

Best wishes,
Sia
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Michael
Top achievements
Rank 1
answered on 12 Oct 2011, 07:03 PM
Hi Sia

As I said in previous message Chart is embedded into a report.
Report is loaded into WPF project.

I've tried to find a way to implement your example in code because as you can know I don't have access to xaml there :).
Can you provide me with another example focused on this scenario?

I know this is not the right place for this posting because it's focused on WPF, but here I found similar questions; in Reports support I couldn't found anything.

Thanks a lot!
0
Sia
Telerik team
answered on 17 Oct 2011, 05:05 PM
Hello Dan,

First of all, please excuse me for the misunderstanding. Since you are using Reporting for WPF, there you can use only marked zones, but not grid lines. The only possible workaround which comes to my mind is to set a thin marked zone for every custom gridline.

Regards,
Sia
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Michael
Top achievements
Rank 1
answered on 18 Oct 2011, 11:23 AM
Hi Sia

Your sugestion it solved my problem for the moment.
Thank you a lot!


Dan
0
Asawin
Top achievements
Rank 1
answered on 21 Nov 2012, 02:16 AM

i would like to display graph on yxis  like image below can I do that please advise to me

 

Tags
Chart
Asked by
Amy
Top achievements
Rank 1
Answers by
Missing User
Amy
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Sia
Telerik team
Asawin
Top achievements
Rank 1
Share this question
or