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

bar chart in reports

3 Answers 180 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
anu
Top achievements
Rank 1
anu asked on 20 Feb 2008, 10:29 AM
Hi.
I'm creating reports which contains horizontal bar chart.
I want to show the y axis in text form other than numeric, how can do it.
I tried to do it but its giving error.
Please help to solve the problem.
Anoop.

3 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 20 Feb 2008, 04:16 PM
Hi anu,

You can achieve your requirement for either of the axes. The AutoScale/AutoShrink functionality should be turned off for the respective axis and its Items collection should be filled with custom axis items. Each axis item can have a custom text set via the TextBlock.Text property.

Please note that when the chart is horizontally orientated the Y axis is parallel to the bottom line of the plot area, i.e. the axes change their places when rotating the chart.

If you experience any problems when implementing this approach, please open a support ticket and send us your sample code and a brief description of what exactly the chart should display.

Kind regards,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
anu
Top achievements
Rank 1
answered on 21 Feb 2008, 04:55 AM
Hi.
Thanks for the reply.
My requirement is something like a bar chart in which X axis should be project name and Y axis is  project status (like Open,Onhold,Closed  etc..) these status are static, i mean the order of status in Y axis will be always like Open first, then Onhold then Closed. The bar height for each project varies according to the project status which i will get from db.
Hope my reqiurement is clear.
How to do it?
Anoop.
0
Chavdar
Telerik team
answered on 21 Feb 2008, 04:45 PM
Hi anu,

Here is a sample implementation of your task (feel free to convert it to C#, if you are not using VB):

    Public Sub ConfigureChart(ByVal chart As Telerik.Reporting.Chart)

        chart.PlotArea.XAxis.AutoScale = False
        chart.PlotArea.XAxis.AutoShrink = False
        chart.PlotArea.XAxis.Items.Add(Me.CreateAxisItem(0, "Project 1"))
        chart.PlotArea.XAxis.Items.Add(Me.CreateAxisItem(1, "Project 2"))
        chart.PlotArea.XAxis.Items.Add(Me.CreateAxisItem(2, "Project 3"))

        chart.PlotArea.YAxis.AutoScale = False
        chart.PlotArea.YAxis.Items.Add(Me.CreateAxisItem(0, " "))
        chart.PlotArea.YAxis.Items.Add(Me.CreateAxisItem(1, "Open"))
        chart.PlotArea.YAxis.Items.Add(Me.CreateAxisItem(2, "On Hold"))
        chart.PlotArea.YAxis.Items.Add(Me.CreateAxisItem(3, "Closed"))
        chart.PlotArea.YAxis.Items.Add(Me.CreateAxisItem(4, " "))

        chart.PlotArea.Appearance.Dimensions.Margins.Left = Telerik.Reporting.Charting.Styles.Unit.Percentage(20)

        Dim s As New ChartSeries()
        s.Name = "Series 1"
        s.Type = ChartSeriesType.Bar

        chart.Series.Clear()
        chart.Series.Add(s)

        s.Items.Add(Me.CreateSeriesItem(2, "On Hold"))
        s.Items.Add(Me.CreateSeriesItem(3, "Closed"))
        s.Items.Add(Me.CreateSeriesItem(1, "Open"))

        chart.SeriesOrientation = ChartSeriesOrientation.Horizontal
    End Sub

    Public Function CreateAxisItem(ByVal value As Double, ByVal text As String) As ChartAxisItem
        Dim axisItem As New ChartAxisItem()
        axisItem.Value = value
        axisItem.TextBlock.Text = text
        Return axisItem
    End Function

    Public Function CreateSeriesItem(ByVal value As Double, ByVal label As String) As ChartSeriesItem
        Dim seriesItem As New ChartSeriesItem()
        seriesItem.YValue = value
        seriesItem.Label.TextBlock.Text = label
        Return seriesItem
    End Function

Please note that the purpose of this code is just to give you an idea of how to proceed and you can freely modify it to reflect your project requirements.

Greetings,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
anu
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
anu
Top achievements
Rank 1
Share this question
or