Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Numeric Axis Labels on LineChart (Read 23522 times)
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Numeric Axis Labels on LineChart
Mar 8th, 2008 at 6:15am
Print Post  
When using LineChart and specifying XData, the value labels under the X axis only appear at values corresponding to the data points in the set.  Is it possible to not show the X values corresponding to the data points, but instead to have the X axis labels be the value at the division markers (the value after each AxisDelta amount)?  For example, if my data set has 3 data points with X values of 2, 7, and 17, is it possible to show axis labels of 0,5,10,15, and 20 below the axis?

Thanks,
-David Deakins
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #1 - Mar 9th, 2008 at 11:29am
Print Post  
Yes, that's possible. Set the XAxisSettings.AxisLabelType property to AutoScale, use XAxisSettings.MinValue and XAxisSettings.MaxValue to specify the range of the values displayed below the axis, and use XAxisSettings.AxisDelta to set the interval between them.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #2 - Mar 9th, 2008 at 2:29pm
Print Post  
Thanks for your information!  Is there a way (or will there be a way after the new DateTime axis changes that are currently in development) to combine the AutoScale and DateTime settings for AxisLabelType?  So that I could show the corresponding date values at the equally spaced division markers (rather than just number values)?

Thanks,
-David
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #3 - Mar 9th, 2008 at 2:49pm
Print Post  
Yes, there will be a way to do that for DateTime values too. Chances are good that our developer will implement it tomorrow.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #4 - Mar 10th, 2008 at 3:08pm
Print Post  
Hi,

Try this version:
https://mindfusion.eu/_temp/mc_datetime.zip

Use the StartDate, EndDate and TimeSpan properties of the XAxisSettings object to specify the time interval and division of the axis. Set the AxisLabelType to AutoScale and choose a DateTime format for the dates from the XAxisSettings.NumberFormat enumeration (we'll probably rename it in the official release since it's not just for numbers now). If you choose CustomDateTime, you can assign a format string through XAxisSettings.DateTimeFormat.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #5 - Mar 10th, 2008 at 11:05pm
Print Post  
Thank you, this sounds much closer to what I am looking for.  I am seeing some unexpected behavior when using StartDateTime and EndDateTime, however.  Perhaps I am misunderstanding their function.  Suppose I have date1 as 10 Feb 2008 and date2 as 10 Mar 2008.  I configure AxisLabelType = AusoScale, StartDateTime = date1, EndDateTime = date2, TimeSpan = (date2 - date1), and NumberFormat = ShortDate.  I expect that I will see a '2/10/2008' label on the left side of the X axis and a '3/10/2008' label on the right side of the X axis.  And I expect that the graph will span 29 days on the X axis.  However, what I observe is a 3/8/2008 label in the middle of the axis and a 4/6/2008 label on the right side of the axis.  So my start date and end date are not actually 10 Feb and 10 Mar; instead they are something around 10 Feb and 6 Apr.  It looks like the TimeSpace settings is somehow overriding the StartDateTime and EndDateTime settings to force an integer number of divisions.  And it looks like there must be some small round off error with the (date2 - date1) vs the internal calculation, so it is changing (TimeSpan + a very small amount) into (2 x TimeSpan).  It would be preferable to me if the StartDateTime and EndDateTime were the fixed values and, if the divisions calculated by TimeSpan are not an exact integer number, then I do not see a date label at exactly the right end of the X axis.  So if I had instead set TimeSpan to 14 days in my above example, I would expect to see the 2/10/2008 label on the left side of the X axis, a 2/24/2008 label towards the middle of the X axis, and a 3/9/2008 label almost at the right edge of the X axis.  And I would expect the date span to still be 29 days as configured by StartDateTime and EndDateTime.  Does that make sense?  So I think my question is: Is there same way to turn off this requirement for 'integer number of label divisions on an axis'?

Thanks,
-Dave
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #6 - Mar 11th, 2008 at 10:46am
Print Post  
Hi Dave,

Maybe we have not named correctly the property, but TimeSpan specifies the interval between each two divisions at the axis. So, if you set it to 2 days, the period between the StartDateTime and EndDatime will be divided into many intervals, 2 days long each. So, if you set in your case the TimeSpan to 1 day, the control is going to draw 29 divisions between Feb 10th and March 10th as expected. Please, try it and let me know if it works ok. We are preparing images with labels in the new version of the documentation to make clear which property does exactly what.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #7 - Mar 11th, 2008 at 1:36pm
Print Post  
I think that makes sense but my question is: How do I get just 1 division?  If I set TimeSpan to (EndDateTime - StartDateTime), then I am seeing get 2 divisions and EndDateTime is changed to be EndDateTime + TimeSpan.

Thanks,
-Dave
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #8 - Mar 11th, 2008 at 1:40pm
Print Post  
Sorry, I may have used the terms incorrectly.  I am looking for one date label on the left end of the axis and one on the right end of the axis and no change to EndDateTime (I think that may be 2 divisions as we were talking about it before, not 1 division; in any case that is what I am trying to configure)

Thanks,
-Dave
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #9 - Mar 11th, 2008 at 2:12pm
Print Post  
This worked fine for me:

chart.XAxisSettings.AxisLabelType = AxisLabelType.AutoScale;
chart.XAxisSettings.StartDateTime = new DateTime( 2008, 2, 10 );
chart.XAxisSettings.EndDateTime = new DateTime( 2008, 3, 9 );
chart.XAxisSettings.TimeSpan = chart.XAxisSettings.EndDateTime -
chart.XAxisSettings.StartDateTime;
chart.XAxisSettings.AxisLength = 400;

Could you post your initialization code here, and a sample of the data if possible?

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #10 - Mar 11th, 2008 at 4:46pm
Print Post  
Here is a chunk of code that reproduces my problem:

    MindFusion::Charting::WinForms::LineChart ^ chart = gcnew MindFusion::Charting::WinForms::LineChart;

    chart->Location = System:Cheesyrawing:Tongueoint(50, 275);
    chart->Size = Drawing::Size(350, 210);
    chart->LineType = MindFusion::Charting::LineTypes::Line;

    chart->XAxisSettings->AxisLabelType = MindFusion::Charting::AxisLabelType::AutoScale;
    chart->XAxisSettings->StartDateTime = System:CheesyateTime(2008,2,10);
    chart->XAxisSettings->EndDateTime = System:CheesyateTime(2008,3,10);
    chart->XAxisSettings->TimeSpan = (chart->XAxisSettings->EndDateTime - chart->XAxisSettings->StartDateTime);
    chart->XAxisSettings->NumberFormat = MindFusion::Charting::NumberFormat::ShortDate;
    chart->XAxisSettings->AxisLength = 250;

    chart->YAxisSettings->AxisLabelType = MindFusion::Charting::AxisLabelType::AutoScale;
    chart->YAxisSettings->MinValue = 0;
    chart->YAxisSettings->MaxValue = 5;
    chart->YAxisSettings->AxisDelta = 1;
    chart->YAxisSettings->AxisLength = 150;

    System::Collections::Generic::List<System:CheesyateTime> ^ xData1 = gcnew System::Collections::Generic::List<System:CheesyateTime>();
    xData1->Add( System:CheesyateTime(2008,3,9) );
    xData1->Add( System:CheesyateTime(2008,3,1) );
    xData1->Add( System:CheesyateTime(2008,3,5) );

    System::Collections::Generic::List<System::Collections::Generic::List<System:Cheesya
teTime> ^> ^ xData = gcnew System::Collections::Generic::List<System::Collections::Generic::List<System:Cheesya
teTime> ^>();
    xData->Add( xData1 );
    chart->XData = xData;

    System::Collections::Generic::List<int> ^ yData1 = gcnew System::Collections::Generic::List<int>();
    yData1->Add( 1 );
    yData1->Add( 3 );
    yData1->Add( 2 );

    System::Collections::Generic::List<System::Collections::Generic::List<int> ^> ^ yData = gcnew System::Collections::Generic::List<System::Collections::Generic::List<int> ^>();
    yData->Add( yData1 );
    chart->YData = yData;

    page1_.Controls->Add( chart );

Let me know if I should e-mail it separately in case the code is not readable in this forum post.

What I observe from this code is a 3/9/2008 label around the middle of the X axis and a 4/7/2008 label on the right end of the X axis (and no label at the left end of the X axis).  Please help me see what I am doing wrong.

Thanks,
-Dave
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #11 - Mar 12th, 2008 at 2:20pm
Print Post  
Hi,

This version of the control should fix the problem:
https://mindfusion.eu/_temp/mc_divfix.zip

Stoyan
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #12 - Mar 12th, 2008 at 4:25pm
Print Post  
Thank you, I now get a date on either end of the axis and the time span is correct.  My apologies for any additional question: Once I have specified StartDateTime, EndDateTime, and TimeSpan once, how do clear the axis labels so that I can set them to different values?  In my program, there is a date selector that lets you choose which section of the data set to view.  So initially I have one StartDateTime and EndDateTime, but when the user selects a new start date, I will set the StartDateTime and EndDateTime to new values.  When I do this, the X axis appears to still include the initial range of dates.  For example, say my initial StartDateTime = 10 Feb 2008, EndDateTime = 10 Mar 2008, and TimeSpan = (EndDateTime - StartDateTime).  Then the user changes my start date control to 1 Apr 2008.  So I set StartDateTime = 1 Apr 2008, EndDateTime = 30 Apr 2008, and TimeSpan = (EndDateTime - StartDateTime).  Now what I see on the X axis is 2/10/2008, 3/10/2008, 4/8/2008, and 5/7/2008.  So it looks like the original Feb-Mar range is kept when I reset to the new April range.  How do I tell the AxisSettings to clear out the old date range and only use the new April range.

Thanks,
-Dave
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Numeric Axis Labels on LineChart
Reply #13 - Mar 13th, 2008 at 11:13am
Print Post  
That was a bug. This version should correctly reset the time interval when you set the StartTime property -

https://mindfusion.eu/_temp/mc_starttime.zip

Stoyan
  
Back to top
 
IP Logged
 
DaveDeakins
YaBB Newbies
*
Offline



Posts: 15
Joined: Mar 5th, 2008
Re: Numeric Axis Labels on LineChart
Reply #14 - Mar 13th, 2008 at 4:15pm
Print Post  
One other item that I'm not sure if this is the intended behavior: First I set StartDateTime = 10 Feb 2008 and EndDateTime = 10 Mar 2008.  Then if I set StartDateTime = 1 Apr 2008, I get a System.NullReferenceException from MindFusion.Charting.ChartMeasurer.CalculateTextSize.  If I first set EndDateTime = 30 Apr 2008 and then set StartDateTime = 1 Apr 2008, everything is fine.  If I go the other direction (set StartDateTime = 10 Feb 2008 and EndDateTime = 10 Mar 2008, then change EndDateTime = 30 Jan 2008), I also get the NullReferenceException.  Going backwards if set StartDateTime = 1 Jan 2008 before EndDateTime = 30 Jan 2008, everything is fine.  Is this NullReferenceException the intended behavior?

Thanks,
-Dave
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint