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,
I am looking into this matter of any error using the UltraChart with the persistence framework. I will give you a progress update by the end of the day Wednesday.
Sincerely,Mike P.Developer Support EngineerInfragistics, Inc.www.infragistics.com
Hello rickcl,
I have done some research into this matter and I have a question to help clarify the issue. What are you trying to persist with the WebChat? From my understanding it doesn’t seem as though persisting is relevant because the WebChat is an image that is generated.
Sincerely,
Mike P.
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com
Hi Mike,
This question emerges from developing an application where complex data is processed together with user preferences and loaded into controls that are serialized and sent to a web server, so the only logic on the web server is deserialize and show the control.
The idea is that I can be able to change how the chart looks without worrying about the web server.
rickycl.
Thank you for the update. The persistence framework is useful in storing settings the user might change when interacting with the control. Since the chart is a static image generated by the data used it doesn’t make sense to persist the chart. If you have other controls that feed data to the chart you could persist those controls then feed that data to the chart.
Please let me know if you have any questions concerning this matter.
Persisting just the image isn't good enough because when the chart is deserialized and shown on a page it would still have chart's specific events for me to handle (if assing handlers to them of course).
I will simplify the question:
Anyway, I don't seem to follow, are you saying I cannot persist an UltraChart created by code?
I need to somehow persist a programmatically created chart with it's content, style and so on, is it posible or not?
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.