Jump to content
Software FX Community
Sign in to follow this  
User (Legacy)

Multiple X-Axis

Recommended Posts

When I look at the ChartFX Reference library (Multiple X-Axis under Axis 

Handling, X Axis). If I pull the code out of the sample area and paste

it into my Windows app, I replicate what the example does.

However, now I'm trying to apply the knowledge of this example to my own

application and cannot seem to get the X-Axis labels to appear at the

top of the chart as shown in the example ... it always appears below the

chart and without any labels (even though I assign to labels). I've

tried messing around with AxisPosition and some other items to no affect.

What determines where the labels on the X-Axis appear?

Thanks.

post-2107-13922379605447_thumb.jpg

Share this post


Link to post
Share on other sites

> What determines where the labels on the X-Axis appear?

The main this is having a scale, if the axis has no scale it will not show.

An axis that has data associated with it (e.g. Main Y-Axis, main X-Axis)

will scale automatically as data is passed. An axis with no data associate

to it (e.g. secondary X-Axis) needs to receive a scale manually, for

example:

axisX2.Min = 10;

axisX2.Max = 100;

If all you want is to have the X-Axis at the top of the chart you don't need

an extra X-Axis, all you need to do is:

chart.AxisX.Position = AxisPosition.Far;

--

Francisco Padron

www.chartfx.com

"LNS" <ianj_lns@lns-systems.com> wrote in message

news:$RPi%23ywrFHA.4084@webserver3.softwarefx.com...

> When I look at the ChartFX Reference library (Multiple X-Axis under Axis

> Handling, X Axis). If I pull the code out of the sample area and paste it

> into my Windows app, I replicate what the example does.

>

> However, now I'm trying to apply the knowledge of this example to my own

> application and cannot seem to get the X-Axis labels to appear at the top

> of the chart as shown in the example ... it always appears below the chart

> and without any labels (even though I assign to labels). I've tried

> messing around with AxisPosition and some other items to no affect.

>

> What determines where the labels on the X-Axis appear?

>

> Thanks.

Share this post


Link to post
Share on other sites

Software FX Support wrote:

>>What determines where the labels on the X-Axis appear?

>

>

> The main this is having a scale, if the axis has no scale it will not show.

> An axis that has data associated with it (e.g. Main Y-Axis, main X-Axis)

> will scale automatically as data is passed. An axis with no data associate

> to it (e.g. secondary X-Axis) needs to receive a scale manually, for

> example:

>

> axisX2.Min = 10;

> axisX2.Max = 100;

>

> If all you want is to have the X-Axis at the top of the chart you don't need

> an extra X-Axis, all you need to do is:

>

> chart.AxisX.Position = AxisPosition.Far;

>

Here is the code the initializes the second X-Axis:

myAxis = ChartFX.Axis[ 3 ];

myAxis.Visible = true;

myAxis.Min = 0;

myAxis.Max = Matrix.FindElement( aVectorName ).TheVector.Count-1;

myAxis.Step = 1;

myAxis.YAxis = false;

The labels are initialized in a different method, but this is it:

Vector myVector = Matrix.FindElement( aVectorName ).TheVector;

for ( int v=0; v < myVector.Count; v++ ) {

myDate = new DateTime( Convert.ToInt64( myVector.GetElement(v) ) );

if ( myDate.Month == 1 )

myAxis.Label[v] = myDate.ToString( "yyyy" );

}//for

As soon as I run this code and display the chart, the ChartFX.Axis[3]

appears below the main X Axis. I have attempted to say:

myAxis.AxisPosition = AxisPosition.Far;

AxisX.AxisPosition = AxisPosition.Near;

However, this makes no difference.

Can you see what it is about this code that is causing the X-Axis to not

appear above the chart?

*-*-*-*-*-*-*-*

Ultimately, what I'm looking for is a way to identify which years of

data I'm looking at. I'm showing a time line with 20-30 years worth of

historical data in one month chunks. Because I don't have the reliable

way to show the X-Axis, I'm showing years with alternating section colors:

mySection = ChartFX.AxisX.Sections[ mySectionCount ];

mySection.From = v+1;

mySection.To = v+13;

myCurrentYear++;

if ( ( myCurrentYear % 2 ) == 0 )

mySection.BackColor = ChartFX.AxisX.AlternateColor;

else

mySection.BackColor = ChartFX.InsideColor;

What I'd really like to be able to do is place a caption on top of the

section for the year.

I cannot do this with annotations, because there is a bug. The relative

position changes depending on the width of the graph. This bug even

appears in your examples when you resize the sample graph.

Any thoughts?

Thanks.

LNS

Share this post


Link to post
Share on other sites

One other point ... It doesn't appear that I can simply have one X-Axis 

with the "January" points being labeled "January 1982" ... the reason is

that as you increase the number of years, the automatic sizing of the

graph doesn't necessarily show the "January" lines, or even has the room

to show a label for 1982. But I figure that an entire year of width in

a 30-year chart should have enough room to show the year in most cases.

Thanks,

LNS

LNS wrote:

> Software FX Support wrote:

>

>>> What determines where the labels on the X-Axis appear?

>>

>>

>>

>> The main this is having a scale, if the axis has no scale it will not

>> show. An axis that has data associated with it (e.g. Main Y-Axis, main

>> X-Axis) will scale automatically as data is passed. An axis with no

>> data associate to it (e.g. secondary X-Axis) needs to receive a scale

>> manually, for example:

>>

>> axisX2.Min = 10;

>> axisX2.Max = 100;

>>

>> If all you want is to have the X-Axis at the top of the chart you

>> don't need an extra X-Axis, all you need to do is:

>>

>> chart.AxisX.Position = AxisPosition.Far;

>>

>

> Here is the code the initializes the second X-Axis:

>

> myAxis = ChartFX.Axis[ 3 ];

>

> myAxis.Visible = true;

> myAxis.Min = 0;

> myAxis.Max = Matrix.FindElement( aVectorName ).TheVector.Count-1;

> myAxis.Step = 1;

> myAxis.YAxis = false;

>

> The labels are initialized in a different method, but this is it:

>

> Vector myVector = Matrix.FindElement( aVectorName ).TheVector;

>

> for ( int v=0; v < myVector.Count; v++ ) {

> myDate = new DateTime( Convert.ToInt64( myVector.GetElement(v) ) );

> if ( myDate.Month == 1 )

> myAxis.Label[v] = myDate.ToString( "yyyy" );

> }//for

>

> As soon as I run this code and display the chart, the ChartFX.Axis[3]

> appears below the main X Axis. I have attempted to say:

>

> myAxis.AxisPosition = AxisPosition.Far;

> AxisX.AxisPosition = AxisPosition.Near;

>

> However, this makes no difference.

>

> Can you see what it is about this code that is causing the X-Axis to not

> appear above the chart?

>

> *-*-*-*-*-*-*-*

>

> Ultimately, what I'm looking for is a way to identify which years of

> data I'm looking at. I'm showing a time line with 20-30 years worth of

> historical data in one month chunks. Because I don't have the reliable

> way to show the X-Axis, I'm showing years with alternating section colors:

>

> mySection = ChartFX.AxisX.Sections[ mySectionCount ];

> mySection.From = v+1;

> mySection.To = v+13;

>

> myCurrentYear++;

> if ( ( myCurrentYear % 2 ) == 0 )

> mySection.BackColor = ChartFX.AxisX.AlternateColor;

> else

> mySection.BackColor = ChartFX.InsideColor;

>

>

> What I'd really like to be able to do is place a caption on top of the

> section for the year.

>

> I cannot do this with annotations, because there is a bug. The relative

> position changes depending on the width of the graph. This bug even

> appears in your examples when you resize the sample graph.

>

> Any thoughts?

>

> Thanks.

> LNS

Share this post


Link to post
Share on other sites

Software FX Support wrote:

>>What determines where the labels on the X-Axis appear?

>

>

> The main this is having a scale, if the axis has no scale it will not show.

> An axis that has data associated with it (e.g. Main Y-Axis, main X-Axis)

> will scale automatically as data is passed. An axis with no data associate

> to it (e.g. secondary X-Axis) needs to receive a scale manually, for

> example:

>

> axisX2.Min = 10;

> axisX2.Max = 100;

>

> If all you want is to have the X-Axis at the top of the chart you don't need

> an extra X-Axis, all you need to do is:

>

> chart.AxisX.Position = AxisPosition.Far;

>

Here is the code the initializes the second X-Axis:

myAxis = ChartFX.Axis[ 3 ];

myAxis.Visible = true;

myAxis.Min = 0;

myAxis.Max = Matrix.FindElement( aVectorName ).TheVector.Count-1;

myAxis.Step = 1;

myAxis.YAxis = false;

The labels are initialized in a different method, but this is it:

Vector myVector = Matrix.FindElement( aVectorName ).TheVector;

for ( int v=0; v < myVector.Count; v++ ) {

myDate = new DateTime( Convert.ToInt64( myVector.GetElement(v) ) );

if ( myDate.Month == 1 )

myAxis.Label[v] = myDate.ToString( "yyyy" );

}//for

As soon as I run this code and display the chart, the ChartFX.Axis[3]

appears below the main X Axis. I have attempted to say:

myAxis.AxisPosition = AxisPosition.Far;

AxisX.AxisPosition = AxisPosition.Near;

However, this makes no difference.

Can you see what it is about this code that is causing the X-Axis to not

appear above the chart?

Thanks.

LNS

Share this post


Link to post
Share on other sites

I placed a modified version of your code in a little sample program and I 

get a secondary X-Axis at the TOP of the chart. There is something in your

program that is not here i n this code that is causing the unexpected

behavior. I would need a sample program that reproduces the behavior in

order to determine what is causing this behavior. The code I tried is this:

Axis myAxis = chart1.Axis[ 3 ];

string [] myVector = new string[] {"a","b","c","d","e"};

myAxis.Visible = true;

myAxis.Min = 0;

myAxis.Max = myVector.Length;

myAxis.Step = 1;

myAxis.YAxis = false;

for ( int v=0; v < myVector.Length; v++ ) {

myAxis.Label[v] = myVector[v];

}//for

--

Francisco Padron

www.chartfx.com

Share this post


Link to post
Share on other sites

I am using ChartFX 2005 and the only option I can add Secondary Y axis is through WinForms. Under WinForms I do not get any option of creating a new axis by:

Axis myAxis = chart1.Axis[ 3 ];
So, is there any other way where in I can create a secondary Y axis?
 
Thanks,
Shouvik 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...