我正在使用高图表,并成功地在页面重新加载时显示它们。我正在使用以下代码在服务器端创建图表:-
DateTime dt = DateTime.Now;
Series[] series=null;
Series Store1 = new Series();
Store1.Data = new Data(new object[]
{
lst[0].target1,lst[0].target2,lst[0].target3,lst[0].target4,lst[0].target5,lst[0].target6,lst[0].target7
});
Store1.Name = lst[0].StoreName;
Store1.Type = DotNet.Highcharts.Enums.ChartTypes.Bar;
Series Store2 = new Series();
Store2.Data = new Data(new object[]
{
lst[1].target1,lst[1].target2,lst[1].target3,lst[1].target4,lst[1].target5,lst[1].target6,lst[1].target7
});
Store2.Name = lst[1].StoreName;
Store2.Type = DotNet.Highcharts.Enums.ChartTypes.Bar;
series = new Series[] { Store1, Store2 };
DotNet.Highcharts.Highcharts bar = new DotNet.Highcharts.Highcharts("chart")
.SetPlotOptions(new PlotOptions
{
Bar = new PlotOptionsBar
{
AllowPointSelect = true,
Cursor = DotNet.Highcharts.Enums.Cursors.Pointer,
ShowInLegend = true,
DataLabels = new PlotOptionsBarDataLabels
{
Color = System.Drawing.ColorTranslator.FromHtml("#000000"),
//ConnectorColor = System.Drawing.ColorTranslator.FromHtml("#000000"),
}
}
})
.SetLegend(new Legend{
Layout=DotNet.Highcharts.Enums.Layouts.Vertical
})
.SetXAxis(new XAxis
{
Categories = new string[] {dt.DayOfWeek.ToString(),
dt.AddDays(-1).DayOfWeek.ToString(),
dt.AddDays(-2).DayOfWeek.ToString(),
dt.AddDays(-3).DayOfWeek.ToString(),
dt.AddDays(-4).DayOfWeek.ToString(),
dt.AddDays(-5).DayOfWeek.ToString(),
dt.AddDays(-6).DayOfWeek.ToString()
}
})
.SetTitle(new Title { Text = "Store Details" })
.SetSeries(series);
ltrchart.Text = bar.ToHtmlString();
客户端代码
<script src="Js/jquery-1.5.1.js" type="text/javascript"></script>
<script src="Js/highcharts.js" type="text/javascript"></script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Literal ID="ltrchart" runat="server"></asp:Literal>
</ContentTemplate>
</asp:UpdatePanel>
我正在使用更新面板,但每当我刷新图表时,我的图表就会消失。如果我重新加载页面,它工作正常,但是当我尝试更改图表而不将其放入更新面板时,它不会改变。我想使用更新面板并希望我的图表改变而不是消失。无论是服务器端还是客户端,我都没有收到任何错误。请帮助我。
问候阿布舍克