hightcharts图表简单使用



@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>PriceLclLog</title>
     @Html.Partial("_JsCss")
    <script src="~/Scripts/Custom/highcharts.js"></script>
</head>
<body>
        <div id="tb" style="height: auto">
        <h>起始日期:</h>
        <input style="width: 100px;" class="Wdate" id="Starttime" name="Starttime" οnclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
        <h>截止日期:</h>
        <input style="width: 100px;" class="Wdate" id="Endtime" name="Endtime" οnclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
        <input οnclick="searchClick();" type="button" value="检索" />
    </div>
      <div id="container" style="min-width: 400px; height: 300px; margin: 0 auto">

      </div>  
     <div id="container2" style="min-width: 400px; height: 300px; margin: 0 auto">

      </div>  
     <div id="container3" style="min-width: 400px; height: 300px; margin: 0 auto">

      </div>  
</body>
</html>

<script>

    $(function () {

        
        $.ajax({
            url: '/CompanysRepositoryLog/GetTongjiByCompanys',
            type: "post",
            success: function (data) {
                createchartsdata(data);
                createchartsdata2(data);
            }
        });

    });


    function createchartsdata(data)
    {
        var categories = [];
        var cdata = [];
        $.each(data.rows, function (index, item) {
            if (index <= 25) {
                categories.push(item.Country);
                cdata.push(item.Count);
            }
        });
        createcharts(categories, cdata);
    }


    function createchartsdata2(data) {
        var categories = [];
        var cdata = [];
        $.each(data.rows, function (index, item) {
            if (index > 25 && index <= 50) {
                categories.push(item.Country);
                cdata.push(item.Count);
            }
        });
        createcharts2(categories, cdata);
    }



    function createcharts(categories,_data)
    {
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: '海外直客热点图',
                labels: {
                    style: {
                        color: '#000'
                    },
                    color: '#000'
                }
            },
            //subtitle: {
            //    text: '5月份'
            //},
            xAxis: {
                categories: categories
            },
            yAxis: {
                min: 0,
                title: {
                    text: '点击数量'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span>',
                pointFormat: '' +
                    '',
                footerFormat: '<table><tbody><tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f} 次</b></td></tr></tbody></table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{
                name: '国家',
                data: _data,
                dataLabels: { //显示数值
                    enabled: true,
                    color: '#666666'
                }
            }
            ]
        });
    }

    function createcharts2(categories, _data) {
        var colors = Highcharts.getOptions().colors;
        $('#container2').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: '海外直客热点图'
            },
            //subtitle: {
            //    text: '5月份'
            //},
            xAxis: {
                categories: categories
            },
            yAxis: {
                min: 0,
                title: {
                    text: '点击数量'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span>',
                pointFormat: '' +
                    '',
                footerFormat: '<table><tbody><tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f} 次</b></td></tr></tbody></table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{
                name: '国家',
                data: _data,
                dataLabels: {
                    enabled: true,
                    color: '#666666'
                }
                //color: colors[2]  //修改柱状图颜色
            }
            ]
        });
    }
</script>



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值