donglengyuan6826 2015-09-06 08:40
浏览 34

Highcharts类别(x)未显示

I would like to fetch data from mysql. I am seeng values (Poraba), but not categories. Is there anyone to help me? I didnt try json print, but I think that is necessary.

http://postimg.org/image/c2ensejl3/

php code:

<?php

   session_start();

    session_regenerate_id();

   include("db_connection.php");


   if(!(isset($_SESSION['username'], $_SESSION['login_string']) || isset($_COOKIE['username']))){

      header("Location: index.html");
      exit();
   }

   $username = $_SESSION['username'];

   $rezultat = "SELECT vrednost, kategorija FROM vrednosti WHERE username = '$username'";

   $result = mysqli_query($link, $rezultat);

   if (mysqli_num_rows($result) > 0) {

    while($row = mysqli_fetch_assoc($result)) {
        echo "" . $row["kategorija"]. "\t" . $row["vrednost"].  "
";
    }
      } else {
      echo "Še ni zapisov";
   }  

      mysqli_close($link);
?>

Query gives me correct values:

"Kurjava 34 Kredit 200 Trgovina 45 Tehnika 54 Vrtec 200"

html code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 


<title>Using Highcharts with PHP and MySQL</title>

<script type="text/javascript" src="js/jquery-1.7.1.min.js" ></script>
<script type="text/javascript" src="js/highcharts.js" ></script>
<script type="text/javascript" src="js/themes/gray.js"></script>

<script type="text/javascript">
   var chart;
         $(document).ready(function() {
            var options = {
               chart: {
                  renderTo: 'container',
                  defaultSeriesType: 'line',
                  marginRight: 130,
                  marginBottom: 25
               },
               title: {
                  text: 'Mesečna statistika',
                  x: -20 //center
               },
               subtitle: {
                  text: '',
                  x: -20
               },
               xAxis: {

                  type: 'datetime',
                  tickInterval: 3600 * 1000, // one hour
                  tickWidth: 0,
                  gridLineWidth: 0,
                  labels: {
                     align: 'center',
                     x: -3,
                     y: 20,
                     formatter: function() {
                        return Highcharts.dateFormat('%l%p', this.value);
                     }
                  }
               },
               yAxis: {
                  title: {
                     text: 'Poraba'
                  },
                  plotLines: [{
                     value: 0,
                     width: 1,
                     color: '#808080'
                  }]
               },
               tooltip: {
                  formatter: function() {
                            return Highcharts.dateFormat('%l%p', this.x-(1000*3600)) +'-'+ Highcharts.dateFormat('%l%p', this.x) +': <b>'+ this.y + '</b>';
                  }
               },
               legend: {
                  layout: 'vertical',
                  align: 'right',
                  verticalAlign: 'top',
                  x: -10,
                  y: 100,
                  borderWidth: 0
               },
               series: [{
                  name: 'Vrednost'
               }]
            }
            // Load data asynchronously using jQuery. On success, add the data
            // to the options and initiate the chart.
            // This data is obtained by exporting a GA custom report to TSV.
            // http://api.jquery.com/jQuery.get/
            jQuery.get('statistika.php', null, function(tsv) {
               var lines = [];
               traffic = [];
               try {
                  // split the data return into lines and parse them
                  tsv = tsv.split(/
/g);
                  jQuery.each(tsv, function(i, line) {
                     line = line.split(/\t/);
                     date = Date.parse(line[0] +' UTC');
                     traffic.push([
                        date,
                        parseInt(line[1].replace(',', ''), 10)
                     ]);
                  });
               } catch (e) {  }
               options.series[0].data = traffic;
               chart = new Highcharts.Chart(options);
            });
         });
</script>
</head>
<body>

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

</body>
</html>

I think, that mistake is in tooltip formmater function, but I dont know how to replaced it.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)