DotNet.Highcharts , Is there any way to use it in

2019-08-27 11:56发布

问题:

i Recently discovered DotNet.HighCharts project, is there any way how can i use it in winform application and view the chart in webBrowser.

I tried this but its not working,

        DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
   .SetXAxis(new XAxis
   {
       Categories = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
   })
   .SetSeries(new Series
   {
       Data = new Data(new object[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 })
   }).SetTitle(new Title { Text = "12223" });




        webBrowser1.DocumentText = chart.ToHtmlString();

回答1:

Not unless you host it externally and load it inside a webBrowser control.



回答2:

Change this : webBrowser1.DocumentText = chart.ToHtmlString(); to chart1 = chart.ToHtmlString();

on the Apsx page, do this :

<head runat="server">
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title></title>
  <script src="YOURFOLDERPROJECT/jquery-1.5.1.min.js" type="text/javascript"></script>
  <script src="YOURFOLDERPROJECT/highcharts.js" type="text/javascript"></script>
  <script src="YOURFOLDERPROJECT/exporting.js" type="text/javascript"></script>
</head>
<body>
 <form id="form1" runat="server">
  <div><asp:Literal id="chart1" runat="server"></asp:Literal>
  </div>
 </form>
</body>