Jump to content
Software FX Community

Is it possible to plot date values as separate entries in the x-axis?


timlin

Recommended Posts

I am plotting dates in the x-axis (as x-values) and doubles in the y-axis.  If I have 3 double values, 9, 10, and 13, for example all plotted on the same date, they currently all plot at the 1/6/2014 date in a horizontal line.  Is there a way to still use x-values for dates but have each date show up in the x-axis (the 1/6/2014 date would show up as 3 separate points)?

Thanks! John 

Link to comment
Share on other sites

Hello John,

Unfortunatelly this is not possible. This would be a hibrid of categorical and numerical axis. Not supported. I apologize for the inconvenience. Maybe what you are looking for is just a regular categorical axis (where the dates on the axis are just labels and not data)? 

Link to comment
Share on other sites

Thanks for the reply.  I believe you are correct and I can get the functionality I need (hopefully) with a categorical axis.  It may just be something I am doing wrong with binding.

I tried plotting the dates as strings instead of DateTime objects while binding.  I have 2 sets of data, for example, label A with 3 values of 9, 10, and 13.  Label B has 3 values of 10, 11, and 14.  The values 9 and 10, 10 and 11, and 13 and 14 are taken on the same date.  When I bind the data using strings, I am getting 6 date values in the x-axis instead of 2 graphs with 3 date values.Is it correct to just bind the date values as strings?

Thanks a lot!John

Link to comment
Share on other sites

Try this. You won't even need the mappings below if all you have is 1 column for strings and 2 for doubles.

 

string data = "<?xml version=\"1.0\"?>" +

"<CHARTFX>" +

" <COLUMNS>" +

" <COLUMN NAME=\"Date\" TYPE=\"String\"/>" +

" <COLUMN NAME=\"Series1\" TYPE=\"Double\"/>" +

" <COLUMN NAME=\"Series2\" TYPE=\"Double\"/>" +

" </COLUMNS>" +

" <ROW Date=\"1/5/2014\" Series1=\"9\" Series2=\"10\"></ROW>" +

" <ROW Date=\"1/6/2014\" Series1=\"10\" Series2=\"11\"></ROW>" +

" <ROW Date=\"1/7/2014\" Series1=\"13\" Series2=\"14\" ></ROW>" +

"</CHARTFX>";

XmlDataProvider cfxXML = new XmlDataProvider();

cfxXML.LoadXml(data);

chart1.DataSourceSettings.Fields.Add(new FieldMap("Date",FieldUsage.Label));

chart1.DataSourceSettings.Fields.Add(new FieldMap("Series1",FieldUsage.Value));

chart1.DataSourceSettings.Fields.Add(new FieldMap("Series2",FieldUsage.Value));

chart1.DataSourceSettings.DataSource = cfxXML; 

Link to comment
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.

×
×
  • Create New...