In [1]:
%load_ext autoreload
%autoreload 2

import os
import ezhc as hc



In [2]:
%version_information ipython, ezhc


Out[2]:
SoftwareVersion
Python3.6.3 64bit [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
IPython6.2.1
OSDarwin 16.7.0 x86_64 i386 64bit
ipython6.2.1
ezhc0.7.0
Tue Jan 02 11:12:23 2018 CET

Themes

  • Directly available in ezhc

In [3]:
th = hc.Theme()
th.info()


Out[3]:

Theme contains predtermined Highcharts themes available as properties

['avocado', 'dark-blue', 'dark-green', 'dark-unica', 'gray', 'grid-light', 'grid', 'sand-signika', 'skies', 'sunset']

Global Options

  • Can be accessed through the GlobalOptions class
  • See the Highcharts documentation to see which options are available
  • To suppress the output of inject() set verbose=False

In [4]:
hc_global = hc.GlobalOptions({'lang': {'decimalPoint': '.', 'thousandsSep': ','}})
hc_global.inject(verbose=True)


Highcharts global options set in this cell:

{"lang":{"decimalPoint":".","thousandsSep":","}}

Themes as global options

  • As described in the documentation it can be convenient to separate the styling of charts from the data
  • This can be done through the GlobalOptions class as show here

In [5]:
hc_global = hc.GlobalOptions(th.themes['dark-unica'])
hc_global.inject(verbose=True)


Highcharts global options set in this cell:

{"colors":["#2b908f","#90ee7e","#f45b5b","#7798BF","#aaeeee","#ff0066","#eeaaee","#55BF3B","#DF5353","#7798BF","#aaeeee"],"chart":{"backgroundColor":{"linearGradient":{"x1":0,"y1":0,"x2":1,"y2":1},"stops":[[0,"#2a2a2b"],[1,"#3e3e40"]]},"style":{"fontFamily":"'Unica One', sans-serif"},"plotBorderColor":"#606063"},"title":{"style":{"color":"#E0E0E3","textTransform":"uppercase","fontSize":"20px"}},"subtitle":{"style":{"color":"#E0E0E3","textTransform":"uppercase"}},"xAxis":{"gridLineColor":"#707073","labels":{"style":{"color":"#E0E0E3"}},"lineColor":"#707073","minorGridLineColor":"#505053","tickColor":"#707073","title":{"style":{"color":"#A0A0A3"}}},"yAxis":{"gridLineColor":"#707073","labels":{"style":{"color":"#E0E0E3"}},"lineColor":"#707073","minorGridLineColor":"#505053","tickColor":"#707073","tickWidth":1,"title":{"style":{"color":"#A0A0A3"}}},"tooltip":{"backgroundColor":"rgba(0, 0, 0, 0.85)","style":{"color":"#F0F0F0"}},"plotOptions":{"series":{"dataLabels":{"color":"#B0B0B3"},"marker":{"lineColor":"#333"}},"boxplot":{"fillColor":"#505053"},"candlestick":{"lineColor":"white"},"errorbar":{"color":"white"}},"legend":{"itemStyle":{"color":"#E0E0E3"},"itemHoverStyle":{"color":"#FFF"},"itemHiddenStyle":{"color":"#606063"}},"credits":{"style":{"color":"#666"}},"labels":{"style":{"color":"#707073"}},"drilldown":{"activeAxisLabelStyle":{"color":"#F0F0F3"},"activeDataLabelStyle":{"color":"#F0F0F3"}},"navigation":{"buttonOptions":{"symbolStroke":"#DDDDDD","theme":{"fill":"#505053"}}},"rangeSelector":{"buttonTheme":{"fill":"#505053","stroke":"#000000","style":{"color":"#CCC"},"states":{"hover":{"fill":"#707073","stroke":"#000000","style":{"color":"white"}},"select":{"fill":"#000003","stroke":"#000000","style":{"color":"white"}}}},"inputBoxBorderColor":"#505053","inputStyle":{"backgroundColor":"#333","color":"silver"},"labelStyle":{"color":"silver"}},"navigator":{"handles":{"backgroundColor":"#666","borderColor":"#AAA"},"outlineColor":"#CCC","maskFill":"rgba(255,255,255,0.1)","series":{"color":"#7798BF","lineColor":"#A6C7ED"},"xAxis":{"gridLineColor":"#505053"}},"scrollbar":{"barBackgroundColor":"#808083","barBorderColor":"#808083","buttonArrowColor":"#CCC","buttonBackgroundColor":"#606063","buttonBorderColor":"#606063","rifleColor":"#FFF","trackBackgroundColor":"#404043","trackBorderColor":"#404043"},"legendBackgroundColor":"rgba(0, 0, 0, 0.5)","background2":"#505053","dataLabelsColor":"#B0B0B3","textColor":"#C0C0C0","contrastTextColor":"#F0F0F3","maskColor":"rgba(255,255,255,0.3)"}

In [6]:
g = hc.Highcharts()
g.title.text = 'Solar Employment Growth by Sector, 2010-2016'
g.subtitle.text = 'Source: thesolarfoundation.com'
g.yAxis.title.text = 'Number of Employees'
g.legend = {'layout': 'vertical', 'align': 'right', 'verticalAlign': 'middle'}
g.exporting = False
g.chart.width = '800'

g.plotOptions.series = {'label': {'connectorAllowed': False}, 'pointStart': 2010}
g.series = [{'name': 'Installation', 'data': [43934.3, 52503.1, 57177.2, 69658.8, 97031.9, 119931, 137133.5, 154175.6]},
            {'name': 'Manufacturing', 'data': [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]},
            {'name': 'Sales & Distribution', 'data': [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387]},
            {'name': 'Project Development', 'data': [None, None, 7988, 12169, 15112, 22452, 34400, 34227]},
            {'name': 'Other', 'data': [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]}
           ]
g.plot()


Out[6]:

In [7]:
hc_global.reset(verbose=True)


Highcharts global options reset to default.


In [ ]: