首页 > 解决方案 > 使用 Highcharts 使用 Mysql DB 通过 PhP 的数据创建风玫瑰

问题描述

我已将气象数据存储在 MySQL 数据库中;我想使用风表检索和显示风数据。查看 Highcharts (windrose) 的示例,我注意到数据需要按基本方向组织(每个风向都是一个查询)。所以我创建了一个查询,准确地提供风向的频率,如下所示:

速度航向频率

0-5 N 154

10-15 N 81

15-20 N 91

20-30 牛 35

30-40 牛 1

5-10 牛 100

0 北东 1

0-5 NNE 295

10-15 NNE 48

15-20 NNE 18

20-30 NNE 6

5-10 NNE 86

0 东北 1 … …</p>

0-5 西北偏北 86

10-15 NNW 96

15-20 西北 55

20-30 NNW 11

5-10 NNW 89

您对如何在下面的示例中用 sql 查询替换数据数组有任何建议或示例吗?下面是 Highcharts 上可用示例的摘录频率是硬编码的,所以没关系。数据部分应读取查询。任何帮助都非常受欢迎,在此先感谢 Giancarlo


<script src="../../code/highcharts.js"></script>
<script src="../../code/highcharts-more.js"></script>
<script src="../../code/modules/data.js"></script>
<script src="../../code/modules/exporting.js"></script>
<script src="../../code/modules/export-data.js"></script>
<div id="container"></div>
<div style="display:none">
    <!-- Source: http://or.water.usgs.gov/cgi-bin/grapher/graph_windrose.pl -->
    <table id="freq" border="0" cellspacing="0" cellpadding="0">
        <tr nowrap bgcolor="#CCCCFF">
            <th colspan="9" class="hdr">Table of Frequencies (percent)</th>
        </tr>
        <tr nowrap bgcolor="#CCCCFF">
            <th class="freq">Direction</th>
            <th class="freq">&lt; 0.5 m/s</th>
            <th class="freq">0.5-2 m/s</th>
            <th class="freq">2-4 m/s</th>
            <th class="freq">4-6 m/s</th>
            <th class="freq">6-8 m/s</th>
            <th class="freq">8-10 m/s</th>
            <th class="freq">&gt; 10 m/s</th>
            <th class="freq">Total</th>
        </tr>
        <tr nowrap>
            <td class="dir">N</td>
            <td class="data">1.81</td>
            <td class="data">1.78</td>
            <td class="data">0.16</td>
            <td class="data">0.00</td>
            <td class="data">0.00</td>
            <td class="data">0.00</td>
            <td class="data">0.00</td>
            <td class="data">3.75</td>
        </tr>```

标签: javascriptphpmysqldatabasehighcharts

解决方案


推荐阅读