HighCharts 圖表外掛程式 自訂綁定 時間軸資料

來源:互聯網
上載者:User

HighCharts 圖表外掛程式 自訂綁定 時間軸資料     HighCharts 圖表外掛程式 自訂綁定 時間軸資料,解決時間軸自動顯示資料與實際綁定資料時間不對應問題!     學習樣本如下:

<!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>    <title>喊單收益曲線圖</title>    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />    <script src="jquery-1.4.2.min.js" type="text/javascript"></script>    <script src="highcharts.js" type="text/javascript"></script>    <script src="exporting.js" type="text/javascript"></script></head><body style="margin: auto;">    <!-- 喊單收益曲線圖 -->    <div id="container" style="width: 100%; height: 100%; margin: 0 auto">    </div></body></html><script type="text/javascript" language="javascript">    /*    * 官方文檔: http://www.highcharts.me/    */    var chart, myTime = "", myData = "";    $(function () {        //盈利率        myData = "[-20.25,-12.30,-3.68,5.45,19.00,-2.78,-5.45,9.80,10.45,16.15]";        options.series[0].data = eval(myData);        //時間        myTime = "['2014-03-01 01:10','2014-03-01 01:30','2014-03-01 01:45','2014-03-01 02:30','2014-03-01 02:45','2014-03-01 03:00','2014-03-01 03:40','2014-03-01 04:50','2014-03-01 05:05','2014-03-01 06:06']";        options.xAxis.categories = eval(myTime);        //載入圖表        chart = new Highcharts.Chart(options);    });    var options = {        chart: {            renderTo: 'container',            zoomType: 'x'        },        title: {            text: '喊單收益曲線圖'        },        subtitle: {            text: '點擊並拖動繪圖區域的放大'        },        xAxis: {            title: {                text: null            },            labels: {                formatter: function () {                    return this.value;                }            }        },        yAxis: {            title: {                text: '盈利率'            },            labels: {                formatter: function () {                    return this.value + "%";                }            },            startOnTick: false,            showFirstLabel: false        },        tooltip: {            formatter: function () {                return '' + '日期:' + this.x                          + '<br/>盈利率:' + Highcharts.numberFormat(this.y, 2) + "%";            }        },        legend: {            enabled: false        },        plotOptions: {            area: {                fillColor: {                    linearGradient: [0, 0, 0, 300],                    stops: [[0, '#4572A7'],    [1, 'rgba(2,0,0,0)']   ]                },                lineWidth: 1,                marker: {                    enabled: false,                    states: {                        hover: {                            enabled: true,                            radius: 5                        }                    }                },                shadow: false,                states: {                    hover: {                        lineWidth: 1                    }                }            }        },        series: [{            type: 'area',            name: '盈利率'        }]    }</script>
   如下:   

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.