I am using high charts and has got success in displaying them on a page reload. I am creating the chart on server side using the following code:-
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();
Cliend Secret Code
<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>
I am using an update panel but whenever i refresh my chart disappears. If i reload the page it is working fine but when i try and change the graph without putting it in update panel it doesn t change. I want to use update panel and want my graph to change and not disappear. I am not getting any errors neither server side nor client side. Please help me with the same.
Regards Abhishek