jquery图表插件highcharts使用

当我们使用highcharts做这样的图是不是很老火,其实开始我感觉很麻烦。但是官网上有demo,虽然只有很小一部分。http://www.highcharts.com/demo/column-stacked基本百度一下就可以找到加入曲线。其实就是 serese 的数据,只是加入type属性就更改成你想要的。下面那个table你可以使用table加入jquery实现就ok了

$(function () {

        $('#container').highcharts({

            chart: {

                type: 'column'

            },

            title: {

                text: 'Stacked column chart'

            },

            xAxis: {

gridLineWidth:1,

 plotOptions: {

 column: {

 pointPadding: 0.2,

 pointWidth: 30  //柱子的宽度30px

 }

 },

//tickPixelInterval:100,

                categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']

            },

            yAxis: {

                tickPositions: [0, 100, 200, 300, 400,500],//设置刻度

                min: 0,

                title: {

                    text: 'Total fruit consumption'

                },

                stackLabels: {

                    enabled: true,

                    style: {

                        fontWeight: 'bold',

                        color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'

                    }

                }

            },

            legend: {

                align: 'right',

                x: -100,

                verticalAlign: 'top',

                y: 20,

                floating: true,

                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',

                borderColor: '#CCC',

                borderWidth: 1,

                shadow: false

            },

            tooltip: {

                formatter: function() {

                    return '<b>'+ this.x +'</b><br/>'+

                        this.series.name +': '+ this.y +'<br/>'+

                        'Total: '+ this.point.stackTotal;

                }

            },

            plotOptions: {

                column: {

                    stacking: 'normal',

                    pointWidth: 30 , //柱子的宽度30px

                    dataLabels: {

                        enabled: true,

                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'

                    }

                }

            },

            series: [{

                color:'#F2BE20',

                name: 'John',

                data: [50, 30, 40, 70, 20]

            }, {

                color:'#F8FB23',

                name: 'Jane',

                data: [20, 20, 30, 20, 10]

            }, {

                color:'#E9070B',

                name: 'Joe',

                data: [30, 40, 40, 20, 50]

            },{type: 'line', 

                name: 'John', 

                data:[{ 

name: 'John',

                    y: 50

                }, 

                { 

name: 'John',

                    y: 30

                }, 

                { 

name: 'John',

                    y: 40

                },{ 

name: 'John',

                    y: 70

                },{ 

name: 'John',

                    y: 20

                }

                ]},

                {type: 'line', 

                    name: 'Joe', 

                    data:[{ 

name: 'Joe',

                        y: 30

                    }, 

                    { 

name: 'Joe',

                        y: 40

                    }, 

                    { 

name: 'Joe',

                        y: 40

                    },{ 

name: 'Joe',

                        y: 20

                    },{ 

name: 'Joe',

                        y: 50

                    }

                    ]},

                    {type: 'line', 

                        name: 'Jane', 

                        data:[{ 

name: 'Jane',

                            y: 20

                        }, 

                        { 

name: 'Jane',

                            y: 20

                        }, 

                        { 

name: 'Jane',

                            y: 30

                        },{ 

name: 'Jane',

                            y: 20

                        },{ 

name: 'Jane',

                            y: 10

                        }

                        ]}

                ]

        });

    });

</script>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值