Jump to content
Software FX Community

Export to XML will throw FormatExceptions if the label text contains {#..}


Recommended Posts



I have a case where the user is presented with values containing {<some GUID or number>}.  While the graph looks fine it will throw a FormatException in exporting to xml, as it appears this is being passed directly into String.Format (protecting the strings with {{x}} keeps the error from happening ouf course but displays in the graph & would be prohibitively expensive to perform.)  I have modified the ApiButton_Click function in your PassingData example application to show this.  While hideously ugly (and we don't want our application to show this data generally) it exporting failing is fatal to our design & the overhead of checking every string we populate the chart with is very high.  Please let me know if I can do anything to help (or have missed something)





  private void ApiButton_Click(object sender, EventArgs e)

  chart1.Gallery = Gallery.Curve;

  Random r = new Random();

  /* This function populates the chart using the API. First, you must specify the number of series and points
* and then pass the data. In this case we're passing random data. You can also use this method to pass X values,
* for which you will use chart1.Data.X[series, point] and chart1.Data.Y[series, point], instead of
* chart1.Data[series, point], which is simply to pass Y data.
  chart1.Data.Series = 2;
  chart1.Data.Points = 15;

  for (int series = 0; series < chart1.Data.Series; series++)
  chart1.Series[series].Text = "{1111}"; // here

  for (int point = 0; point < chart1.Data.Points; point++)
  chart1.Data[series, point] = r.NextDouble() * 100;

  if (series == 0)
  chart1.Data.Labels[point] = "{2222}"; // here

  System.IO.MemoryStream ms = new System.IO.MemoryStream();
  ms.Seek(0, System.IO.SeekOrigin.Begin);

  // the following line will throw a FormatException if either line above
  // marked with "here" is compiled in...
  chart1.Export(FileFormat.Xml, ms);

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.

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...