具有MySQL数据的Highstock

时间:2016-04-21 11:29:10

标签: javascript php mysql json highstock

我有php文件,它以JSON格式生成数据values.php,我希望显示图表index.html和JS data1.js的文件。

values.php中的代码

import {Component} from 'angular2/core';

import {TestDirective} from '../../directives/test.directive';

@Component({
    selector: 'test-app',
    templateUrl: 'login-form.html',
    directives: [TestDirective]
})
export class TestApp {}

在index.html中

import {Directive} from 'angular2/core';

@Directive({
    selector: '[testdir]',
    host: {
        '(keydown)': 'run()'
    }
})
export class TestDirective {

    varpassword: string;

    constructor() {
        this.varpassword = [******]
    }

    run() {
        console.log( this.varpassword );
    }

}

和JS data1.js

<?php
$con = mysql_connect("localhost","root","root");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
$data = array();
$count = 0;
mysql_select_db("test", $con);
$result = mysql_query("SELECT * FROM sensor ORDER BY id ASC ") or die ("Connection error");
while($row = mysql_fetch_array($result)) {
//echo "[" . $row['time'] . "," . $row['value']. "]"."," ;
  $newdate = strtotime($row['time']) * 1000; 
$data[] = array($newdate, (float)$row['value']);
$count++;
}
echo json_encode($data);
mysql_close($con);
?>

似乎一切都好,但我不知道为什么不在浏览器中显示图形。 enter image description here 输出数据:enter image description here

也许有人会看到一些错误。可能在语法JSON数据行中出错?

0 个答案:

没有答案