diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a6b8dc8 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include MANIFEST.in +include LICENSE + +graft tests + +global-exclude *.py[co] diff --git a/examples/highcharts/heatmap.py b/examples/highcharts/heatmap.py new file mode 100644 index 0000000..338134b --- /dev/null +++ b/examples/highcharts/heatmap.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +""" +Highcharts Demos +Heatmap: http://www.highcharts.com/demo/heatmap +""" +from highcharts import Highchart +H = Highchart() + +data = [ + [0, 0, 10], + [0, 1, 19], + [0, 2, 8], + [0, 3, 24], + [0, 4, 67], + [1, 0, 92], + [1, 1, 58], + [1, 2, 78], + [1, 3, 117], + [1, 4, 48], + [2, 0, 35], + [2, 1, 15], + [2, 2, 123], + [2, 3, 64], + [2, 4, 52], + [3, 0, 72], + [3, 1, 132], + [3, 2, 114], + [3, 3, 19], + [3, 4, 16], + [4, 0, 38], + [4, 1, 5], + [4, 2, 8], + [4, 3, 117], + [4, 4, 115], + [5, 0, 88], + [5, 1, 32], + [5, 2, 12], + [5, 3, 6], + [5, 4, 120], + [6, 0, 13], + [6, 1, 44], + [6, 2, 88], + [6, 3, 98], + [6, 4, 96], + [7, 0, 31], + [7, 1, 1], + [7, 2, 82], + [7, 3, 32], + [7, 4, 30], + [8, 0, 85], + [8, 1, 97], + [8, 2, 123], + [8, 3, 64], + [8, 4, 84], + [9, 0, 47], + [9, 1, 114], + [9, 2, 31], + [9, 3, 48], + [9, 4, 91] +] + +H.add_data_set(data, ) + +H.set_options('chart', { + 'type': 'heatmap', + 'marginTop': 40, + 'marginBottom': 80, + 'plotBorderWidth': 1 +}) + +H.set_options('xAxis', { + 'categories': + ['Alexander', 'Marie', 'Maximilian', 'Sophia', 'Lukas', 'Maria', 'Leon', 'Anna', 'Tim', 'Laura'] +}) + +H.set_options('yAxis', { + 'categories': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], + 'title': None +}) + +H.set_options('title', { + 'text': "Sales per employee per weekday" +}) + +H.set_options('colorAxis', { + 'min': 0, + 'minColor': '#FFFFFF', + 'maxColor': '#7CB5EC' +}) + +H.set_options('legend', { + 'align': 'right', + 'layout': 'vertical', + 'margin': 0, + 'verticalAlign': 'top', + 'y': 25, + 'symbolHeight': 280 +}) + +H.set_options('tooltip', { + 'formatter': "function () {" + + "return '' + this.series.xAxis.categories[this.point.x] + ' sold
' +" + + "this.point.value + ' items on
' + this.series.yAxis.categories[this.point.y] + '';" + + "}" +}) + +H.htmlcontent \ No newline at end of file diff --git a/examples/ipynb/highcharts/heatmap.ipynb b/examples/ipynb/highcharts/heatmap.ipynb new file mode 100644 index 0000000..9fd0880 --- /dev/null +++ b/examples/ipynb/highcharts/heatmap.ipynb @@ -0,0 +1,159 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# -*- coding: utf-8 -*-\n", + "\"\"\"\n", + "Highcharts Demos\n", + "Heatmap: http://www.highcharts.com/demo/heatmap\n", + "\"\"\"\n", + "from highcharts import Highchart\n", + "H = Highchart()\n", + "\n", + "data = [\n", + " [0, 0, 10],\n", + " [0, 1, 19],\n", + " [0, 2, 8],\n", + " [0, 3, 24],\n", + " [0, 4, 67],\n", + " [1, 0, 92],\n", + " [1, 1, 58],\n", + " [1, 2, 78],\n", + " [1, 3, 117],\n", + " [1, 4, 48],\n", + " [2, 0, 35],\n", + " [2, 1, 15],\n", + " [2, 2, 123],\n", + " [2, 3, 64],\n", + " [2, 4, 52],\n", + " [3, 0, 72],\n", + " [3, 1, 132],\n", + " [3, 2, 114],\n", + " [3, 3, 19],\n", + " [3, 4, 16],\n", + " [4, 0, 38],\n", + " [4, 1, 5],\n", + " [4, 2, 8],\n", + " [4, 3, 117],\n", + " [4, 4, 115],\n", + " [5, 0, 88],\n", + " [5, 1, 32],\n", + " [5, 2, 12],\n", + " [5, 3, 6],\n", + " [5, 4, 120],\n", + " [6, 0, 13],\n", + " [6, 1, 44],\n", + " [6, 2, 88],\n", + " [6, 3, 98],\n", + " [6, 4, 96],\n", + " [7, 0, 31],\n", + " [7, 1, 1],\n", + " [7, 2, 82],\n", + " [7, 3, 32],\n", + " [7, 4, 30],\n", + " [8, 0, 85],\n", + " [8, 1, 97],\n", + " [8, 2, 123],\n", + " [8, 3, 64],\n", + " [8, 4, 84],\n", + " [9, 0, 47],\n", + " [9, 1, 114],\n", + " [9, 2, 31],\n", + " [9, 3, 48],\n", + " [9, 4, 91]\n", + "]\n", + "\n", + "H.add_data_set(data, series_type='heatmap', borderWidth=1, dataLabels={\n", + " 'enabled': True,\n", + " 'color': '#000000'\n", + "})\n", + "\n", + "H.set_options('chart', {\n", + " 'type': 'heatmap',\n", + " 'marginTop': 40,\n", + " 'marginBottom': 80,\n", + " 'plotBorderWidth': 1\n", + "})\n", + "\n", + "H.set_options('xAxis', {\n", + " 'categories': \n", + " ['Alexander', 'Marie', 'Maximilian', 'Sophia', 'Lukas', 'Maria', 'Leon', 'Anna', 'Tim', 'Laura']\n", + "})\n", + "\n", + "H.set_options('yAxis', {\n", + " 'categories': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],\n", + " 'title': None\n", + "})\n", + "\n", + "H.set_options('title', {\n", + " 'text': \"Sales per employee per weekday\"\n", + "})\n", + "\n", + "H.set_options('colorAxis', {\n", + " 'min': 0,\n", + " 'minColor': '#FFFFFF',\n", + " 'maxColor': '#7CB5EC'\n", + "})\n", + "\n", + "H.set_options('legend', {\n", + " 'align': 'right',\n", + " 'layout': 'vertical',\n", + " 'margin': 0,\n", + " 'verticalAlign': 'top',\n", + " 'y': 25,\n", + " 'symbolHeight': 280\n", + "})\n", + "\n", + "H.set_options('tooltip', {\n", + " 'formatter': \"function () {\" + \n", + " \"return '' + this.series.xAxis.categories[this.point.x] + ' sold
' +\" +\n", + " \"this.point.value + ' items on
' + this.series.yAxis.categories[this.point.y] + '';\" +\n", + " \"}\"\n", + "})\n", + "\n", + "H" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.1" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/highcharts/highcharts/highchart_types.py b/highcharts/highcharts/highchart_types.py index 09817af..4a255b1 100644 --- a/highcharts/highcharts/highchart_types.py +++ b/highcharts/highcharts/highchart_types.py @@ -479,6 +479,7 @@ "selected": bool, "sliced": bool, "showInLegend": bool, + "stack": basestring, "type": basestring, "visible": bool, "x": [int, float], @@ -617,7 +618,7 @@ def __getattr__(self,item): class Series(object): """Series class for input data """ - def __init__(self,data,series_type="line",supress_errors=False,**kwargs): + def __init__(self, data, series_type="line", supress_errors=False, **kwargs): # List of dictionaries. Each dict contains data and properties, # which need to handle before construct the object for series diff --git a/highcharts/highstock/options.py b/highcharts/highstock/options.py index 18fa235..7b47e2a 100644 --- a/highcharts/highstock/options.py +++ b/highcharts/highstock/options.py @@ -301,6 +301,7 @@ class PlotOptions(BaseOptions): "arearange": (SeriesOptions, dict), "areaspline": (SeriesOptions, dict), "areasplinerange": (SeriesOptions, dict), + "candlestick": (SeriesOptions, dict), "column": (SeriesOptions, dict), "columnrange": (SeriesOptions, dict), "flags": (SeriesOptions, dict), diff --git a/tests/test_highcharts.py b/tests/test_highcharts.py index 6d6628c..a3882e6 100644 --- a/tests/test_highcharts.py +++ b/tests/test_highcharts.py @@ -56,6 +56,9 @@ def test_Example1(self): execfile(os.path.join(self.PATH_ROOT, 'Example1.py')) os.remove("highcharts.html") + def test_error_bar(self): + execfile(os.path.join(self.PATH_ROOT, 'heatmap.py')) + def test_line_time_series(self): execfile(os.path.join(self.PATH_ROOT, 'line-time-series.py')) @@ -82,4 +85,4 @@ def test_spline_symbols(self): def test_treemap_levels(self): execfile(os.path.join(self.PATH_ROOT, 'treemap-levels.py')) - \ No newline at end of file +