I have the following code:
protected void SetChartToItem(Item item)
{
ShieldChart1 = new ShieldChart();
ShieldChart1.Width = Unit.Percentage(100);
ShieldChart1.Height = Unit.Pixel(400);
ShieldChart1.CssClass = "chart";
ShieldChart1.PrimaryHeader.Text = item.name;
ShieldChart1.TooltipSettings.AxisMarkers.Enabled = true;
ShieldChart1.TooltipSettings.AxisMarkers.Mode = ChartXYMode.XY;
ShieldChart1.TooltipSettings.AxisMarkers.Width = new Unit(1);
ShieldChart1.TooltipSettings.AxisMarkers.ZIndex = 3;
ChartAxisX axisX = new ChartAxisX();
axisX.Title.Text = "Times";
ShieldChart1.Axes.Add(axisX);
ChartAxisY axisY = new ChartAxisY();
axisY.Title.Text = "Prices";
ShieldChart1.Axes.Add(axisY);
ShieldChart1.Axes.SetDirty();
}
And the following code:
<shield:ShieldChart ID="ShieldChart1" Width="700px" Height="380px" runat="server" OnTakeDataSource="ShieldChart1_TakeDataSource" CssClass="chart">
<PrimaryHeader Text="TestHeader"></PrimaryHeader>
<ExportOptions AllowExportToImage="true" AllowPrint="false" />
<Axes>
<shield:ChartAxisX>
<Title Text="Time"></Title>
</shield:ChartAxisX>
<shield:ChartAxisY>
<Title Text="Price"></Title>
</shield:ChartAxisY>
</Axes>
<DataSeries>
<shield:ChartLineSeries DataFieldY="Volume" DataFieldX="Timer" CollectionAlias="Volume">
<Settings EnablePointSelection="true">
<PointMark>
<ActiveSettings>
<PointSelectedState DrawWidth="4" DrawRadius="4" />
</ActiveSettings>
</PointMark>
</Settings>
</shield:ChartLineSeries>
<shield:ChartLineSeries DataFieldY="Price" DataFieldX="Timer" CollectionAlias="Price">
<Settings EnablePointSelection="true">
<PointMark>
<ActiveSettings>
<PointSelectedState DrawWidth="4" DrawRadius="4" />
</ActiveSettings>
</PointMark>
</Settings>
</shield:ChartLineSeries>
</DataSeries>
</shield:ShieldChart>
When I call SetChartToItem, it looks like it works when I watch it go through step by step, but when the page renders there are no changes to the actual ShieldChart. More information that might help is when I remove the line ShieldChart1 = new ShieldChart(); then the entire ShieldChart will disappear instead.
It took me 3 months, but I figured out what the problem was. I was causing some of the chart to build itself in the 'Page_Load' function. The solution to this was to make sure everyone was done only if the page is a postback page, which is not included in my code above but fixed the issue for me.