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

How to Add Y Axis Label on Bar Graph

11 Answers 427 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Iris
Top achievements
Rank 1
Iris asked on 12 Jun 2013, 04:32 AM
The attachement shows show my graph looks like.

I want to display the labels on the y-axis instead of the default "ALL" text. How do I do this?

Secondly, the x-axis starts at 1 as shown in the attachment. How do I make it start at 0?

Thanks.

11 Answers, 1 is accepted

Sort by
0
Iris
Top achievements
Rank 1
answered on 14 Jun 2013, 08:48 AM
I have managed to make the x-axis to start at 0 but still failed to show the labels on the y-axis.

I have checked the demo videos, but in the videos, Chart object is used instead of Graph.
0
Stef
Telerik team
answered on 14 Jun 2013, 04:58 PM
Hi Iris,

Please check the settings of the attached XML report definition. It is created with Telerik Reporting Q2 2013 Standalone Designer tool.

If you need further help, elaborate on the data structure and desired Graph item layout.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Iris
Top achievements
Rank 1
answered on 17 Jun 2013, 04:05 AM
Stef, thank you for replying.

I have taken a look at the code provided, particularly this line:
<BarSeries CoordinateSystem="cartesianCoordinateSystem1" CategoryGroup="categoryGroup" SeriesGroup="xGroup" X="=Sum(Fields.y1)" DataPointLabel="=Sum(Fields.y1)" Legend="=Fields.x + '/' + 'Sum(y1)'" LegendFormat="">

I see that you set the y -axis value to DataPointLabel properties. I did the same thing on my code:

this.barSeries1.DataPointLabel = "=Fields.PRODUCT_BAR_CODE_NUMBER + \' \' + Fields.product_short_name";
this.barSeries1.DataPointLabelStyle.Visible = true;
this.barSeries1.DataPointLabelAlignment = Telerik.Reporting.BarDataPointLabelAlignment.InsideBase;

However, none of the options provided by DataPointLabelAlignment properties allows me to put the label on the left side of the y-axis.

Here's the full designer code for this graph:

// graph1
//
graphGroup1.Name = "categoryGroup";
this.graph1.CategoryGroups.Add(graphGroup1);
this.graph1.CoordinateSystems.Add(this.cartesianCoordinateSystem1);
this.graph1.DataSource = this.sqlDataSource1;
this.graph1.Legend.Style.LineColor = System.Drawing.Color.LightGray;
this.graph1.Legend.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
this.graph1.Legend.Style.Visible = false;
this.graph1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.099999986588954926D), Telerik.Reporting.Drawing.Unit.Inch(0.1000000610947609D));
this.graph1.Name = "graph1";
this.graph1.PlotAreaStyle.LineColor = System.Drawing.Color.LightGray;
this.graph1.PlotAreaStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
this.graph1.Series.Add(this.barSeries1);
graphGroup4.Groupings.Add(new Telerik.Reporting.Grouping("=Fields.product_short_name"));
graphGroup4.Name = "product_short_nameGroup";
graphGroup4.Sortings.Add(new Telerik.Reporting.Sorting("=Fields.product_short_name", Telerik.Reporting.SortDirection.Asc));
this.graph1.SeriesGroups.Add(graphGroup4);
this.graph1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(6.7000007629394531D), Telerik.Reporting.Drawing.Unit.Inch(2.7000000476837158D));
this.graph1.Style.Padding.Bottom = Telerik.Reporting.Drawing.Unit.Pixel(10D);
this.graph1.Style.Padding.Left = Telerik.Reporting.Drawing.Unit.Pixel(10D);
this.graph1.Style.Padding.Right = Telerik.Reporting.Drawing.Unit.Pixel(10D);
this.graph1.Style.Padding.Top = Telerik.Reporting.Drawing.Unit.Pixel(10D);
graphTitle1.Position = Telerik.Reporting.GraphItemPosition.TopCenter;
graphTitle1.Style.LineColor = System.Drawing.Color.LightGray;
graphTitle1.Style.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
graphTitle1.Text = "";
this.graph1.Titles.Add(graphTitle1);
//
// cartesianCoordinateSystem1
//
this.cartesianCoordinateSystem1.Name = "cartesianCoordinateSystem1";
this.cartesianCoordinateSystem1.XAxis = this.graphAxis1;
this.cartesianCoordinateSystem1.YAxis = this.graphAxis2;
//
// graphAxis1
//
this.graphAxis1.MajorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis1.MajorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis1.MinorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis1.MinorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis1.MinorGridLineStyle.Visible = false;
this.graphAxis1.Name = "graphAxis1";
numericalScale1.Minimum = 0D;
this.graphAxis1.Scale = numericalScale1;
this.graphAxis1.Title = "Quantity";
//
// graphAxis2
//
this.graphAxis2.LabelAngle = 0;
this.graphAxis2.LabelPlacement = Telerik.Reporting.GraphAxisLabelPlacement.NextToAxis;
this.graphAxis2.MajorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis2.MajorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis2.MinorGridLineStyle.LineColor = System.Drawing.Color.LightGray;
this.graphAxis2.MinorGridLineStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Pixel(1D);
this.graphAxis2.MinorGridLineStyle.Visible = false;
this.graphAxis2.MinorTickMarkDisplayType = Telerik.Reporting.GraphAxisTickMarkDisplayType.Inside;
this.graphAxis2.Name = "graphAxis2";
this.graphAxis2.Scale = categoryScale1;
this.graphAxis2.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
this.graphAxis2.Title = "Product";
this.graphAxis2.TitlePlacement = Telerik.Reporting.GraphAxisTitlePlacement.Centered;
//
// barSeries1
//
graphGroup2.Name = "categoryGroup";
this.barSeries1.CategoryGroup = graphGroup2;
this.barSeries1.CoordinateSystem = this.cartesianCoordinateSystem1;
this.barSeries1.DataPointLabel = "=Fields.PRODUCT_BAR_CODE_NUMBER + \' \' + Fields.product_short_name";
this.barSeries1.DataPointLabelAlignment = Telerik.Reporting.BarDataPointLabelAlignment.InsideBase;
this.barSeries1.DataPointLabelStyle.Visible = true;
this.barSeries1.DataPointStyle.LineWidth = Telerik.Reporting.Drawing.Unit.Inch(0D);
this.barSeries1.DataPointStyle.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Top;
this.barSeries1.DataPointStyle.Visible = true;
this.barSeries1.Legend = "=Fields.product_short_name";
this.barSeries1.LegendFormat = "";
graphGroup3.Groupings.Add(new Telerik.Reporting.Grouping("=Fields.product_short_name"));
graphGroup3.Name = "product_short_nameGroup";
graphGroup3.Sortings.Add(new Telerik.Reporting.Sorting("=Fields.product_short_name", Telerik.Reporting.SortDirection.Asc));
this.barSeries1.SeriesGroup = graphGroup3;
this.barSeries1.X = "=Sum(Fields.TotalQuantity)";

The datasource, sqlDataSource1 have a query which is somewhat like this:
SELECT SUM(quantity) AS TotalQuantity, product_short_name, PRODUCT_BAR_CODE_NUMBER  FROM myTable

Attached files:
- current graph.png : this is how my graph currently looks like
- sample graph.jpg : this is how I want the y-axis to look like (take note that the season names are on the left side of the y-axis)
0
Iris
Top achievements
Rank 1
answered on 20 Jun 2013, 04:26 AM
It's been almost 4 days and still no reply?
0
Stef
Telerik team
answered on 21 Jun 2013, 02:45 PM
Hello Iris,

The forums are a community resource and although we monitor them, we do not guarantee a timely reply here. Please use the support ticketing system if you'd like to reach directly Telerik's staff.
As for the problem, notice that in the provided report definition we have defined Categories in addition to the Series. Use the context menu to copy the Graph item from the trdx file and paste it in Visual Studio designer. There you can compare both yours and ours items definitions.

In your case it is enough to set the "product_short_name" column as a category and "TotalQuantity" as value for your Graph item.



Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Iris
Top achievements
Rank 1
answered on 02 Jul 2013, 03:28 AM
Thank you for your reply.

Could you be more exact on how to define the Categories? I've looked at CategoryGroup properties for the graph but saw no field that enables me to set "product_short_name" as category.
0
Squall
Top achievements
Rank 1
answered on 04 Jul 2013, 03:13 PM
You can set the those in the Graph Wizard, or as CategoryGroup grouping expressions.
0
Jasnil
Top achievements
Rank 1
answered on 03 Mar 2014, 05:47 AM
Hi Iris,

I am a new user to Telerik Reporting, from your attached image i can see that you set values from 1, 2, 3, 4,..
in my graph i would like to value it as 5,10,15,20,25 .... instead of 100, 200, 300, 400.. which displaying currently.

It will be much appreciated if you give me a quick solution if possible.

0
Jasnil
Top achievements
Rank 1
answered on 03 Mar 2014, 05:52 AM
Hi Squall,

I am a new user to Telerik Reporting.
In my graph I would like to value y-axis label as 5,10,15,20,25 .... instead of 100, 200, 300, 400.. which displaying currently.

It will be much appreciated if you give me a quick solution if possible.
0
Iris
Top achievements
Rank 1
answered on 04 Mar 2014, 04:14 AM
Jasnil,

I was involved in another project since my last post here and thus this project was somewhat scrapped. However, I've tried the solution given by Squall and it did not work. If you eventually found a way to do this, please share it here.

Thank you and sorry for not being able to help.
0
Nasko
Telerik team
answered on 05 Mar 2014, 04:52 PM
Hello Jasnil,

It is possible to get the Y axis labels like you mentioned if the axis uses a numerical scale. Then you can set 
Graph.CoordinateSystems.CartesianCoordinateSystem.YAxis.Scale.Minimum = 5
and 
Graph.CoordinateSystems.CartesianCoordinateSystem.YAxis.Scale.MajorStep = 5

which will set the Y axis labels as 5, 10, 15, 20, 25, etc.

I hope this suggestion points you in the right direction.

Regards,
Nasko
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Tags
General Discussions
Asked by
Iris
Top achievements
Rank 1
Answers by
Iris
Top achievements
Rank 1
Stef
Telerik team
Squall
Top achievements
Rank 1
Jasnil
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or