Hi,
I have an UltraChart control. It looks like this:
<igchart:UltraChart ID="UltraChart1" runat="server" EmptyChartText="Data Not Available" Version="10.2"></igchart:UltraChart>
In the code behind I have this:
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("label", typeof(string)); dt.Columns.Add("cost", typeof(double)); dt.Rows.Add("item 1", 29); dt.Rows.Add("item 2", 33); dt.Rows.Add("item 3", 28); dt.Rows.Add("item 4", 35); NumericSeries series = new NumericSeries(); series.Data.DataSource = dt; series.Data.LabelColumn = "label"; series.Data.ValueColumn = "cost"; series.DataBind(); UltraChart1.Series.Add(series); UltraChart1.Data.DataBind(); }
The result is a chart with some values. Great!
---------
So what I have done is create a new Composite Chart using the wizard. I called it UltraChart2. I added all the Areas, Axis, Data, Chart Layers and Legends. I got the chart looking exacly the way I like it. I'm not going to put the code here unless you ask for it because it is like 250 lines long.
Now all I want to do is replace the current data that I added when I went through the wizard to some custom data. So once again, I put this in the code behind:
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("label", typeof(string)); dt.Columns.Add("cost", typeof(double)); dt.Rows.Add("item 1", 29); dt.Rows.Add("item 2", 33); dt.Rows.Add("item 3", 28); dt.Rows.Add("item 4", 35); NumericSeries series = new NumericSeries(); series.Data.DataSource = dt; series.Data.LabelColumn = "label"; series.Data.ValueColumn = "cost"; series.DataBind(); UltraChart2.Series.Add(series); UltraChart2.Data.DataBind(); }
The result is the chart with exacly the same data that I added in the wizard. If I delete this data, I get a blank chart.
This should be a simple process but I'm obviously missing something vital. Can you fill me in?
Hello Michael,
Do you have any further questions on adding the series within the Composite Chart?
Let me know if you have any questions with this matter. Thank you.
Thank you this has done the trick.
Hello,
You can use the following code on the server side after series.DataBind():
UltraChart2.CompositeChart.ChartLayers[0].Series.Clear();UltraChart2.CompositeChart.ChartLayers[0].Series.Add(series);
Since in the markup there are points that are defined in the Composite Chart so in order for the data to be seen in the chart you can add the NumericSeries under CompositeChart.ChartLayers.
Let me know if this works for you. Thank you.
I'm still looking into the chart for databinding using the provided markup and server side code.
I appreciate your patience.
I have created the simplest chart possible to serve as an example. Here is the markup for my Composite Chart. This was generated using the wizard:
<igchart:UltraChart ID="UltraChart2" runat="server" EmptyChartText="Data Not Available. Please call UltraChart.Data.DataBind() after setting valid Data.DataSource" Version="10.2" ChartType="Composite"> <ColorModel AlphaLevel="150"> </ColorModel> <Axis> <PE ElementType="None" Fill="Cornsilk"></PE> <X Visible="True" TickmarkInterval="0"> <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255"> </MajorGridLines> <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255"> </MinorGridLines> <Labels ItemFormatString="<ITEM_LABEL>" HorizontalAlign="Near" VerticalAlign="Center" Orientation="VerticalLeftFacing"> <SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation="VerticalLeftFacing" FormatString=""> </SeriesLabels> </Labels> </X> <Y Visible="True" TickmarkInterval="0"> <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255"> </MajorGridLines> <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255"> </MinorGridLines> <Labels ItemFormatString="<DATA_VALUE:00.##>" HorizontalAlign="Far" VerticalAlign="Center" Orientation="Horizontal"> <SeriesLabels HorizontalAlign="Far" VerticalAlign="Center" Orientation="Horizontal" FormatString=""> </SeriesLabels> </Labels> </Y> <Y2 Visible="False" TickmarkInterval="0"> <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255"> </MajorGridLines> <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255"> </MinorGridLines> <Labels ItemFormatString="<DATA_VALUE:00.##>" Visible="False" HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"> <SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal" FormatString=""> </SeriesLabels> </Labels> </Y2> <X2 Visible="False" TickmarkInterval="0"> <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255"> </MajorGridLines> <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255"> </MinorGridLines> <Labels ItemFormatString="<ITEM_LABEL>" Visible="False" HorizontalAlign="Far" VerticalAlign="Center" Orientation="VerticalLeftFacing"> <SeriesLabels HorizontalAlign="Far" VerticalAlign="Center" Orientation="VerticalLeftFacing" FormatString=""> </SeriesLabels> </Labels> </X2> <Z Visible="False" TickmarkInterval="0"> <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255"> </MajorGridLines> <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255"> </MinorGridLines> <Labels ItemFormatString="" HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"> <SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"> </SeriesLabels> </Labels> </Z> <Z2 Visible="False" TickmarkInterval="0"> <MajorGridLines Visible="True" DrawStyle="Dot" Color="Gainsboro" Thickness="1" AlphaLevel="255"> </MajorGridLines> <MinorGridLines Visible="False" DrawStyle="Dot" Color="LightGray" Thickness="1" AlphaLevel="255"> </MinorGridLines> <Labels ItemFormatString="" Visible="False" HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"> <SeriesLabels HorizontalAlign="Near" VerticalAlign="Center" Orientation="Horizontal"> </SeriesLabels> </Labels> </Z2> </Axis> <Tooltips Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" /> <CompositeChart> <Series> <igchartprop:NumericSeries Key="series1"> <points> <igchartprop:NumericDataPoint Label="Col1" Value="20"> <pe elementtype="None" /> </igchartprop:NumericDataPoint> <igchartprop:NumericDataPoint Label="Col2" Value="40"> <pe elementtype="None" /> </igchartprop:NumericDataPoint> <igchartprop:NumericDataPoint Label="Col3" Value="90"> <pe elementtype="None" /> </igchartprop:NumericDataPoint> <igchartprop:NumericDataPoint Label="Col4" Value="30"> <pe elementtype="None" /> </igchartprop:NumericDataPoint> </points> </igchartprop:NumericSeries> </Series> <ChartLayers> <igchartprop:ChartLayerAppearance AxisXKey="axis1" AxisYKey="axis2" ChartAreaKey="area1" ChartType="ColumnChart" Key="chartLayer1" SeriesList="series1"> <ChartTypeAppearances> <igchartprop:ColumnChartAppearance> </igchartprop:ColumnChartAppearance> </ChartTypeAppearances> </igchartprop:ChartLayerAppearance> </ChartLayers> <ChartAreas> <igchartprop:ChartArea Key="area1"> <Axes> <igchartprop:AxisItem DataType="String" Key="axis1" OrientationType="X_Axis" SetLabelAxisType="GroupBySeries" TickmarkInterval="0"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels HorizontalAlign="Near" ItemFormatString="" Orientation="Horizontal" VerticalAlign="Center"> <SeriesLabels HorizontalAlign="Center" Orientation="Horizontal" VerticalAlign="Center"> </SeriesLabels> </Labels> </igchartprop:AxisItem> <igchartprop:AxisItem DataType="Numeric" Key="axis2" OrientationType="Y_Axis" SetLabelAxisType="GroupBySeries" TickmarkInterval="0"> <MajorGridLines AlphaLevel="255" Color="Gainsboro" DrawStyle="Dot" Thickness="1" Visible="True" /> <MinorGridLines AlphaLevel="255" Color="LightGray" DrawStyle="Dot" Thickness="1" Visible="False" /> <Labels HorizontalAlign="Near" ItemFormatString="<DATA_VALUE:00.##>" Orientation="Horizontal" VerticalAlign="Center"> <SeriesLabels HorizontalAlign="Center" Orientation="Horizontal" VerticalAlign="Center"> </SeriesLabels> </Labels> </igchartprop:AxisItem> </Axes> <GridPE ElementType="None" /> </igchartprop:ChartArea> </ChartAreas> </CompositeChart> </igchart:UltraChart>
In Page_Load(...) I have the following code:
You will notice that the data in the chart does not change. I would like it to match the data set in the DataTable object above.
Thanks.