首页 > 代码库 > highcharts 显示点值的效果

highcharts 显示点值的效果

 plotOptions: {                line: {                	/*                  <s:if test=‘#request.rdflags=="point"‘>		                    <s:if test="%{#request.chartsVO.category == ‘rd‘}">		 					dataLabels: {		 						enabled: true,		 	                    borderRadius: 3,		                        backgroundColor: ‘rgba(252, 255, 197, 0.7)‘,		                        borderWidth: 1,		                        borderColor: ‘#AAA‘,		                        y:-7, 		 	                   formatter:function(){		                           var ary = this.series.data;		                           var i;		                           for (i = 0; i < ary.length; i++)							        {							            if (this.x == ary[i].x)							            {							                break;							            }							        }		                           if (i%4 == 0 && ary.length-1-i>3|| i == ary.length-1) {		                                return this.y;		                            }else {		                                return null;		                           }		                       }		 	                },		 	               </s:if> 	               </s:if> 	               */                    marker: {                    	<s:if test=‘#request.rdflags=="point"‘>                    	   enabled:false,                    	</s:if>                    	<s:else>                    	enabled:true,                    	radius: 1,                    	</s:else>						states:{  							hover:{  								enabled:true,								radius:4                            }						}                      },                    states:{  						hover:{  							enabled:true                        }					}                }            },

第二种方法:

  1  series: [  2                 <s:iterator var="item" value="http://www.mamicode.com/#request.chartsVO.series" status="status">  3                 {  4                     name : ‘${item.name}‘,  5                     type: ‘${item.type}‘,  6                     yAxis: ${item.yaxis},  7                     color: ‘${item.color}‘,  8                     tooltip: {  9                         valueDecimals:${item.precision} 10                     }, 11                     data: [ 12                         <s:iterator var="d" value="http://www.mamicode.com/#item.datas" status="d_status"> 13                             <s:if test="%{#request.chartsVO.xaxisVO.xaxisType == ‘datetime‘}"> 14                             <s:if test=‘#d.y!=null‘> 15                                 <s:if test=‘#request.rdflags=="point"‘> 16                                     <s:if test="%{(#d_status.index % 4==0 && #item.datas.size()-#d_status.index>3)||#d_status.last}"> 17                                     { 18                                         x:${d.x}, 19                                         dataLabels: { 20                                             enabled: true 21                                         }, 22                                         marker:{ 23                                             enabled:true 24                                         }, 25                                         y:${d.y} 26                                     } 27                                     </s:if> 28                                     <s:else> 29                                     [${d.x}, ${d.y}] 30                                     </s:else> 31                                 </s:if> 32                                 <s:else> 33                                   [${d.x}, ${d.y}] 34                                 </s:else> 35                             </s:if> 36                             <s:else> 37                               [${d.x}, null] 38                             </s:else> 39                             </s:if> 40                             <s:if test="%{#request.chartsVO.xaxisVO.xaxisType == ‘category‘}"> 41                                  <s:if test="%{#request.chartsVO.category == ‘xd‘}"> 42                                       <s:if test=‘#d.y!=null‘> 43                                                <s:if test=‘#request.rdflags=="point"‘> 44                                                         <s:if test="%{(#d_status.index % 4==0 && #item.datas.size()-#d_status.index>4)||#d_status.last}"> 45                                                         { 46                                                             dataLabels: { //datalabels 标签的 enabled属性控制点值的显示 47                                                                enabled: true 48                                                             }, 49                                                             marker:{ 50                                                                 enabled:true 51                                                             }, 52                                                             y:${d.y} 53                                                         } 54                                                         </s:if> 55                                                         <s:else> 56                                                         [, ${d.y}] 57                                                         </s:else> 58                                                 </s:if> 59                                                 <s:else> 60                                                    [, ${d.y}] 61                                                 </s:else> 62                                       </s:if> 63                                       <s:else> 64                                           [, null] 65                                       </s:else> 66                                   </s:if> 67                                   <s:else> 68                                       <s:if test=‘#d.y!=null‘> 69                                            <s:if test=‘#request.rdflags=="point"‘> 70                                                     <s:if test="%{(#d_status.index % 2==0 && #item.datas.size()-#d_status.index>2)||#d_status.last}"> 71                                                     { 72                                                         dataLabels: { 73                                                                enabled: true 74                                                         }, 75                                                         marker:{ 76                                                             enabled:true 77                                                         }, 78                                                         y:${d.y} 79                                                     } 80                                                     </s:if> 81                                                     <s:else> 82                                                     [, ${d.y}] 83                                                     </s:else> 84                                             </s:if> 85                                             <s:else> 86                                                [, ${d.y}] 87                                             </s:else> 88                                       </s:if> 89                                       <s:else> 90                                           [, null] 91                                       </s:else> 92                                   </s:else> 93                             </s:if> 94                             <s:if test="!#d_status.last">,</s:if> 95                         </s:iterator> 96                     ] 97                 } 98                 <s:if test="!#status.last">,</s:if> 99                 </s:iterator>100             ]

 

highcharts 显示点值的效果