asp.net 柱形图

在vs中,如果要使用柱形图,我们大多数使用第三方提供的插件,所以必须要引用样式,这里我使用的是Highcharts-4.1.9插件,百度一下就可以下载到。关键的js代码:

<script src="../Highcharts-4.1.9/js/jquery-1.8.2.min.js"></script>
        <style type="text/css">
        </style>
        <script type="text/javascript">
            $(function () {
                $('#container').highcharts({
                    chart: {
                        type: 'column'
                    },
                    title: {
                        text: '各科室出院人次统计'
                    },
                    subtitle: {
                        text: '柱形图'
                    },
                    xAxis: {
                        type: 'category',
                        labels: {
                            rotation: -45,
                            style: {
                                fontSize: '13px',
                                fontFamily: 'Verdana, sans-serif'
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        title: {
                            text: '出院人次'
                        }
                    },
                    legend: {
                        enabled: false
                    },
                    tooltip: {
                        pointFormat: '{series.name}: <b>{point.y}</b><br/>'
                    },
                    series: <%= returnValue %>,
                    dataLabels: {
                        enabled: true,
                        rotation: 0,
                        color: '#FFFFFF',
                        align: 'center',
                        format: '{point.y}', // one decimal
                        y: 10, // 10 pixels down from the top
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif'
                        }
                    }
                }]
            });
            });
           
</script>

//body里面内容
<body>
    <form id="form1" runat="server">
    <div class="easyui-panel" style="padding: 5px; margin-top:10px;">
            <script src="../Highcharts-4.1.9/js/highcharts.js" type="text/javascript"></script>
            <script src="../Highcharts-4.1.9/js/modules/exporting.js" type="text/javascript"></script>
            <div id="container" style="min-width: 300px; height: 400px; margin: 0 auto"></div>
        </div>
    </form>
</body>

.net后台获取数据库数据填充:
public string returnValue = "";
public string containerHeight = "400px";

//关键性代码
DataTable dt = ((DataSet)rs).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows.Count > 4)
                    {
                        containerHeight = (dt.Rows.Count * 50).ToString() + "px";
                    }
                    else
                    {
                        containerHeight = "200px";
                    }
                    string dataY = "[{name: '总费用',data: [";
                    foreach (DataRow dr in dt.Rows)
                    {
                        dataY += "['" + dr["名称"].ToString() + "'," + dr["总费用"].ToString() + "]" + ",";
                    }
                    returnValue = dataY + "]";
                }


转载于: http://www.cnblogs.com/hyyweb/p/5141021.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值