我在aspx网站(.NET 4.0)中使用集成图表控件,但我无法显示它。这是我的代码(VB.NET):
PushButtonFunction()
call AfxBeginThread(Calculate())
Calculate
{
SendMessage(WM_FUNCTION)
}
WM_FUCNTION link Play()
Play
{
tbb::parallel_for(tbb::blocked_range<int>(0,300),
[&](const tbb::blocked_range<int> &r)
{
for( y = r.begin(), pos = 0; y < r.end(); ++y )
{
body code 1
for( x = 0; x < 200; ++x, ++pos )
{
body code 2
}
}
}
)
body code 3
}
正如您所看到的,我使用表格来填充图表的数据。 该图表将添加到一个简单的占位符中。
Protected Sub CreateChart(ByVal dt As DataTable, ByVal KZ As DB_Kennzahl)
Dim chart As New Chart
chart.Height = Unit.Pixel(400)
chart.Width = Unit.Pixel(800)
Dim ca As New ChartArea
ca.Name = "ChartArea"
chart.ChartAreas.Add(ca)
Dim seriesKZ As New Series
seriesKZ.Name = KZ.Text
seriesKZ.ChartType = SeriesChartType.Column
seriesKZ.Color = Drawing.Color.Blue
chart.Series.Add(seriesKZ)
For Each dr As DataRow In dt.Rows
Dim dp As New DataPoint
dp.SetValueY(Convert.ToDecimal(dr.Item(6)))
dp.AxisLabel = CStr(dr.Item("Datum"))
seriesKZ.Points.Add(dp)
Next
chart.DataBind()
plch_Chart.Controls.Add(chart)
End Sub
我忘了在代码中写些什么吗?我无法弄清楚错误是什么。代码似乎是正确的,因为即使抛出一个异常也不会抛出。
编辑:Web.config :(只影响图表的部分)
<asp:PlaceHolder ID="plch_Chart" runat="server" Visible="true"></asp:PlaceHolder>
答案 0 :(得分:1)
您的web.config似乎正确无误。您可以直接在页面中创建控件,而不是将控件添加到占位符吗?
<asp:Chart ID="myChart" runat="server" ImageStorageMode="UseImageLocation" Width="800px" Height="400px" ImageLocation="~/someTempFolder/myChartImage">
<Series>
<asp:Series Name="Serie1"></asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1"></asp:ChartArea>
</ChartAreas>
</asp:Chart>