dongxie3701 2016-10-31 13:13
浏览 153

如何使用数据库值创建折线图?

I have a database to save some value which is gerilim, akim and power.

I want to make a line chart with these values from database. I search on the internet and couldn't find anything. Here is my script code;

* LINE CHART
 * ----------
 */
//LINE randomly generated data

var data = [],id=0;
<?php 
include"../../pages/veri_ayar.php";

$verileriCek = mysql_query("SELECT * FROM etkin");

            while ($b=mysql_fetch_array($verileriCek)){

                $akim = $b['akim'];
        $id=$b['id'];

            }
   data=$akim;
   id=$id;?>


var i=0;
    while(i < id ) {
      data;
      i++;
    }
    var line_data1 = {
      data: data,
      color: "#3c8dbc"
    };
    $.plot("#line-chart", [line_data1], {
      grid: {
        hoverable: true,
        borderColor: "#f3f3f3",
        borderWidth: 1,
        tickColor: "#f3f3f3"
      },
      series: {
        shadowSize: 0,
        lines: {
          show: true
    },
    points: {
      show: true
    }
  },
  lines: {
    fill: false,
    color: ["#3c8dbc"]
  },
  yaxis: {
    show: true,
  },
  xaxis: {
    show: true
  }
});
//Initialize tooltip on hover
$('<div class="tooltip-inner" id="line-chart-tooltip"></div>').css({
  position: "absolute",
  display: "none",
  opacity: 0.8
}).appendTo("body");
$("#line-chart").bind("plothover", function (event, pos, item) {

  if (item) {
    var x = item.datapoint[0].toFixed(2),
        y = item.datapoint[1].toFixed(2);

    $("#line-chart-tooltip").html(item.series.label + " of " + x + " = " + y)
        .css({top: item.pageY + 5, left: item.pageX + 5})
        .fadeIn(200);
  } else {
    $("#line-chart-tooltip").hide();
  }

});
/* END LINE CHART */
  • 写回答

1条回答 默认 最新

  • douweng3383 2016-10-31 13:20
    关注

    The best way is to build a REST API with php that will serve a JSON that will contain all the values, then you can Get that JSON with AJAX from the client-side (JavaScript) and use a great visualization lib like D3.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度