highcharts 使用

highcharts 使用

 

 

 


highcharts 使用
 

 


       

  $.getJSON(url,function(jsonObject){
               chart = new Highcharts.Chart({ //HighCharts核心方法
                chart: {
                 renderTo: renderId,   //放置图标的容器(DIV)
                 defaultSeriesType: 'line', //折线图
                 zoomType: 'x',
                 backgroundColor: jsonObject.backgroundColor
                },
                credits: {             
                 enabled: false   //右下角不显示LOGO         
                }, 
                title: {
                          text: jsonObject.title,
                          style: {
                           font: '16px "Microsoft YaHei"',
                           color: '#393942'
                          }
                      },
                   xAxis: {  //X轴
                    categories: eval("(" + jsonObject.categories + ")"),
                       labels: eval("(" + jsonObject.xAxis_labels + ")")
                   },
                   yAxis: {
                       max: jsonObject.y_axis_max,
                 min: jsonObject.y_axis_min,
                 allowDecimals:false,
                          title: {
                              text: ''
                          }
                      },
                      tooltip: {
                          headerFormat: '<span style="font-size:12px">{point.key}</span><table>',
                          pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                              '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
                          footerFormat: '</table>',
                          shared: true,
                          useHTML: true,
                          borderColor: '#4BA9DF'
                      },
                      exporting: {             
                    enabled: false  //设置导出按钮不可用         
                   },
                   legend: {
                          enabled: true,
                          symbolWidth: 5,
                          borderWidth: 0
                   },
                   series: eval("(" + jsonObject.series + ")")
               });
              });

 

JSONObject jsonObject = new JSONObject();
try {
int step = 1;
JSONArray jsonArray = new JSONArray();
for (int i = showDataNum; i > 0; i--) {
jsonArray.put(DateUtils.formatDate(DateUtils
.getStringByBefore(i)));
}
jsonObject.put("categories", jsonArray.toString());
jsonObject
.append("series",
"[{name:'新增用户',color: '#4BA9DF',data: [1,2,3,4,5,6,5]}]");
jsonObject.append("xAxis_labels", "{step:" + step + "}");
jsonObject.append("title", "目前没有有效数据产生");
jsonObject.append("backgroundColor", "#ebebeb");
} catch (JSONException e) {
	e.printStackTrace();
}

 

 

你可能感兴趣的:(Ajax,前端,api,Highcharts,使用)