javascript - HighCharts 仅显示标题

标签 javascript jquery highcharts

我一整天都在研究这个 HighCharts 示例,但未能使其全部正常工作。我正在显示在 getJSON 调用中检索到的多个数据系列。图表被放入其容器 DIV 中,但没有绘制数据,并且 JavaScript 控制台上没有错误。

我认为问题一定出在 JSONP 调用格式上,但我看不出有任何问题。 JSONP 服务位于:http://199.38.183.107/ow/fludata.php?callback=?

<html>
<head>
<title>Demonstration of web service</title>
<style type="text/css">
.chart-container {
    width: 100%;
    height: 100%;
}
</style>
</head>

<body>

<div id="container" style="width: 100%; height: 400px;"></div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js">       </script>
<script src="http://code.highcharts.com/highcharts.js"></script>

<script>

$(function () {
  $.getJSON('http://199.38.183.107/ow/fludata.php?callback=?', function(data){
    $('#container').highcharts({
      chart: {
        type: 'spline'
  },
  title: {
    text: 'Weekly influenza infection counts'
  },
  subtitle: {
    text: 'Data series show the CDC Regions'
  },
  xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: { // don't display the dummy year
      month: '%e. %b',
      year: '%b'
    }
  },
  yAxis: {
    title: {
      text: 'Number of infections reported'
    },
    min: 0
  },
  plotOptions: {
    series: {
      marker: {enabled: false},
      turboThreshold: 1000000,
      states: {hover: {enabled: false}}
    }
  },
  tooltip: {
        formatter: function() {
           return '<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%e. %b', this.x) +': '+ this.y +' m';
        }
      },
      series: data,
      credits: { enabled: false }
    }); //container
  }); //getJSON
}); //function

最佳答案

问题出在您的日期/时间上。您应该将您的时间乘以 1000

关于javascript - HighCharts 仅显示标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19693473/

相关文章:

javascript - 禁用特定下拉值上的按钮

javascript - 选择实时更改输入的保持值

javascript - 使用 Javascript 合并 JSON api 响应

javascript - highcharts 未在选项卡中加载

highcharts - 我无法让 Highcharts phantomJs 导出服务器工作

javascript - Elasticsearch 显示重复命中

javascript - 如果用户输入长度= x , btn.click() 函数

javascript - TextureLoader 中的 onLoad 不起作用?

javascript - 如何在 jQuery 中获取 Request.ApplicationPath

highcharts - 将区域扩展到图表的全宽,月份在 x 轴上