Here's a piece of code that generates an UltraChart (taken from a sample in the documentation) and then serializes it using the persistence framework:
public UltraChart GetChart() {
UltraChart lChart = new UltraChart();
lChart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite;
ChartArea myChartArea = new ChartArea();
lChart.CompositeChart.ChartAreas.Add(myChartArea);
AxisItem axisX = new AxisItem();
axisX.OrientationType = AxisNumber.X_Axis;
axisX.DataType = AxisDataType.String;
axisX.SetLabelAxisType = SetLabelAxisType.GroupBySeries;
axisX.Labels.ItemFormatString = "<ITEM_LABEL>";
axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;
AxisItem axisY = new AxisItem();
axisY.OrientationType = AxisNumber.Y_Axis;
axisY.DataType = AxisDataType.Numeric;
axisY.Labels.ItemFormatString = "<DATA_VALUE:0.#>";
myChartArea.Axes.Add(axisX);
myChartArea.Axes.Add(axisY);
NumericSeries seriesA = GetNumericSeriesBound();
NumericSeries seriesB = GetNumericSeriesUnBound();
lChart.CompositeChart.Series.Add(seriesA);
lChart.CompositeChart.Series.Add(seriesB);
ChartLayerAppearance myColumnLayer = new ChartLayerAppearance();
myColumnLayer.ChartType = ChartType.ColumnChart;
myColumnLayer.ChartArea = myChartArea;
myColumnLayer.AxisX = axisX;
myColumnLayer.AxisY = axisY;
myColumnLayer.Series.Add(seriesA);
myColumnLayer.Series.Add(seriesB);
lChart.CompositeChart.ChartLayers.Add(myColumnLayer);
CompositeLegend myLegend = new CompositeLegend();
myLegend.ChartLayers.Add(myColumnLayer);
myLegend.Bounds = new Rectangle(0, 75, 20, 25);
myLegend.BoundsMeasureType = MeasureType.Percentage;
myLegend.PE.ElementType = PaintElementType.Gradient;
myLegend.PE.FillGradientStyle = GradientStyle.ForwardDiagonal;
myLegend.PE.Fill = Color.CornflowerBlue;
myLegend.PE.FillStopColor = Color.Transparent;
myLegend.Border.CornerRadius = 10;
myLegend.Border.Thickness = 0;
lChart.CompositeChart.Legends.Add(myLegend);
return lChart;
}
public Stream GetChartStream()
{
var lChart = GetChart();
PersistenceManager lManager = PersistenceManager.GetInstance();
PersistenceData lData = new PersistenceData();
lData.Controls.Add(lManager.SaveControl(lChart, "control"));
return lData.ToStream();
And it is generating this error:
"The XML element 'EnableTheming' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element."
at line "return lData.ToStream();"
Why could this be?
Thanks in advance.
Hello rickycl,
Please let me know if you have any questions.
Yes. You are right persistence framework does the job for you.
Although convenient, Persistence Framework has limitations. EnableTheming is one of them. For more information on Persistence Framework's limitations please refer to the following documentation:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/PersistenceFramework_About_Persistence_Framework.html
The suggestion posted in following forum thread, that is deserialization via reflection may be something to consider:
http://forums.infragistics.com/forums/t/46896.aspx
If you have any questions, please let me know as well.
I apologize for the delay in my response. I was trying to reproduce the behavior you are seeing. I was not very successful.
I may need more information about the application.
Please attach the cs/vb file with your response.
Thank you in advance.
Hi Vivian,
Which schema and attributes you suggest verifying? I am just using the persistence framework to do the job, I have no control over that, do I?
Thanks!
Thank you for the input they are helpful.
Going back to the exception you are seeing, I am leaning on a duplicate XML node. ASP.NET will create two namespaces and type names if there are duplication occurs. I suggest verifying the schema and attributes you are using.
For more details please refer to the following documentation:
http://msdn.microsoft.com/en-us/library/ms946381.aspx
I am currently looking into the WebDataGrid inquiry regarding SavePreset/LoadPreset. I will be updating you within the week.