使用数据库中的数据加载highcharts

时间:2011-08-10 17:02:12

标签: highcharts

嗨,我是highcharts和zend的新手。我在我的zend视图中安装了highcharts,并能够绘制带有一些虚拟数据的图表。现在我想用我的数据库中的数据创建一个图表。我的数据包含用户的体重和体重测量的日期。

    x axis will be the weight of the user
    y axis will be the date of weight measurement  

我已准备好数据库,但我不知道如何从我的数据库中的数据创建图表。 谢谢。

2 个答案:

答案 0 :(得分:3)

通常x轴用于时间值,但您可以通过将inverted属性设置为true来反转图表,以交换x轴和y轴的位置(基本上使时间轴垂直)而不是横向的):

chart: {
    renderTo: 'container',
    type: 'spline',
    inverted: true   // <== inverted chart
},

xAxis: {
    type: 'datetime',
},

series: [{
    data: [[Date.UTC(2011, 0, 1), 69.9],
          [Date.UTC(2011, 0, 2), 71.5],
          [Date.UTC(2011, 0, 3), 76.4],
          [Date.UTC(2011, 0, 4), 81.5],
          [Date.UTC(2011, 0, 5), 80.4]]
}]

我在jsfiddle上为你做了一个例子,显示了这个:http://jsfiddle.net/emWm7/

参考文档:http://www.highcharts.com/ref/index.php#chart--inverted

答案 1 :(得分:-1)

我有两个可以使用的代码示例。一种是从表中生成制表符分隔值。另一个是从表中生成JSON字符串。

以制表符分隔的值示例here

JSON示例here

相关问题