cagin
cagin

Reputation: 5920

DevExpress: How to set programmatically diagram to chart control

I create ChartControl dynamiclly and I have to set Diagram property as dynamiclly. Here is my code:

   XYDiagram xyDiagram1 = new XYDiagram();
   xyDiagram1.AxisX.Title.Text = "";
   xyDiagram1.AxisX.VisibleInPanesSerializable = "-1";
   xyDiagram1.AxisX.WholeRange.Auto = false;
   xyDiagram1.AxisX.WholeRange.AutoSideMargins = false;
   xyDiagram1.AxisX.WholeRange.MaxValueSerializable = "10";
   xyDiagram1.AxisX.WholeRange.MinValueSerializable = "5";
   xyDiagram1.AxisX.WholeRange.SideMarginsValue = 2.5D;
   xyDiagram1.AxisY.Title.Text = "";
   xyDiagram1.AxisY.VisibleInPanesSerializable = "-1";

   barChart.Diagram = xyDiagram1;

But it throws This property can't be customized at runtime. exception. Do you have any suggestion?

Upvotes: 0

Views: 1250

Answers (1)

Gosha_Fighten
Gosha_Fighten

Reputation: 3858

An instance of ChartControl.Diagram is automatically created by a chart. The ViewType enumerable controls what diagram is created. So, cast the ChartControl.Diagram property to your diagram type to get it. You don't need to create a diagram manually.

Upvotes: 1

Related Questions