jquery图表插件highcharts

本文介绍如何在ASP.NET应用程序中使用Highcharts创建交互式图表。通过具体示例展示了必要的JavaScript引用、图表初始化代码及关键配置选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 官网及features?

2. highcharts(asp.net)?

3. 代码下载


1. 官网及features?

highcharts官网:http://www.highcharts.com/

demo site : http://www.highcharts.com/demo/?example=bar-basic&theme=grid

features:


2. highcharts使用(asp.net)?

页面Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AspNetHighCharts._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> <!-- 1. Add these JavaScript inclusions in the head of your page --> <mce:script src="Highcharts/js/jquery.min.js" mce_src="Highcharts/js/jquery.min.js" type="text/javascript"></mce:script> <mce:script src="Highcharts/js/highcharts.js" mce_src="Highcharts/js/highcharts.js" type="text/javascript"></mce:script> <!-- 1a) Optional: add a theme file --> <%--<mce:script src="Highcharts/js/themes/grid.js" mce_src="Highcharts/js/themes/grid.js" type="text/javascript"></mce:script>--%> <mce:script src="Highcharts/js/modules/exporting.js" mce_src="Highcharts/js/modules/exporting.js" type="text/javascript"></mce:script> <!-- 2. Add the JavaScript to initialize the chart on document ready --> <mce:script type="text/javascript"><!-- var categories = new Array(); // Build the categories object <% for(int i = 0; i < chartProperties.xAxisCategories.Count; i++) { %> categories[<%= i %>] = '<%= chartProperties.xAxisCategories[i] %>'; <% } %> var series = new Array(); // Buld the series object series['name'] = '<%= chartProperties.series.name %>'; var data = new Array(); <% for(int i = 0; i < chartProperties.series.data.Count; i++) { %> data[<%= i %>] = <%= chartProperties.series.data[i] %>; <% } %> series['data'] = data; var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', defaultSeriesType: 'bar' }, title: { text: '<%= chartProperties.titleText %>' }, subtitle: { text: '<%= chartProperties.subtitleText %>' }, xAxis: { categories: categories, title: { text: '<%= chartProperties.xAxisTitleText %>' } }, yAxis: { min: <%= chartProperties.yAxisMinValue %>, title: { text: 'yAxis', align: 'high' } }, tooltip: { formatter: function() { return '<%= chartProperties.tooltip %>'; /*return '' + this.series.name + ': ' + this.y + ' millions';*/ } }, plotOptions: { bar: { dataLabels: { enabled: true } } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y: 60, floating: true, borderWidth: 1, backgroundColor: '#FFFFFF', shadow: true }, credits: { enabled: false }, series: [series] }); }); // --></mce:script> </head> <body> <form id="form1" runat="server"> <div> <!-- 3. Add the container --> <div id="container" style="width: 500px; height: 250px; margin: 0 auto"></div> </div> </form> </body> </html>

HighChartProperties.cs:

using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace AspNetHighCharts { public class HighChartProperties { public string titleText = string.Empty; public string subtitleText = string.Empty; public IList<string> xAxisCategories = new List<string>(); public string xAxisTitleText = string.Empty; public int yAxisMinValue = new int(); public string yAxisTitleText = string.Empty; public string tooltip = string.Empty; public int legendXPos = new int(); public int legendYPos = new int(); public Series series = new Series(); } }

Series.cs:

using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace AspNetHighCharts { public class Series { public string name = string.Empty; public IList<double> data = new List<double>(); } }


3. 代码下载

代码下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值