We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display custom labels when we dynamically change the type of chart

Thread ID:

Created:

Updated:

Platform:

Replies:

55174 Jan 24,2007 05:41 PM UTC Feb 7,2007 11:35 AM UTC Windows Forms 10
loading
Tags: Chart
Surya
Asked On January 24, 2007 05:41 PM UTC


I am displaying custom labels for primary x-axis
for a column chart.If I select a different chart type such as bar chart from the toolbar, I want
to display the custom labels on the y-axis. How can I do that ?

Thanks
Surya

Surya
Replied On January 24, 2007 07:57 PM UTC


Any Info on this ?

>
I am displaying custom labels for primary x-axis
for a column chart.If I select a different chart type such as bar chart from the toolbar, I want
to display the custom labels on the y-axis. How can I do that ?

Thanks
Surya

Ramya R [Syncfusion]
Replied On January 25, 2007 10:09 AM UTC

Hi Surya,

My apologies for the delay in responding to you.

If your intention is to have the same custom labels for Y-Axis as that in X-Axis when the Series Type is changed then it can be done by as shown in the code snippet below,

this.chartControl1.Model.Series[0].Type=ChartSeriesType.Bar;
this.chartControl1.PrimaryYAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryYAxis.Labels.Clear();
for(int i=0;i{
this.chartControl1.PrimaryYAxis.Labels.Add( new ChartAxisLabel(ylabel[i],Color.Crimson, new Font("TimesNewRoman", 10), val, "", ChartValueType.Custom ));
val=val+2;
}

//ylabel[i]-contains the text of labels of X-Axis

Also kindly take a look at the attached sample.

Let me know if I am wrong in getting your requirement.

Thanks & Regards,
Ramya.


CustomLabel.zip

Surya
Replied On January 25, 2007 03:50 PM UTC


That's a good example. Are you exposing any events when the user clicks the buttons in the chart tool bar ? I want to handle the event when user selects a chart type and custom display the axes labels.

Thanks for your effort.

Surya

>Hi Surya,

My apologies for the delay in responding to you.

If your intention is to have the same custom labels for Y-Axis as that in X-Axis when the Series Type is changed then it can be done by as shown in the code snippet below,

this.chartControl1.Model.Series[0].Type=ChartSeriesType.Bar;
this.chartControl1.PrimaryYAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryYAxis.Labels.Clear();
for(int i=0;i{
this.chartControl1.PrimaryYAxis.Labels.Add( new ChartAxisLabel(ylabel[i],Color.Crimson, new Font("TimesNewRoman", 10), val, "", ChartValueType.Custom ));
val=val+2;
}

//ylabel[i]-contains the text of labels of X-Axis

Also kindly take a look at the attached sample.

Let me know if I am wrong in getting your requirement.

Thanks & Regards,
Ramya.


CustomLabel.zip

Surya
Replied On January 26, 2007 07:00 PM UTC


Please respond to my previous question ..Below

Also would like to know if there is a way to customize the series type menu in the chart toolbar.
----------------------------------------------
Are you exposing any events when the user clicks the buttons in the chart tool bar ? I want to handle the event when user selects a chart type and custom display the axes labels.


--------------------------------------------


>
That's a good example. Thanks for your effort.

Surya

>Hi Surya,

My apologies for the delay in responding to you.

If your intention is to have the same custom labels for Y-Axis as that in X-Axis when the Series Type is changed then it can be done by as shown in the code snippet below,

this.chartControl1.Model.Series[0].Type=ChartSeriesType.Bar;
this.chartControl1.PrimaryYAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryYAxis.Labels.Clear();
for(int i=0;i{
this.chartControl1.PrimaryYAxis.Labels.Add( new ChartAxisLabel(ylabel[i],Color.Crimson, new Font("TimesNewRoman", 10), val, "", ChartValueType.Custom ));
val=val+2;
}

//ylabel[i]-contains the text of labels of X-Axis

Also kindly take a look at the attached sample.

Let me know if I am wrong in getting your requirement.

Thanks & Regards,
Ramya.


CustomLabel.zip

Ramya R [Syncfusion]
Replied On January 30, 2007 12:56 PM UTC

Hi Surya,

My apologies for the delay in responding to you.

Could you please me provide with more informations with regard to your requirement, so that it would help me to meet your requirement exactly?

Thanks,
Ramya.

Administrator [Syncfusion]
Replied On January 30, 2007 03:33 PM UTC


Ramya :

I am using the chart toolbar. In short,I want to customize the appearance of charts when the user clicks a seriesType from the menu that appears when the user clicks on 'seriestype' button.

I am using custom labels for my charts.So, when
I select another series type from the menu then
the labels are not displaying appropriately. To be more clear, Suppose that I've displayed a column series with custom labels on the x-axis.Now, I change the series type to 'bar' by selecting corresponding item from the menu in the toolbar.When I change it, the custom labels that are displayed on x-axis are not shifting to y-axis automatically(Since they are custom displayed ).

One solution I can think of is to handle the event when the user changes the series type.
How Can I do that ? Also, I would like to customize
the items in the menu containing the series types.How Can I do that ?

Hope I made myself clear.

Thanks
Surya



>Hi Surya,

My apologies for the delay in responding to you.

Could you please me provide with more informations with regard to your requirement, so that it would help me to meet your requirement exactly?

Thanks,
Ramya.

Administrator [Syncfusion]
Replied On January 31, 2007 12:31 PM UTC

Hi Surya,

Thank you for the detailed information.

You can use the PrepareStyle event of the series to shift the labels to Y-Axis when the ChartSeriesType is changed using the ChartToolBar.

Kindly take a look at the code snippet below.
In this snippet the custom labels are shifted to
Y-Axis when the ChartSeriesType is Bar.


private void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries ser=sender as ChartSeries;
if(ser!=null && ser.Type==ChartSeriesType.Bar)
{
Double val=2;
this.chartControl1.PrimaryYAxis.RangeType=ChartAxisRangeType.Set;
this.chartControl1.PrimaryYAxis.Range=new MinMaxInfo(0,18,2);
this.chartControl1.Model.Series[0].Type=ser.Type;
this.chartControl1.PrimaryYAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryYAxis.Labels.Clear();
for(int i=0;i {
this.chartControl1.PrimaryYAxis.Labels.Add( new ChartAxisLabel(ylabel[i],Color.Crimson, new Font("TimesNewRoman", 10), val, "", ChartValueType.Custom ));
val=val+2;
}
this.chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.AutomaticMode;
this.chartControl1.PrimaryYAxis.TickSize = new Size( 3, 3 );

}

}

Let me know whether this helps you.

Thanks & Reagrds,
Ramya.

Surya
Replied On February 1, 2007 02:45 PM UTC

Ramya :
I've used your example.It seems to work fine.
It would be really helpful if you could tell
me how I can customize the chartSeries popup
Menu.I want to remove some of the chart
series types from the list.

Thanks for your good effort.

Surya

>Hi Surya,

Thank you for the detailed information.

You can use the PrepareStyle event of the series to shift the labels to Y-Axis when the ChartSeriesType is changed using the ChartToolBar.

Kindly take a look at the code snippet below.
In this snippet the custom labels are shifted to
Y-Axis when the ChartSeriesType is Bar.


private void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries ser=sender as ChartSeries;
if(ser!=null && ser.Type==ChartSeriesType.Bar)
{
Double val=2;
this.chartControl1.PrimaryYAxis.RangeType=ChartAxisRangeType.Set;
this.chartControl1.PrimaryYAxis.Range=new MinMaxInfo(0,18,2);
this.chartControl1.Model.Series[0].Type=ser.Type;
this.chartControl1.PrimaryYAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryYAxis.Labels.Clear();
for(int i=0;i {
this.chartControl1.PrimaryYAxis.Labels.Add( new ChartAxisLabel(ylabel[i],Color.Crimson, new Font("TimesNewRoman", 10), val, "", ChartValueType.Custom ));
val=val+2;
}
this.chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.AutomaticMode;
this.chartControl1.PrimaryYAxis.TickSize = new Size( 3, 3 );

}

}

Let me know whether this helps you.

Thanks & Reagrds,
Ramya.

Administrator [Syncfusion]
Replied On February 7, 2007 11:33 AM UTC

Hi Surya,

My apologies for the delay in getting back to you.

If your intention is to have a ChartToolBar with a Button displaying only few SeriesType as per your requirement then it can done by adding a new button to the Toolbar and displaying the SeriesType in its ContextMenu and then accordingly changing the Type of Series depending upon the SeriesType chosen from the menu.

Kindly take a look at the code snippet below,

private void SetChartToolBar()
{
ChartToolBarButtonColection bt = this.chartControl1.ToolBar.Buttons;
bt.Clear();
button1.Image=new System.Drawing.Bitmap( @"..\..\ChartImage.bmp" );
bt.Add(this.button1);
this.button1.ContextMenu = new ContextMenu();
this.button1.ContextMenu.MenuItems.Add( "Bar" );
this.button1.ContextMenu.MenuItems.Add( "Column" );

this.button1.MouseDown += new MouseEventHandler( button1_MouseDown );
this.button1.ContextMenu.MenuItems[0].Click += new EventHandler( MenuItem0_Click );
this.button1.ContextMenu.MenuItems[1].Click += new EventHandler( MenuItem1_Click );
}


private void MenuItem0_Click(object sender, EventArgs e)
{
this.chartControl1.Series[0].PrepareStyle+=new ChartPrepareStyleInfoHandler( series1_PrepareStyle );
this.chartControl1.Series[0].Type = ChartSeriesType.Bar;
}
private void MenuItem1_Click(object sender, EventArgs e)
{
this.chartControl1.Series[0].PrepareStyle+=new ChartPrepareStyleInfoHandler( series1_PrepareStyle );
this.chartControl1.Series[0].Type = ChartSeriesType.Column;
}

private void button1_MouseDown(object sender, MouseEventArgs e)
{
this.button1.ContextMenu.Show( this.chartControl1, this.chartControl1.ToolBar.Location );
}

Also kindly take a look at the attached sample.

Let me know whether this helps you.

Thanks & Regards,
Ramya.


Administrator [Syncfusion]
Replied On February 7, 2007 11:35 AM UTC

Hi Surya,

Sorry for not providing the sample attachment in the previous post.

I have attached the sample with this post.

Thanks,
Ramya.

CustomLabel0.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;