{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Highstock Demos\n",
"=========\n",
"1.7 million points with async loading: http://www.highcharts.com/stock/demo/lazy-loading\n",
"------------------------------------------------------------------------------------\n",
"\n",
"This example generates a candlestick chart, which updates (async loading) when a different time period is selected\n",
"by the navigation bar due to the large dataset.\n",
"\n",
"Due to the update, this chart requires JS function in the beginning and xAxis.events options."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from highcharts import Highstock\n",
"H = Highstock()\n",
"\n",
"data_url = 'http://www.highcharts.com/samples/data/from-sql.php?callback=?'\n",
"H.add_data_from_jsonp(data_url, 'json_data', 'candlestick', dataGrouping = {'enabled': False})\n",
"\n",
"script = \"\"\"json_data = [].concat(json_data, [[Date.UTC(2011, 9, 14, 19, 59), null, null, null, null]]);\"\"\"\n",
"H.add_JSscript(script, 'head')\n",
"\n",
"H.add_navi_series_from_jsonp() # not really useful, but it shows in highstock demo\n",
"\n",
"options = {\n",
" 'chart' : {\n",
" 'zoomType': 'x'\n",
" },\n",
"\n",
" 'navigator' : {\n",
" 'adaptToUpdatedData': False,\n",
" },\n",
"\n",
" 'scrollbar': {\n",
" 'liveRedraw': False\n",
" },\n",
"\n",
" 'title': {\n",
" 'text': 'AAPL history by the minute from 1998 to 2011'\n",
" },\n",
"\n",
" 'subtitle': {\n",
" 'text': 'Displaying 1.7 million data points in Highcharts Stock by async server loading'\n",
" },\n",
"\n",
" 'rangeSelector' : {\n",
" 'buttons': [{\n",
" 'type': 'hour',\n",
" 'count': 1,\n",
" 'text': '1h'\n",
" }, {\n",
" 'type': 'day',\n",
" 'count': 1,\n",
" 'text': '1d'\n",
" }, {\n",
" 'type': 'month',\n",
" 'count': 1,\n",
" 'text': '1m'\n",
" }, {\n",
" 'type': 'year',\n",
" 'count': 1,\n",
" 'text': '1y'\n",
" }, {\n",
" 'type': 'all',\n",
" 'text': 'All'\n",
" }],\n",
" 'inputEnabled': False, # it supports only days\n",
" 'selected' : 4 # all\n",
" },\n",
"\n",
" 'xAxis' : {\n",
" 'events' : {\n",
" 'afterSetExtremes' : \"\"\"function afterSetExtremes(e) {\n",
"\n",
" var chart = $('#container').highcharts();\n",
"\n",
" chart.showLoading('Loading data from server...');\n",
" $.getJSON('http://www.highcharts.com/samples/data/from-sql.php?start=' + Math.round(e.min) +\n",
" '&end=' + Math.round(e.max) + '&callback=?', function (data) {\n",
"\n",
" chart.series[0].setData(data);\n",
" chart.hideLoading();\n",
" });\n",
" }\"\"\"\n",
" },\n",
" 'minRange': 3600 * 1000 # one hour\n",
" },\n",
"\n",
" 'yAxis': {\n",
" 'floor': 0\n",
" },\n",
"\n",
"}\n",
"\n",
"H.set_dict_options(options)\n",
"\n",
"H"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}