Jump to content
Software FX Community

Import and Series Tag/Text Discrepancy


ARissing
 Share

Recommended Posts

We're currently using the Import method to load the schema of the chart and we've noticed a bug in the loading of the XML data.  In particular, when loading from XML, the series' text property does not properly load back up from the xml they were saved with.

The series are saved off with a user friendly name in the text field and a database friendly ID in the tag field.  But upon loading the chart's schema back from the file system the tag's value is placed into the text field overwriting it.  In the end, we have the DatabaseFriendlyID value placed in both the Tag and the Text fields.

 From what I've seen, it just seems there's a typo somewhere in the loading code.

Link to comment
Share on other sites

I am unable to replicate this problem. Please ensure that you are running the latest version of ChartFX. Below is the link to download and apply the latest service pack:

http://support.softwarefx.com/ShowInteractive.aspx?Product=CfxNet70&option=0

Make sure that any instance of ChartFX and Visual Studio is closed. If testing with an existing project, please  make sure that you re-reference the ChartFX .dlls to reflect the above change and that you recompile the application. If you are still experiencing this problem, attach a simple sample project where you are able to replicate this issue.

image.zip

Link to comment
Share on other sites

Ok, this Xml should produce the problem (even with the most up to date dll):

 <?xml version="1.0" encoding="UTF-8"?>

<CFX7>

  <AXESX>

  <ITEM index="0">

  <TITLE>

  <TEXT>Date</TEXT>

  </TITLE>

  </ITEM>

  </AXESX>

  <SERIES>

  <ITEM index="0">

  <TAG>Value_Tag</TAG>

  <TEXT>Value_Text</TEXT>

  </ITEM>

  </SERIES>

  <DATASOURCESETTINGS>

  <FIELDS>

  <ITEM>

  <NAME>Date</NAME>

  <USAGE>XValue</USAGE>

  </ITEM>

  <ITEM>

  <NAME>Value_Tag</NAME>

  <USAGE>Value</USAGE>

  </ITEM>

  </FIELDS>

  </DATASOURCESETTINGS>

</CFX7>

The text value seems to be linked to the Name field of the fields, which is quite preculiar.  Because I don't see how you're mapping the name in the fields to the series, unless it is based on order.

The text field in the series has no impact on the text property of the series and is purely determined by the fields name.  The tag on the other hand seems to be set by the order of the series with regards to the fields.

 To me the logic seems a little off one way or another, if anything it would seem more straight forward if the series had an 'Id' field or a 'Name' field that would be allow you to map back to the field, rather than Text.  In much the same way that a DataTable works, you want one string for the database and one string for the user to see.

 Eitherway, it seems I'll have to rename the name element in the fields to overcome this problem.  Please correct me if this is not the best route to take.

Link to comment
Share on other sites

I did some tests and found out that the tag property is not the one overwriting the text property of the series; since you are exporting the DataSourceSettings, the field name ("Value_Tag") is the one taking precedence because it is one of the last settings exported since DataBinding is done when the chart is being painted. For this, we do not recommend setting the Text property of the Series since when you import back the xml, this will be overwritten; however, there is one way of doing what you're trying to accomplish but this will only work is you are not going to bind data after importing since this will overwrite the text property. You can export without exporting the DataSourceSetting properties as follow:

chart1.Series[0].Text = "This is Series 1"; chart1.Series[1].Text = "This is Series 2";

chart1.FileContents = ~FileContents.DataBind; chart1.TemplateContents = ~FileContents.DataBind;

chart1.Export(

FileFormat.Xml, "D:\\Temp\\Test.xml");

The above code will export without the DataSourceSettings and when importing back, the values of the Text property will be shown; however, as I mentioned before, binding data to the chart after importing will overwrite the value of the text property. For this reason, it is better practice to set the DisplanyName of the FieldMap which, when exporting to XML, will also get serialized and added to the XML file. You can do the following:

FieldMap field1 = new FieldMap();

field1.Name =

"Electronic";field1.DisplayName = "Series 1";

field1.Usage =

FieldUsage.Value;FieldMap field2 = new FieldMap(); field2.Name = "Independent";

field2.DisplayName =

"Series 2";field2.Usage = FieldUsage.Value;

chart1.DataSourceSettings.Fields.Add(field1);

chart1.DataSourceSettings.Fields.Add(field2);

chart1.DataSource = ds.Tables[0];

When you bind data after importing, this will ensure that the value of the DisplayName property does not change.

post-3417-1392240314608_thumb.png

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.

 Share

×
×
  • Create New...