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

Axis names help needed

3 Answers 67 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 17 Apr 2012, 12:42 AM

Hello, Im new to coding in general and am trying to label the columns in a chart.  I have the chart displaying the data i want, but all the labels are 1,2,3, etc.  for each column. I tried using the code below but without much coding experience im not sure how to use it. I think i need something before it to make it work but im not sure.  Im also not sure where in the code this should go, does it go in the general .cs file for Telerik Reporting Item or does it go in the "details" section where the chart is located? if i can provide any more info please ask.

Chart.PlotArea.XAxis.AutoScale = false;
Chart.PlotArea.XAxis.AddRange(1, 7, 1); 
Chart.PlotArea.XAxis[0].TextBlock.Text = "Mon";
Chart.PlotArea.XAxis[1].TextBlock.Text = "Tue";
Chart.PlotArea.XAxis[2].TextBlock.Text = "Wed";
Chart.PlotArea.XAxis[3].TextBlock.Text = "Thu";
Chart.PlotArea.XAxis[4].TextBlock.Text = "Fri";
Chart.PlotArea.XAxis[5].TextBlock.Text = "Sat";
Chart.PlotArea.XAxis[6].TextBlock.Text = "Sun";

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 18 Apr 2012, 09:19 AM
Hi,

You can utilize this code in the report constructor after InitializeComponent, given that you have already created a chart in the designer with a serie and series items. If the chart is databound, then the series would be created automatically at runtime and in this case you would not be able to change the values for the XAxis with this code, instead you can use the DataXColumn property to specify the database column for the X-value or create the chart entirely programmatically as shown in the Data Binding Chart to a Generic List of Objects where you have full control over the chart creation.

Greetings,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
0
Terry
Top achievements
Rank 1
answered on 18 Apr 2012, 03:42 PM
thank you, ive been trying to work with this but the example of code provided is a little confusing.  Being new to coding in general i know i come in to a steep learning curve but im having trouble adapting that code to what i currently have. Below is what i have now, pretty simple so most anything can be added i guess, i just dont know how to reference what i need correclty in the example provided. can you help?

namespace ValligentReports
{
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Telerik.Reporting;
using Telerik.Reporting.Drawing;

/// <summary>
/// Summary description for DeliveryStatus___Client.
/// </summary>

public partial class DeliveryStatus___Client : Telerik.Reporting.Report
{
public DeliveryStatus___Client()
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();}
//
// TODO: Add any constructor code after InitializeComponent call
//
}
}
0
Steve
Telerik team
answered on 19 Apr 2012, 08:12 AM
Hi,

Not sure which is the confusing part at this point. Following the instructions from our previous reply, if you have manually created a chart from the report designer i.e. this chart is not data bound (its DataSource property is not set), then you should place that code after the InitializeComponent method e.g.:

public DeliveryStatus___Client()
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
 
chart1.PlotArea.XAxis.AutoScale = false;
chart1.PlotArea.XAxis.AddRange(1, 7, 1);
chart1.PlotArea.XAxis[0].TextBlock.Text = "Mon";
chart1.PlotArea.XAxis[1].TextBlock.Text = "Tue";
//....... any other code you need
 
}


All the best,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
Tags
General Discussions
Asked by
Terry
Top achievements
Rank 1
Answers by
Steve
Telerik team
Terry
Top achievements
Rank 1
Share this question
or