图表Highcharts属性

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"    
  2.         pageEncoding="UTF-8"%>    
  3.     <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">    
  4.     <html>    
  5.     <head>    
  6.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">    
  7.     <title>Highcharts Demo</title>    
  8.     <script type="text/javascript" src="js/jquery.min.js"></script>    
  9.     <script type="text/javascript" src="js/highcharts.js"></script>    
  10.     <script type="text/javascript" src="js/excanvas.compiled.js"></script>    
  11.     <script type="text/javascript">    
  12.     var chart;    
  13.     $(document).ready(function() {    
  14.         chart = new Highcharts.Chart({    
  15.             chart: {    
  16.                 renderTo: 'container',//设置显示图表的容器    
  17.                 type: 'line',//设置图表样式,可以为line,spline, scatter, splinearea bar,pie,area,column    
  18.     //          defaultSeriesType: 'column', //图表的默认样式    
  19.     //          margin:[21, 23, 24, 54],//整个图表的位置(上下左右的空隙)    
  20.                 marginRight: 200,//右边间距    
  21.                 marginBottom: 25//底部间距/空隙    
  22.     //          inverted: false,//可选,控制显示方式,默认上下正向显示    
  23.     //          shadow:true,//外框阴影    
  24.     //          backgroundColor:"#FFF",    
  25.     //          animation:true,    
  26.     //          borderColor:"#888",    
  27.     //          borderRadius:5,    
  28.     //          borderWidth:1,    
  29.     //          ignoreHiddenSeries:true,    
  30.     //          reflow:true,    
  31.     //          plotBorderWidth:1,    
  32.     //          alignTicks:true    
  33.             },    
  34.             labels:{//在报表上显示的一些文本    
  35.                 items:[{    
  36.                     html:'本图表数据有误,仅用于说明相应的属性',    
  37.                     style:{left:'100px',top:'60px'}    
  38.                 }, {    
  39.                     html:'http://www.highcharts.com/demo',    
  40.                     style:{left:'100px',top:'100px'}    
  41.                 }]    
  42.             },    
  43.             credits:{//右下角的文本    
  44.                 enabled: true,    
  45.                 position: {//位置设置    
  46.                     align: 'right',    
  47.                     x: -10,    
  48.                     y: -10    
  49.                 },    
  50.                 href: "http://www.highcharts.com",//点击文本时的链接    
  51.                 style: {    
  52.                     color:'blue'    
  53.                 },    
  54.                 text: "Highcharts Demo"//显示的内容    
  55.             },    
  56.     //        plotOptions:{//绘图线条控制    
  57.     //            spline:{    
  58.     //                allowPointSelect :true,//是否允许选中点    
  59.     //                animation:true,//是否在显示图表的时候使用动画    
  60.     //                cursor:'pointer',//鼠标移到图表上时鼠标的样式    
  61.     //                dataLabels:{    
  62.     //                   enabled :true,//是否在点的旁边显示数据    
  63.     //                    rotation:0    
  64.     //                },    
  65.     //                enableMouseTracking:true,//鼠标移到图表上时是否显示提示框    
  66.     //                events:{//监听点的鼠标事件    
  67.     //                    click: function() {    
  68.     //                    }    
  69.     //                },    
  70.     //                marker:{    
  71.     //                    enabled:true,//是否显示点    
  72.     //                   radius:3,//点的半径    
  73.     //                      fillColor:"#888"    
  74.     //                    lineColor:"#000"    
  75.     //                    symbol: 'url(http://highcharts.com/demo/gfx/sun.png)',//设置点用图片来显示    
  76.     //                    states:{    
  77.     //                        hover:{    
  78.     //                            enabled:true//鼠标放上去点是否放大    
  79.     //                                                    },    
  80.     //                        select:{    
  81.     //                            enabled:false//控制鼠标选中点时候的状态    
  82.     //                        }    
  83.     //                    }    
  84.     //               },    
  85.     //                states:{    
  86.     //                    hover:{    
  87.     //                        enabled:true,//鼠标放上去线的状态控制    
  88.     //                        lineWidth:3    
  89.     //                    }    
  90.     //                },    
  91.     //                stickyTracking:true,//跟踪    
  92.     //                visible:true,    
  93.     //                lineWidth:2//线条粗细    
  94.     //                pointStart:100,    
  95.     //            }    
  96.     //        },    
  97.         
  98.             title: {    
  99.                 text: 'Monthly Average Temperature',//标题    
  100.                 x: -20 //center设置标题的位置    
  101.             },    
  102.             subtitle: {    
  103.                 text: 'Source: WorldClimate.com',//副标题    
  104.                 x: -20//副标题位置    
  105.             },    
  106.             xAxis: {//横轴的数据    
  107.                 categories: ['Jan''Feb''Mar''Apr''May''Jun',    
  108.                     'Jul''Aug''Sep''Oct''Nov''Dec']    
  109.     //          lineWidth:1,//纵轴一直为空所对应的轴,即X轴    
  110.     //          plotLines: [{//一条竖线    
  111.     //               color: '#FF0000',    
  112.     //               width: 2,    
  113.     //               value: 5.5    
  114.     //           }]    
  115.     //          labels: {//设置横轴坐标的显示样式    
  116.     //              rotation: -45,//倾斜度    
  117.     //              align: 'right',    
  118.     //              style: {    
  119.     //                   font: 'normal 13px Verdana, sans-serif'    
  120.     //                   color: 'white'    
  121.     //              }    
  122.     //          }    
  123.         
  124.             },    
  125.             yAxis: {    
  126.     //          tickInterval: 200,  //自定义刻度    
  127.     //          max:1000,//纵轴的最大值    
  128.     //          min: 0,//纵轴的最小值    
  129.                 title: {//纵轴标题    
  130.                     text: '百分数'    
  131.                 },    
  132.                 labels : {    
  133.                     formatter : function() {//设置纵坐标值的样式    
  134.                      return this.value + '%';    
  135.                     }    
  136.                    },     
  137.                 plotLines: [{    
  138.                     value: 0,    
  139.                     width: 1,    
  140.                     color: '#808080'    
  141.                 }]    
  142.             },    
  143.             tooltip: {//鼠标移到图形上时显示的提示框    
  144.                 formatter: function() {    
  145.                         return '<b>'this.series.name +'</b><br/>'+    
  146.                         this.x +': 'this.y +'°C';    
  147.                 }    
  148.     //          crosshairs:[{//控制十字线    
  149.     //              width:1,    
  150.     //              color:"#CCC",    
  151.     //              dashStyle:"longdash"    
  152.     //          }    
  153.         
  154.             },    
  155.             legend: {//方框所在的位置(不知道怎么表达)    
  156.                 layout: 'vertical',    
  157.                 align: 'right',    
  158.                 verticalAlign: 'top',    
  159.                 x: -10,    
  160.                 y: 100,    
  161.                 borderWidth: 0    
  162.             },    
  163.             series: [{//以下为纵轴数据    
  164.                 name: 'Tokyo',    
  165.                 data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]    
  166.             }, {    
  167.                 name: 'New York',    
  168.                 data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]    
  169.             }, {    
  170.                 name: 'Berlin',    
  171.                 data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]    
  172.             }, {    
  173.                 name: 'London',    
  174.                 data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]    
  175.             }]    
  176.         });    
  177.     });    
  178.     </script>    
  179.     </head>    
  180.     <body>    
  181.     <div id="container" ></div>    
  182.     </body>    
  183.     </html>   





  1. 属性说明【部分】  
  2.   
  3. 一.chart的部分相关属性说明  
  4.     renderTo: 'container',      //图表的页面显示容器(也就是要显示到的div)  
  5.     defaultSeriesType: 'line',  //图表类型(line、spline、scatter、splinearea、bar、pie、area、column)  
  6.     marginRight: 50,            //上下左右空隙(图表跟图框之间)  
  7.     marginBottom: 60,           //下面空隙如果不够大,图例说明有可能看不到  
  8.     plotBackgroundImage: '../graphics/skies.jpg'//(图表的)背景图片  
  9.     plotBackgroundColor:        //背景颜色  
  10.     width: 1000,                //图框(最外层)宽(默认800)  
  11.     height: 500,                //图框高(默认500)   
  12.     backgroundColor: "red"      //图框的背景颜色  
  13.     borderColor: "red"          //图框的边框颜色  
  14.     borderRadius: 5,            //图框的圆角大小  
  15.     borderWidth: 9,             //图框的边框大小  
  16.     inverted: false,            //(使图)倒置  
  17.     plotBorderColor: "red",     //图表的边框颜色  
  18.     plotBorderWidth: 0,         //图表的边框大小  
  19.     plotShadow: false,          //图表是否使用阴影效果  
  20.     reflow: false,     
  21.     shadow:true                 //图框是否使用阴影  
  22.     showAxes: false,            //是否最初显示轴  
  23.     spacingTop: 100,            //图表上方的空白  
  24.     spacingRight: 10,  
  25.     spacingBottom: 15,  
  26.     spacingLeft: 10,  
  27.     colors: [...]                 //图上线。。的颜色  
  28.   
  29. 二. credits的部分相关属性说明  
  30.     credits:  //设置右下角的标记。highchart.com (这个也可以在highcharts.js里中修改)  
  31.     {      
  32.         //enabled: true,      //是否显示  
  33.         position: {           //显示的位置                     
  34.             align: 'left',         
  35.             x: 10                             
  36.         },  
  37.         text: "xoyo.com",           //显示的文字  
  38.         style:{                     //样式  
  39.             cursor: 'pointer',  
  40.             color: 'red',  
  41.             fontSize: '20px'  
  42.         },  
  43.         href: 'http://www.xoyo.com', //路径  
  44.     },  
  45. 三. title的部分相关属性说明  
  46.     title: //标题  
  47.     {   
  48.         text: '月份平均温度',  
  49.         x: -20,                  //center //水平偏移量   
  50.         y: 100                   //y:垂直偏移量  
  51.         align: 'right'         //水平方向(left, right, bottom, top)  
  52.         floating: true,          //是否浮动显示  
  53.         margin: 15,  
  54.         style: ,                 //样式  
  55.         verticalAlign: "left"    //垂直方向(left, right, bottom, top)  
  56.     },  
  57. 四. xAxis或者YAxis的部分相关属性说明  
  58.     categories: ['一月''二月'],  
  59.     //allowDecimals: false  
  60.     //alternateGridColor: 'red'       //在图表中相隔出现纵向的颜色格栅  
  61.     //dateTimeLabelFormats: ,  
  62.     //endOnTick: false,               //是否显示控制轴末端的一个cagegories出来  
  63.     //events: {  
  64.     //setExtremes:  
  65.     //},  
  66.     //gridLineColor: "red",           //纵向格线的颜色  
  67.     //gridLineDashStyle: Solid        //纵向格栅线条的类型  
  68.     //gridLineWidth: 5,               //纵向格线的的大小  
  69.     //id: null,  
  70.     //labels: {  //X轴的标签(下面的说明)  
  71.         //align: "center",              //位置  
  72.         //enabled: false,               //是否显示  
  73.         //formatter: ,  
  74.         //rotation: 90,                 //旋转,效果就是影响标签的显示方向  
  75.         //staggerLines: 4,              //标签的交错显示(上、下)  
  76.         //step: 2,                      //标签的相隔显示的步长  
  77.         //style:{},  
  78.         //x: 100,                     //偏移量,默认两个都是0,  
  79.         //y: 40  
  80.           
  81.     //},  
  82.     //lineColor: "red",               //X轴的颜色  
  83.     //lineWidth: 5,                   //X轴的宽度  
  84.     //linkedTo:1,  
  85.     //opposite: true                  //是否把标签显示到对面  
  86.     //max: 12,                        //显示的最大值  
  87.     //maxPadding: 6,  
  88.     //maxZoom: 1,  
  89.     //min: 10,                        //显示的最小值  
  90.     //minorGridLineColor: 'red',        //副格线的颜色  
  91.     //minorGridLineDashStyle: 'blod', //副格线的的颜色  
  92.     //minorGridLineWidth: 50,         //副格线的宽度  
  93.     //minorTickColor: #A0A0A0,        //???没有看出效果  
  94.     minorTickInterval:3,               //副标记的间隔  
  95.     //minorTickLength: 10,             //副标记的长度  
  96.     //minorTickPosition: 'inside',     //副标记的位置  
  97.     //minorTickWidth: 5,               //副标记的宽  
  98.     //minPadding: 0.01,  
  99.     //offset: 0,                       //坐标轴跟图的距离  
  100.     //plotBands: //使某数据块显示不同的效果      
  101.     //plotLines: [{         //标线属性  
  102.         //value: 0,      //值为0的标线  
  103.     //}],          
  104.     //tickmarkPlacement: "on",   //标记(文字)显示的位置,on表示在正对位置上。  
  105.     //reversed: true,            //是否倒置  
  106.     //showFirstLabel: false,     //第一个标记的数值是否显示  
  107.     //startOfWeek: 2,  
  108.     //tickColor: 'blue',         //标记(坐标的记号)的颜色  
  109.     //tickInterval: 20,          //标记(坐标的记号)的步长  
  110.     //tickLength: 5,  
  111.     //tickmarkPlacement: "on",  
  112.     //tickPixelInterval: 1000,   //两坐标之间的宽度  
  113.     //tickPosition: "inside",    //坐标标记的方向  
  114.     //title: {                   //设置坐标标题的相关属性  
  115.         //margin: 40,  
  116.         //rotation: 90,  
  117.         //text: "Y-values",  
  118.         //align: "middle",  
  119.         //enabled: "middle",  
  120.         //style: {color: 'red'}  
  121.     //},  
  122.     //type: "linear"  
  123. 五.tooltip的部分相关属性说明  
  124.     tooltip: //提示框设置  
  125.     {        
  126.         formatter: function() {  //格式化提示框的内容样式  
  127.         return '<b>'this.series.name +'</b><br/>'+  
  128.                 this.x +': 'this.y +'°C';  
  129.         },                         
  130.         backgroundColor: '#CCCCCC',   //背景颜色  
  131.         //borderColor: '#FCFFC5'      //边框颜色  
  132.         //borderRadius: 2             //边框的圆角大小  
  133.         borderWidth: 3,               //边框宽度(大小)  
  134.         //enabled: false,             //是否显示提示框  
  135.         //shadow: false,              //提示框是否应用阴影  ?没有看出明显效果?????????  
  136.         //shared: true,               //当打开这个属性,鼠标几个某一区域的时候,如果有多条线,所有的线上的据点都会有响应(ipad)  
  137.         //snap: 0,                    //没有看出明显效果?????????  
  138.         crosshairs: {                 //交叉点是否显示的一条纵线  
  139.             width: 2,  
  140.             color: 'gray',  
  141.            dashStyle: 'shortdot'  
  142.         }  
  143.         style: {  //提示框内容的样式  
  144.             color: 'white',  
  145.             padding: '10px',    //内边距 (这个会常用到)  
  146.             fontSize: '9pt',              
  147.         }  
  148.     },  
  149. 六.legend(图例说明)的部分相关属性说明  
  150.     legend: //图例说明  
  151.     {     
  152.         //layout: 'vertical',   //图例说明布局(垂直显示,默认横向显示)  
  153.         align: 'center',        //图例说明的显示位置  
  154.         //verticalAlign: 'top', //纵向的位置  
  155.         //x: 250,                 //偏移量   
  156.         //y: 0,                 
  157.         borderWidth: 1,            //边框宽度  
  158.         //backgroundColor: 'red'   //背景颜色  
  159.         borderColor: 'red',  
  160.         //borderRadius             //边框圆角  
  161.         //enabled: false          //是否显示图例说明  
  162.         //floating:true           //是否浮动显示(效果就是会不会显示到图中)  
  163.         //itemHiddenStyle: {color: 'red'},  
  164.         //itemHoverStyle: {color: 'red'}   //鼠标放到某一图例说明上,文字颜色的变化颜色  
  165.         //itemStyle:  {color: 'red'}   //图例说明的样式  
  166.         //itemWidth:                   //图例说明的宽度  
  167.         //labelFormatter: function() { return this.value}       //?????????????默认(return this.name)  
  168.         //lineHeight: 1000             //没看出明显效果  
  169.         //margin: 20  
  170.         //reversed:true                //图例说明的顺序(是否反向)  
  171.         //shadow:true                  //阴影  
  172.         //style: {color:'black'}  
  173.         //symbolPadding: 100           //标志(线)跟文字的距离  
  174.         //symbolWidth: 100             //标志的宽  
  175.         //width:100  
  176.     },  
  177. 七. plotOptions的部分修改属性说明  
  178.     plotOptions: (我这个是在柱形图上做的测试)  
  179.     {    
  180.         column: //柱形图  
  181.         {  
  182.             //pointPadding: 0.2,  
  183.             //borderWidth: 1,               //柱子边框的大小  
  184.             //borderColor: "red",           //柱子边框的颜色  
  185.             //borderRadius: 180,            //柱子两端的圆角的半径  
  186.             //colorByPoint: true,           //否应该接受每系列的一种颜色或每点一种颜色  
  187.             groupPadding: 0,                //每一组柱子之间的间隔(会影响到柱子的大小)  
  188.             //minPointLength: 0,            //最小数据值那一条柱子的长度(如果是0,可能看不到,可以设置出来)  
  189.             //pointPadding: 0.1,            //柱子之间的间隔(会影响到柱子的大小)  
  190.             //pointWidth: 2,                //柱子的大小(会影响到柱子的大小)  
  191.             //allowPointSelect: false,   
  192.             //animation: true,              //图形出来时候的动画  
  193.             //color: 'red',                 //柱子的颜色  
  194.             //connectNulls: false,          //连接图表是否忽略零点(如线形图,数据为0是是否忽略)  
  195.             //cursor: '',                   //?????????游标  
  196.             //dashStyle: null,  
  197.             dataLabels: { //图上是否显示数据标签  
  198.             //enabled: true,  
  199.             align: "center",  
  200.             //color: 'red',  
  201.             formatter: function()   
  202.             {  
  203.                 return this.y + 'mm'  
  204.             },  
  205.             rotation: 270,  
  206.             //staggerLines: 0,  
  207.             //step: ,  
  208.             //style: ,  
  209.             //x: 0,  
  210.             //y: -6  
  211.             },  
  212.             //enableMouseTracking:   
  213.             events: {    //事件  
  214.             click: function(event)  
  215.             {  
  216.                 alert(this.name);  
  217.             },  
  218.             //checkboxClick: ,  
  219.             //hide: ,  
  220.             //legendItemClick: ,  
  221.             //mouseOver: ,  
  222.             //mouseOut: ,  
  223.             //show:  
  224.             },  
  225.             //id: null,  
  226.             //lineWidth: 20,  
  227.             //marker: {  //图例说明上的标志  
  228.             //enabled: false  
  229.             //},  
  230.             point: {     //图上的数据点(这个在线形图可能就直观)  
  231.             events: {  
  232.                 click: function()   
  233.                 {  
  234.                 alert(this.y);  
  235.                 },  
  236.                 //mouseOver: ,  
  237.                 //mouseOut: ,  
  238.                 //remove: ,  
  239.                 //select: ,  
  240.                 //unselect: ,  
  241.                 //update:  
  242.                 }  
  243.             },  
  244.             //pointStart: 0,     //显示图数据点开始值  
  245.             //pointInterval: 1,  //显示图数据点的间隔  
  246.             //selected: false,  
  247.             //shadow: true,  
  248.             //showCheckbox: true,  //是否显示(图例说明的)复选框  
  249.             //showInLegend: false, //是否显示图例说明  
  250.             //stacking: 'percent', //是否堆积???  
  251.             states:   
  252.             {  
  253.                             hover:   
  254.                 {  
  255.                                 //brightness: 0.1,  
  256.                                 enabled: true,    //图上的数据点标志是否显示  
  257.                                 //lineWidth: 2,    //没看出效果  
  258.                                 marker:   
  259.                 {  
  260.                                     //states: ,  
  261.                                     //enabled: true,         //数据点标志是否显示  
  262.                                     //fillColor: null,       //数据点标志填充的颜色  
  263.                                     //lineColor: "#FFFFFF",  //数据点标志线的颜色  
  264.                                     //lineWidth: 0,          //数据点标志线的大小  
  265.                                     //radius: 45,            //数据点标志半径  
  266.                                     //symbol: 'triangle'//'url(http://highcharts.com/demo/gfx/sun.png)' //数据点标志形状(triangle三角形,或者用图片等等)  
  267.                                 }  
  268.                             }  
  269.                      },  
  270.              //stickyTracking: true,  //轨道粘性 (例如线图,如果这个设置为否定,那就必须点到数据点才有反应)  
  271.              //visible: true,         //设置为false就不显示图  
  272.              //zIndex: null           //没有看出效果???  
  273.     },  

猜你喜欢

转载自blog.csdn.net/weixin_42387852/article/details/80760021