def create_chart(): chart = Highchart() options = { 'title': { 'text': 'Loss over time for various models' }, 'xAxis': { 'title': { 'text': 'Number of images' }, 'maxPadding': 0.05, 'showLastLabel': True }, 'yAxis': { 'title': { 'text': 'Loss' }, 'lineWidth': 2 }, 'legend': { 'enabled': True, 'layout': 'vertical', 'align': 'left', 'verticalAlign': 'middle' }, 'tooltip': { 'headerFormat': '<b>{series.name}</b><br/>', 'pointFormat': '{point.x} images: Loss = {point.y}' } } chart.set_dict_options(options) return chart
def timeline_python_highcharts(): """Return filename of plot of the damped_vibration function.""" H = Highchart() timeline_data = pd.read_csv('timeline.txt') options = { 'chart': { 'type': 'columnrange', 'inverted': True, 'zoomType': 'y' }, 'title': { 'text': 'BepiTimeline Test' }, 'xAxis': { 'categories': list(set(timeline_data['Instrument'].values.tolist())) }, 'yAxis': { 'type': 'datetime' }, 'tooltip': { 'formatter': "function () {return Highcharts.dateFormat('%e %B %H:%M', this.point.low) + ' - ' + Highcharts.dateFormat('%e %B %H:%M', this.point.high);}" }, 'plotOptions': { 'columnrange': { 'grouping': False } } } H.set_dict_options(options) grouped = timeline_data.groupby('Instrument') grouped = [grouped.get_group(x) for x in grouped.groups] for level, frame in enumerate(grouped): df = {} df['name'] = frame['Instrument'].values[0] df['data'] = [] for row in frame.itertuples(): block = {} block['x'] = level st = dt.strptime(row[2], '%Y-%m-%d %H:%M') st = int((st-dt(1970,1,1)).total_seconds()*1000) en = dt.strptime(row[3], '%Y-%m-%d %H:%M') en = int((en-dt(1970,1,1)).total_seconds()*1000) block['low'] = st block['high'] = en df['data'].append(block) H.add_data_set(df['data'], 'columnrange', df['name'] ) print(H.iframe) return 0
def __init__(self, **kwargs): self.q_df = kwargs["question_dataframe"] self.tag = kwargs["question_tag"] self.levels = kwargs["target_levels"] self.study_groups_definition = kwargs["study_groups_definition"] self.chart = Highchart() chart_options = kwargs["chart_options"] if isinstance(chart_options, DeepChainMap): chart_options = chart_options.to_dict() self.chart.set_dict_options(chart_options) self.chart_definition = None # calculated by _chart method
def create_highcharts(device_name, results): categories = [] ssid_categories = results[3] for pair in ssid_categories: categories.append(pair[1]) chart = Highchart(width=1000, height=400) styling = '<span style="font-family: \'DejaVu Sans\', Arial, Helvetica, sans-serif; color: ' options = { 'title': { 'text': styling + '#00AEEF; font-size: 20px; line-height: 1.2640625; ">' + 'Wi-Fi Performance ' + device_name + '</span>' }, 'chart': { 'zoomType': 'x' }, 'xAxis': { 'type': 'datetime', 'title': { 'text': styling + '#F7941C; font-size: 12px; line-height: 1.4640625; font-weight: bold;">Time [h:min:s]</span>' } }, 'yAxis': [{ 'title': { 'text': styling + '#00AEEF; font-size: 12px; line-height: 1.2640625; font-weight: bold; ">Throughput [bps]</span>' }, }, { 'title': { 'text': styling + '#EC008C; font-size: 12px; line-height: 1.2640625; font-weight: bold; ">RSSI</span>' }, 'opposite': 'true' }, { 'title': { 'text': styling + '#00A650; font-size: 12px; line-height: 1.2640625; font-weight: bold; ">SSID/BSSID</span>' }, 'categories': categories, 'opposite': 'true' }], } chart.set_dict_options(options) return chart
def create_line_chart(categories, values, title, filename, charttype, orientation, axisreverse, stack): chart = Highchart() options = { 'chart': { 'type': charttype }, 'title': { 'text': title }, 'xAxis': { 'categories': categories, 'labels': { 'rotation': 45 } }, 'yAxis': { 'title': { 'text': '#Cases' }, 'stackLabels': { 'enabled': False, 'verticalAlign': 'top', 'y': 100 } }, 'plotOptions': { 'series': { 'dataLabels': { 'enabled': True }, 'stacking': 'normal' } }, 'legend': { 'enabled': True }, 'tooltip': { 'enabled': True, 'shared': True, 'formatter': "function(){ var s = '<b>'+ this.x +'</b>'; var s1=''; var sum = 0; $.each(this.points, function(i, point) { s1 += '<br/><b>'+ point.series.name +'</b>: '+ point.y ; sum += point.y; }); s += '<br/><b>Total</b>: '+sum ; return s+s1;}" } } chart.set_dict_options(options) print(options) colors = ['#1A5276', '#6E2C00', '#2C3E50', '#45B39D'] keys = list(values.keys()) for series in keys: data = values[series] chart.add_data_set(data, charttype, series, marker={'enabled': True}, color=colors[keys.index(series)]) print(filename) chart.save_file(filename)
def make_chart_daily_max_long_short(stats): chart = Highchart() options = { 'chart': { 'zoomType': 'x' }, 'title': { 'text': 'Max Long/Short intra day' }, 'xAxis': { 'type': 'datetime' }, 'yAxis': { 'title': { 'text': '$' } }, 'legend': { 'enabled': False } } chart.set_dict_options(options) timestamps = stats.index.astype(np.int64) // 1000000 long_data = np.dstack((timestamps, stats["max_long"].values))[0].tolist() chart.add_data_set(long_data, 'column', 'Max Long') short_data = np.dstack( (timestamps, -stats["max_short"].values))[0].tolist() chart.add_data_set(short_data, 'column', 'Max Short') return chart
def generateCharts(currentWeek, students, names, averageRank, averageToken): if not os.path.exists(chart_folder): os.makedirs(chart_folder) raw_options['chart']['height'] = 500 options = copy.deepcopy(raw_options) options['yAxis'] = [{ 'min' : -1, 'max' : 1, 'reversed': True, 'title': { 'text': 'Normalized Rank' }, 'labels': { 'formatter': "function () {\ return this.value;\ }" }, 'lineWidth': 2 }, { 'reversed': True, 'title': { 'text': 'Normalized Token' }, 'labels': { 'formatter': "function () {\ return this.value;\ }" }, 'lineWidth': 2, 'opposite': True }, ] options['xAxis']['title']['text'] = 'Week' for student in students: if not student.is_active: continue chart = Highchart() options['title']['text'] = names[student.user_name] options['chart']['renderTo'] = 'container_' + student.user_name chart.set_dict_options(options) rank_data = [] token_data = [] for week in range(1, currentWeek + 1): rank = averageRank[week-1].get(student.user_name) token = averageToken[week-1].get(student.user_name) if rank is not None and token is not None: point = [week, rank] rank_data.append(point) point = [week, token] token_data.append(point) chart.add_data_set(rank_data, 'spline', 'Normalized Rank', marker={'enabled': True}) chart.add_data_set(token_data, 'spline', 'Normalized Token', marker={'enabled': True}, yAxis=1) chart.save_file(chart_folder + student.user_name)
def compareChart(currentWeek, students, names, averageRank): if not os.path.exists(chart_folder): os.makedirs(chart_folder) raw_options['chart']['height'] = 800 options = copy.deepcopy(raw_options) options['title']['text'] = 'Normalized Rank Comparison Chart' options['yAxis']['title']['text'] = 'Normalized Rank' options['xAxis']['title']['text'] = 'Week' chart = Highchart() chart.set_dict_options(options) series = [] for student in students: if not student.is_active: continue name = names[student.user_name] data = [] for week in range(1, currentWeek + 1): rank = averageRank[week-1].get(student.user_name) if rank is not None: point = [week, rank] data.append(point) series.append({'name': name, 'data': data}) chart.add_data_set(data, 'spline', name, marker={'enabled': True}) #options['series'] = series chart.save_file(chart_folder + 'compare')
def make_chart_daily_exposure(stats): chart = Highchart() options = { 'chart': { 'zoomType': 'x' }, 'title': { 'text': 'End of day exposure' }, 'xAxis': { 'type': 'datetime' }, 'yAxis': { 'title': { 'text': 'Exposure' } }, 'legend': { 'enabled': False } } chart.set_dict_options(options) timestamps = stats.index.astype(np.int64) // 1000000 plot_data = np.dstack( (timestamps, stats["day_end_exposure"].values))[0].tolist() chart.add_data_set(plot_data, 'area', 'Exposure') return chart
def make_chart_realized_pnl(stats): chart = Highchart() options = { 'chart': { 'zoomType': 'x' }, 'title': { 'text': 'Realized Cumulative Profit and Loss' }, 'xAxis': { 'type': 'datetime' }, 'yAxis': { 'title': { 'text': 'Realized P/L' } }, 'legend': { 'enabled': False } } chart.set_dict_options(options) timestamps = stats.index.astype(np.int64) // 1000000 plot_data = np.dstack( (timestamps, stats["realized_pnl"].values))[0].tolist() chart.add_data_set(plot_data, 'line', 'PnL') return chart
def make_chart_max_drawdown(stats): chart = Highchart() options = { 'chart': { 'zoomType': 'x' }, 'title': { 'text': 'Max Drawdown' }, 'xAxis': { 'type': 'datetime' }, 'yAxis': { 'title': { 'text': 'Daily P/L' } }, 'legend': { 'enabled': False } } chart.set_dict_options(options) timestamps = stats.index.astype(np.int64) // 1000000 plot_data = np.dstack( (timestamps, stats["max_drawdown"].values))[0].tolist() chart.add_data_set(plot_data, 'column', 'Max Drawdown') return chart
class QuestionChart: available_series_colours = copy.copy(THISCOVERY_SERIES_COLOURS) study_group_colour_map = dict() def __init__(self, **kwargs): self.q_df = kwargs["question_dataframe"] self.tag = kwargs["question_tag"] self.levels = kwargs["target_levels"] self.study_groups_definition = kwargs["study_groups_definition"] self.chart = Highchart() chart_options = kwargs["chart_options"] if isinstance(chart_options, DeepChainMap): chart_options = chart_options.to_dict() self.chart.set_dict_options(chart_options) self.chart_definition = None # calculated by _chart method def add_index_column(self): self.q_df.insert(loc=0, column=self.tag, value=self.q_df.index) def python_highcharts_hacks(self, chart_definition): """ Hacks to overcome current limitations of python-highcharts """ # interpret JS undefined as such chart_definition = chart_definition.replace('"undefined"', "undefined") # remove quotes from JS functions (so they are not strings) # this is only necessary because python-highcharts has no # support for the responsive option at present function_re = re.compile(r'"function \(\).+;}"') if (m := function_re.search(chart_definition)): chart_definition = chart_definition.replace( m.group(), m.group().strip('"')) return chart_definition
def renderChart(stats, bottom, left="Workflow Job"): keys = [k for k, _ in stats.items()] values = [v for _, v in stats.items()] chart = Highchart() chart.set_options("chart", {"inverted": True}) options = { "title": { "text": "{0} by {1}".format(bottom, left) }, "xAxis": { "categories": keys, "title": { "text": left }, "maxPadding": 0.05, "showLastLabel": True, }, "yAxis": { "title": { "text": bottom }, "labels": { "formatter": "function () {\ return this.value;\ }" }, "lineWidth": 2, }, "legend": { "enabled": False }, "tooltip": { "headerFormat": "<b>{series.name}</b><br/>", "pointFormat": "{point.x} : {point.y}", }, } chart.set_dict_options(options) chart.add_data_set(values, "bar") return str(chart)
def create_graph(self, custom_begin_date, custom_end_date, quantity, time_interval): sensor_node = SensorNode(self.node_id) timestamps = self.get_begin_and_end_timestamps(custom_begin_date, custom_end_date, time_interval) line_graph = Highchart() time_label = '' sensor_node.set_measurements( self.select_measurements(timestamps[0], timestamps[1], quantity)) measurement_types = sensor_node.get_distinct_measurement_types() for m_type in measurement_types: data_list = sensor_node.create_data_list(m_type) line_graph.add_data_set( data_list, series_type='line', name=(sensor_node.get_sensor_description(m_type))) if time_interval == TimeInterval.TODAY or time_interval == TimeInterval.YESTERDAY: time_label = "'hour': '%H:%M'" elif time_interval == TimeInterval.LAST_WEEK: time_label = "'day': '%e. %b'" options = { 'title': { 'text': str(quantity) + " meetdata van bijenkast " + str(sensor_node.node_id) }, 'subtitle': { 'text': "iBee 2017-2018" }, 'xAxis': { 'type': "datetime", 'dateTimeLabelFormats': {time_label}, 'title': { 'text': "Tijd" } }, 'yAxis': { 'title': { 'text': quantity } } } line_graph.set_dict_options(options) return line_graph
def plot_2d(self): h = Highchart(width=750, height=600) options = { 'title': { 'text': 'Value Function Iteration' }, 'xAxis': { 'title': { 'text': "K - Capital Level" } }, 'yAxis': { 'title': { 'text': "Value of Capital" } }, 'tooltip': { 'crosshairs': False, 'shared': True, }, 'legend': {} } h.set_dict_options(options) for x in range(0, len(self.z_vector)): df1 = pd.DataFrame({ 'k': self.k_vector[1:], 'value': self.value_matrix[1:, [x]].flatten() }) df1 = df1[['k', 'value']] df1 = df1.values.tolist() h.add_data_set(df1, 'spline', 'z_' + str(x) + ' = ' + str(self.z_vector[x]), zIndex=1, marker={ 'fillColor': 'white', 'lineWidth': 2, 'lineColor': 'Highcharts.getOptions().colors[1]' }) html_str = h.htmlcontent.encode('utf-8') html_file = open("chart.html", "w") html_file.write(html_str) html_file.close()
def plot_bar_chart_from_pandas_dataframe(df): assert list(df[df.columns[0]]) == list( range(1, len(chart_config.OFIG_X_AXIS_CATEGORIES) + 1)), "Dataframe categories are in the wrong order" assert len(df.index) == len( chart_config.OFIG_X_AXIS_CATEGORIES ), "Dataframe does not contain values for every category" question_export_tag = df.columns[0] chart = Highchart() chart.set_dict_options( chart_config.OfigChartOptions.CHART_OPTIONS.to_dict()) for series_name in df.columns[1:]: data = list(df[series_name]) chart.add_data_set( data, series_type="bar", name=series_name, color=chart_config.THISCOVERY_RED, ) return output_to_files(chart, question_export_tag)
def make_chart_asset_allocation(product_map, account): allocations = list( map(functools.partial(get_position_value, product_map, account), account.get_ids())) capital = account.get_stats().tail(1)['day_end_capital'][0] allocations.append({'name': 'Cash', 'value': capital}) total_allocations = sum(map(lambda x: x['value'], allocations)) allocations_percent = list( map( lambda x: { 'name': x['name'], 'y': x['value'] / total_allocations * 100 }, allocations)) chart = Highchart() options = { 'chart': { 'zoomType': 'x' }, 'title': { 'text': 'Asset allocation' }, 'xAxis': { 'type': 'datetime' }, 'yAxis': { 'title': { 'text': 'Daily P/L' } }, 'legend': { 'enabled': False } } chart.set_dict_options(options) chart.add_data_set(allocations_percent, 'pie', 'Asset allocation') return chart
def cat_page(): # return render_template('cat_page.html') url = 'http://catsgalore.me/api/breeds/' r = requests.get(url) breeds = r.json()['breeds'] data = [br['weight'] for br in breeds] weights = [map(float, tuple(b[1:b.find(')')].split(' to '))) for b in data] chart = Highchart() chart.add_data_set(weights, 'scatter', 'Cat Weights') chart.set_dict_options(options) w = BeautifulSoup(open(BASE_URL + "templates/cat_page.html")) c = BeautifulSoup(str(chart.htmlcontent)) scripts = c.find_all(lambda tag: (tag.has_attr('src') and tag.name == 'script') or tag.name == 'link') chart_script = c.find_all( lambda tag: not tag.has_attr('type') and tag.name == 'script')[0] loading = c.div head = w.head div = w.find_all('div', class_='table-wrapper')[0] div.insert(0, loading) div.insert(1, chart_script) for s in scripts: head.append(s) html = w.prettify("utf-8") with open(BASE_URL + "templates/cats.html", "wb") as f: f.write(html) return render_template("cats.html")
from highcharts import Highchart # A chart is the container that your data will be rendered in, it can (obviously) support multiple data series within it. chart = Highchart() # Adding a series requires at minimum an array of data points. # You can also change the series type, the name, or other series options as kwargs. data = range(1,20) chart.add_data_set(data, series_type='line', name='Example Series') # This will generate and save a .html file at the location you assign chart.save_file()
def plot_grid(molmap, htmlpath='./', htmlname=None): ''' molmap: the object of molmap htmlpath: the figure path ''' if not os.path.exists(htmlpath): os.makedirs(htmlpath) title = 'Assignment of %s by %s emmbedding result' % (molmap.ftype, molmap.method) subtitle = 'number of %s: %s, metric method: %s' % ( molmap.ftype, len(molmap.flist), molmap.metric) name = '%s_%s_%s_%s_%s' % (molmap.ftype, len( molmap.flist), molmap.metric, molmap.method, 'molmap') if htmlname: name = name = htmlname + '_' + name filename = os.path.join(htmlpath, name) print_info('generate file: %s' % filename) m, n = molmap.fmap_shape colormaps = molmap.extract.colormaps position = np.zeros(molmap.fmap_shape, dtype='O').reshape(m * n, ) position[molmap._S.col_asses] = molmap.flist position = position.reshape(m, n) x = [] for i in range(n): x.extend([i] * m) y = list(range(m)) * n v = position.reshape(m * n, order='f') df = pd.DataFrame(list(zip(x, y, v)), columns=['x', 'y', 'v']) bitsinfo = molmap.extract.bitsinfo subtypedict = bitsinfo.set_index('IDs')['Subtypes'].to_dict() subtypedict.update({0: 'NaN'}) df['Subtypes'] = df.v.map(subtypedict) df['colors'] = df['Subtypes'].map(colormaps) H = Highchart(width=1000, height=850) H.set_options('chart', {'type': 'heatmap', 'zoomType': 'xy'}) H.set_options('title', {'text': title}) H.set_options('subtitle', {'text': subtitle}) # H.set_options('xAxis', {'title': '', # 'min': 0, 'max': molmap.fmap_shape[1]-1, # 'allowDecimals':False, # 'labels':{'style':{'fontSize':20}}}) # H.set_options('yAxis', {'title': '', 'tickPosition': 'inside', # 'min': 0, 'max': molmap.fmap_shape[0]-1, # 'reversed': True, # 'allowDecimals':False, # 'labels':{'style':{'fontSize':20}}}) H.set_options( 'xAxis', { 'title': None, 'min': 0, 'max': molmap.fmap_shape[1], 'startOnTick': False, 'endOnTick': False, 'allowDecimals': False, 'labels': { 'style': { 'fontSize': 20 } } }) H.set_options( 'yAxis', { 'title': { 'text': ' ', 'style': { 'fontSize': 20 } }, 'startOnTick': False, 'endOnTick': False, 'gridLineWidth': 0, 'reversed': True, 'min': 0, 'max': molmap.fmap_shape[0], 'allowDecimals': False, 'labels': { 'style': { 'fontSize': 20 } } }) H.set_options( 'legend', { 'align': 'right', 'layout': 'vertical', 'margin': 1, 'verticalAlign': 'top', 'y': 60, 'symbolHeight': 12, 'floating': False, }) H.set_options('tooltip', { 'headerFormat': '<b>{series.name}</b><br>', 'pointFormat': '{point.v}' }) H.set_options('plotOptions', {'series': {'turboThreshold': 5000}}) for subtype, color in colormaps.items(): dfi = df[df['Subtypes'] == subtype] if len(dfi) == 0: continue H.add_data_set( dfi.to_dict('records'), 'heatmap', name=subtype, color=color, #dataLabels = {'enabled': True, 'color': '#000000'} ) H.save_file(filename) print_info('save html file to %s' % filename) return df, H
from highcharts import Highchart results = './results/charts' chart = Highchart() chart.set_options('chart', {'inverted': True}) options = { 'title': { 'text': 'Atmosphere Temperature by Altitude' }, 'subtitle': { 'text': 'According to the Standard Atmosphere Model' }, 'xAxis': { 'reversed': False, 'title': { 'enabled': True, 'text': 'Altitude' }, 'labels': { 'formatter': 'function () {\ return this.value + "km";\ }' }, 'maxPadding': 0.05, 'showLastLabel': True }, 'yAxis': {
#!/usr/bin/python3 from highcharts import Highchart from pymongo import MongoClient import json import pymysql con = MongoClient() db = con['twitterdb'] col = db['tweets'] data = col.find().limit(10) chart = Highchart() def get_data(): c = [] for tweet in data: c.append(tweet['created_at']) #cat.append(tweet['user']['name']) options = { 'chart': { 'type': 'line' }, 'title': { 'text': 'Exploratory Visualization' }, 'legend': { 'enabled': True }, 'xAxis': {
countries = {} for doc in docs: if LANG in doc: lang = doc[LANG] if lang: lang = lang.upper() if lang in langs: langs[lang] += 1 else: langs[lang] = 1 if COUNTRY in doc: country = doc[COUNTRY] if country: if country in countries: countries[country] += 1 else: countries[country] = 1 chart = Highchart() options = {TITLE : {TEXT : 'Results per Language'}} chart.set_dict_options(options) chart.add_data_set(langs.items(), series_type='pie', name='Results') chart.save_file(splitext(argv[2])[0]) chart = Highchart() options = {TITLE : {TEXT : 'Results per Country'}} chart.set_dict_options(options) chart.add_data_set(countries.items(), series_type='pie', name='Results') chart.save_file(splitext(argv[3])[0])
# -*- coding: utf-8 -*- """ Highcharts Demos Pie chart, line and column: http://www.highcharts.com/demo/pie-basic """ import datetime from highcharts import Highchart H = Highchart(width=850, height=400) data = [{ 'name': "Microsoft Internet Explorer", 'y': 56.33 }, { 'name': "Chrome", 'y': 24.03, 'sliced': True, 'selected': True }, { 'name': "Firefox", 'y': 10.38 }, { 'name': "Safari", 'y': 4.77 }, { 'name': "Opera", 'y': 0.91 }, { 'name': "Proprietary or Undetectable", 'y': 0.2 }]
# -*- coding: utf-8 -*- """ Highcharts Demos 3D donut: http://www.highcharts.com/demo/3d-pie-donut """ from highcharts import Highchart H = Highchart(width=550, height=400) options = { 'chart': { 'type': 'pie', 'options3d': { 'enabled': True, 'alpha': 45 } }, 'title': { 'text': "Contents of Highsoft\'s weekly fruit delivery" }, 'subtitle': { 'text': '3D donut in Highcharts' }, 'plotOptions': { 'pie': { 'innerSize': 100, 'depth': 45 } }, }
# -*- coding: utf-8 -*- """ Highcharts Demos Spline with symbols: http://www.highcharts.com/demo/spline-symbols """ from highcharts import Highchart H = Highchart() options = { 'title': { 'text': 'Monthly Average Temperature' }, 'subtitle': { 'text': 'Source: WorldClimate.com' }, 'xAxis': { 'categories': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, 'yAxis': { 'title': { 'text': 'Temperature' }, 'labels': { 'formatter': u'function () {\ return this.value + "°";\ }' } },
# -*- coding: utf-8 -*- """ Highcharts Demos Error bar: http://www.highcharts.com/demo/error-bar """ from highcharts import Highchart H = Highchart(width=550, height=400) options = { 'chart': { 'zoomType': 'xy' }, 'title': { 'text': 'Temperature vs Rainfall' }, 'xAxis': [{ 'categories': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }], 'yAxis': [{ 'labels': { 'format': '{value} °C', 'style': { 'color': 'Highcharts.getOptions().colors[1]' } }, 'title': { 'text': 'Temperature', 'style': { 'color': 'Highcharts.getOptions().colors[1]' }
# -*- coding: utf-8 -*- """ Highcharts Demos Basic area: http://www.highcharts.com/demo/area-basic """ from highcharts import Highchart H = Highchart(width=750, height=600) # the size of chart can be set here options = { 'title': { 'text': 'US and USSR nuclear stockpiles' }, 'subtitle': { 'text': 'Source: <a href="http://thebulletin.metapress.com/content/c4120650912x74k7/fulltext.pdf">' + 'thebulletin.metapress.com</a>' }, 'xAxis': { 'allowDecimals': False, 'labels': { 'formatter': 'function () { \ return this.value; \ }' } }, 'yAxis': { 'title': { 'text': 'Nuclear weapon states' }, 'labels': { 'formatter': "function () { \ return this.value / 1000 + 'k'; \
# -*- coding: utf-8 -*- """ Highcharts Demos Percentage area: http://www.highcharts.com/demo/area-stacked-percent """ from highcharts import Highchart H = Highchart(width=750, height=600) data1 = [502, 635, 809, 947, 1402, 3634, 5268] # data for Asia data2 = [106, 107, 111, 133, 221, 767, 1766] # data for Africa data3 = [163, 203, 276, 408, 547, 729, 628] # data for Europe data4 = [18, 31, 54, 156, 339, 818, 1201] # data for America data5 = [2, 2, 2, 6, 13, 30, 46] # data for Oceania options = { 'title': { 'text': 'Historic and Estimated Worldwide Population Growth by Region' }, 'subtitle': { 'text': 'Source: Wikipedia.org' }, 'xAxis': { 'categories': ['1750', '1800', '1850', '1900', '1950', '1999', '2050'], 'tickmarkPlacement': 'on', 'title': { 'enabled': False } }, 'yAxis': { 'title': {
def hc_basic_line(data, title, subtitle=None, y_axis=None, labels=None, theme=None): H = Highchart() H.set_options("title", { "text": title }) if subtitle: H.set_options("subtitle", { "text": subtitle }) if y_axis: H.set_options("yAxis", { "title": { "text": y_axis } }) H.set_options("legend", { "layout": "vertical", "align": "right", "verticalAlign": "middle" }) # transform the data from a list of rows to a list of columns data_t = list(zip(*data)) # Use the first column as the X axis x_axis = data_t[0] H.set_options("xAxis", { "categories": x_axis, "tickmarkPlacement": "on" }) # And the remaining columns as the graph data if not labels: labels = ["series_%d" % i for i in range(len(data_t)-1)] for label, series in zip(labels, data_t[1:]): H.add_data_set(series, series_type='line', name=label) return hc_plot(H, title, theme)
# -*- coding: utf-8 -*- """ Highcharts Demos Basic bar: http://www.highcharts.com/demo/bar-basic """ from highcharts import Highchart H = Highchart(width=750, height=600) data1 = [107, 31, 635, 203, 2] data2 = [133, 156, 947, 408, 6] data3 = [973, 914, 4054, 732, 34] data4 = [1052, 954, 4250, 740, 38] options = { 'title': { 'text': 'Stacked bar chart' }, 'subtitle': { 'text': 'Source: <a href="https://en.wikipedia.org/wiki/World_population">Wikipedia.org</a>' }, 'xAxis': { 'categories': ['Africa', 'America', 'Asia', 'Europe', 'Oceania'], 'title': { 'text': None } }, 'yAxis': { 'min': 0, 'title': { 'text': 'Population (millions)',
# -*- coding: utf-8 -*- """ Highcharts Demos Scatter plot: http://www.highcharts.com/demo/scatter """ from highcharts import Highchart H = Highchart(width=850, height=400) options = { 'chart': { 'type': 'scatter', 'zoomType': 'xy' }, 'title': { 'text': 'Height Versus Weight of 507 Individuals by Gender' }, 'subtitle': { 'text': 'Source: Heinz 2003' }, 'xAxis': { 'title': { 'enabled': True, 'text': 'Height (cm)' }, 'startOnTick': True, 'endOnTick': True, 'showLastLabel': True }, 'yAxis': { 'title': {
# -*- coding: utf-8 -*- """ Highcharts Demos Bubble chart: http://www.highcharts.com/demo/bubble """ from highcharts import Highchart H = Highchart(width=850, height=400) options = { 'chart': { 'type': 'bubble', 'zoomType': 'xy' }, 'title': { 'text': 'Highcharts Bubbles' }, } data1 = [[97, 36, 79], [94, 74, 60], [68, 76, 58], [64, 87, 56], [68, 27, 73], [74, 99, 42], [7, 93, 87], [51, 69, 40], [38, 23, 33], [57, 86, 31]] data2 = [[25, 10, 87], [2, 75, 59], [11, 54, 8], [86, 55, 93], [5, 3, 58], [90, 63, 44], [91, 33, 17], [97, 3, 56], [15, 67, 48], [54, 25, 81]] data3 = [[47, 47, 21], [20, 12, 4], [6, 76, 91], [38, 30, 60], [57, 98, 64], [61, 17, 80], [83, 60, 13], [67, 78, 75], [64, 12, 10], [30, 77, 82]] H.set_dict_options(options) H.add_data_set(data1, 'bubble') H.add_data_set(data2, 'bubble') H.add_data_set(data3, 'bubble') H.htmlcontent
else: top[hashtag] = 1 data[createdAt] = counts top = sorted(top.items(), key=lambda x: x[1], reverse=True) sortedItems = sorted([item for item in data.items()]) series = {} for i in range(min(int(argv[2]), len(top))): hashtag = top[i][0] dataSet = [] for item in sortedItems: if hashtag in item[1]: dataSet.append(item[1][hashtag]) else: dataSet.append(0) series[hashtag] = dataSet categories = [item[0] for item in sortedItems] chart = Highchart() chart.set_options(TITLE, {TEXT : "Top Trending Topics Over Time"}) chart.set_options(XAXIS, {CATEGORIES : categories}) chart.set_options(YAXIS, {TITLE : {TEXT: "Results containing Hashtag"}}) for item in series.items(): chart.add_data_set(item[1], series_type='line', name=item[0]) chart.save_file(splitext(argv[3])[0])
# -*- coding: utf-8 -*- """ Highcharts Demos Treemap levels: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/treemap-levels/ """ from highcharts import Highchart H = Highchart(width=550, height=400) options = { 'title': { 'text': 'Highcharts Treemap' } } data = [{ 'id': "id_1", 'name': 'A' }, { 'id': "id_2", 'name': 'A1', 'value': 2, 'parent': 'id_1' }, { 'id': "id_3", 'name': 'A2', 'value': 2, 'parent': 'id_1' }, { 'id': "id_4", 'name': 'A3',
# -*- coding: utf-8 -*- """ Highcharts Demos Basic line: http://www.highcharts.com/demo/line-basic """ from highcharts import Highchart H = Highchart() data_Tokyo = [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6] data_NY = [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5] data_Berlin = [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0] data_London = [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] H.add_data_set(data_Tokyo, "line", "Tokyo") H.add_data_set(data_NY, "line", "New York") H.add_data_set(data_Berlin, "line", "Berlin") H.add_data_set(data_London, "line", "London") H.set_options("chart", {"zoomType": "x"}) H.set_options( "xAxis", {"categories": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]} ) H.set_options( "yAxis", {"title": {"text": "Temperature (°C)"}, "plotLines": {"value": 0, "width": 1, "color": "#808080"}} ) H.set_options("tooltip", {"valueSuffix": "°C"}) H.set_options("legend", {"layout": "vertical", "align": "right", "verticalAlign": "middle", "borderWidth": 0}) H.set_options("colors", {})
# -*- coding: utf-8 -*- """ Basic example for python-highcharts All datasets need to input using "add_data_set" method Highchart options can be either set by "set_options" method as showing here or construct a option dictionary object and input using "set_dict_options" method """ from highcharts import Highchart # import highchart library H = Highchart() # setup highchart instance data = list(range(1,20)) data2 = list(range(20,1,-1)) # generate some random datasets """ Each dataset needs to input using add_data_set and add_data_from_jsonp (not recommended) methods 1. add_data_set(data, series_type="line", name=None, **kwargs) 1. data is the dataset for chart 2. series_type (default: "line") is the type of plot this dataset will be presented 3. name is the variable name of dateset(default: Series X) used in python 4. kwargs are for parameters in series or plotOptions (for detail please ref to highcharts API: http://api.highcharts.com/highcharts#) 2. add_data_from_jsonp(data_src, data_name='json_data', series_type="line", name=None, **kwargs) add dataset from the data_src using jsonp. It is converted to jquery function "$.getJSON" in javascript environment 1. data_src is the url (https) for the dataset 2. data_name is the variable name of dataset. This name is used for javascript environment (not in python) 3. series_type( default: "line") is the type of plot this dataset will be presented
# -*- coding: utf-8 -*- """ Highcharts Demos Bar with negative stack: http://www.highcharts.com/demo/bar-negative-stack """ from highcharts import Highchart H = Highchart(width=550, height=400) categories = [ "0-4", "5-9", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40-44", "45-49", "50-54", "55-59", "60-64", "65-69", "70-74", "75-79", "80-84", "85-89", "90-94", "95-99",
# -*- 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],
# -*- coding: utf-8 -*- """ Highcharts Demos Stacked and grouped column: http://www.highcharts.com/demo/column-stacked-and-grouped """ from highcharts import Highchart H = Highchart(width=750, height=600) data1 = [5, 3, 4, 7, 2] data2 = [3, 4, 4, 2, 5] data3 = [2, 5, 6, 2, 1] data4 = [3, 0, 4, 4, 3] options = { 'title': { 'text': 'Total fruit consumtion, grouped by gender' }, 'xAxis': { 'categories': ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] }, 'yAxis': { 'allowDecimals': False, 'min': 0, 'title': { 'text': 'Number of fruits' } }, 'tooltip': { 'formatter': "function () {\
def hchart_json(): chart = Highchart() data = [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8] chart.add_data_set(data, series_type='line', name='Example Series') chart.save_file()
# -*- coding: utf-8 -*- """ Highcharts Demos Time data with irregular intervals: http://www.highcharts.com/demo/spline-irregular-time """ from datetime import datetime from highcharts import Highchart H = Highchart() winter_12_13_data = [ [datetime(1970, 10, 21), 0], [datetime(1970, 11, 4), 0.28], [datetime(1970, 11, 9), 0.25], [datetime(1970, 11, 27), 0.2], [datetime(1970, 12, 2), 0.28], [datetime(1970, 12, 26), 0.28], [datetime(1970, 12, 29), 0.47], [datetime(1971, 1, 11), 0.79], [datetime(1971, 1, 26), 0.72], [datetime(1971, 2, 3), 1.02], [datetime(1971, 2, 11), 1.12], [datetime(1971, 2, 25), 1.2], [datetime(1971, 3, 11), 1.18], [datetime(1971, 4, 11), 1.19], [datetime(1971, 5, 1), 1.85], [datetime(1971, 5, 5), 2.22], [datetime(1971, 5, 19), 1.15], [datetime(1971, 6, 3), 0] ] winter_13_14_data = [
def plot_scatter(molmap, htmlpath='./', htmlname=None, radius=3): ''' molmap: the object of molmap htmlpath: the figure path, not include the prefix of 'html' htmlname: the name radius: int, defaut:3, the radius of scatter dot ''' title = '2D emmbedding of %s based on %s method' % (molmap.ftype, molmap.method) subtitle = 'number of %s: %s, metric method: %s' % ( molmap.ftype, len(molmap.flist), molmap.metric) name = '%s_%s_%s_%s_%s' % (molmap.ftype, len( molmap.flist), molmap.metric, molmap.method, 'scatter') if not os.path.exists(htmlpath): os.makedirs(htmlpath) if htmlname: name = htmlname + '_' + name filename = os.path.join(htmlpath, name) print_info('generate file: %s' % filename) xy = molmap.embedded.embedding_ colormaps = molmap.extract.colormaps df = pd.DataFrame(xy, columns=['x', 'y']) bitsinfo = molmap.extract.bitsinfo.set_index('IDs') df = df.join(bitsinfo.loc[molmap.flist].reset_index()) df['colors'] = df['Subtypes'].map(colormaps) H = Highchart(width=1000, height=850) H.set_options('chart', {'type': 'scatter', 'zoomType': 'xy'}) H.set_options('title', {'text': title}) H.set_options('subtitle', {'text': subtitle}) H.set_options( 'xAxis', { 'title': { 'enabled': True, 'text': 'X', 'style': { 'fontSize': 20 } }, 'labels': { 'style': { 'fontSize': 20 } }, 'gridLineWidth': 1, 'startOnTick': True, 'endOnTick': True, 'showLastLabel': True }) H.set_options( 'yAxis', { 'title': { 'text': 'Y', 'style': { 'fontSize': 20 } }, 'labels': { 'style': { 'fontSize': 20 } }, 'gridLineWidth': 1, }) # H.set_options('legend', {'layout': 'horizontal','verticalAlign': 'top','align':'right','floating': False, # 'backgroundColor': "(Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'", # 'borderWidth': 1}) H.set_options( 'legend', { 'align': 'right', 'layout': 'vertical', 'margin': 1, 'verticalAlign': 'top', 'y': 40, 'symbolHeight': 12, 'floating': False, }) H.set_options( 'plotOptions', { 'scatter': { 'marker': { 'radius': radius, 'states': { 'hover': { 'enabled': True, 'lineColor': 'rgb(100,100,100)' } } }, 'states': { 'hover': { 'marker': { 'enabled': False } } }, 'tooltip': { 'headerFormat': '<b>{series.name}</b><br>', 'pointFormat': '{point.IDs}' } }, 'series': { 'turboThreshold': 5000 } }) for subtype, color in colormaps.items(): dfi = df[df['Subtypes'] == subtype] if len(dfi) == 0: continue data = dfi.to_dict('records') H.add_data_set(data, 'scatter', subtype, color=color) H.save_file(filename) print_info('save html file to %s' % filename) return df, H
# -*- coding: utf-8 -*- """ Highcharts Demos Box plot: http://www.highcharts.com/demo/box-plot """ from highcharts import Highchart H = Highchart(width=550, height=400) options = { 'chart': { 'type': 'boxplot' }, 'title': { 'text': 'Highcharts Box Plot Example' }, 'legend': { 'enabled': False }, 'xAxis': { 'categories': ['1', '2', '3', '4', '5'], 'title': { 'text': 'Experiment No.' } }, 'yAxis': { 'title': { 'text': 'Observations' }, 'plotLines': [{
from twython import Twython from highcharts import Highchart chart = Highchart() options = { 'chart': { 'type': 'line' }, 'title': { 'text': 'Tweets Timeline' }, 'legend': { 'enabled': True }, 'xAxis': { 'categories': [ 'Jan-Jun09', 'Jul-Dec09', 'Jan-Jun10', 'Jul-Dec10', 'Jan-Jun11', 'Jul-Dec11', 'Jan-Jun12', 'Jul-Dec12', 'Jan-Jun13', 'Jul-Dec13', 'Jan-Jun14', 'Jul-Dec14', 'Jan-Jun15', 'Jul-Dec15', 'Jan-Jun16',
# -*- coding: utf-8 -*- """ Highcharts Demos 3D scatter chart: http://www.highcharts.com/demo/3d-scatter-draggable """ from highcharts import Highchart H = Highchart(width=550, height=400) """ This plot has two special features: 1. color setting: the javascript setting in the beginning, which can be added by colors option in our options dict the option_dict in color option can be string (as shown below), list, or dict. 2. roatation capability: the javascript function can be added using add_3dRoatation method (no input), which will add the function into the chart """ options = { 'chart': { 'renderTo': 'container', 'margin': 100, 'type': 'scatter', 'options3d': { 'enabled': True, 'alpha': 10, 'beta': 30, 'depth': 250, 'viewDistance': 5, 'frame': { 'bottom': { 'size': 1, 'color': 'rgba(0,0,0,0.02)' },
def create_chart(categories, values, title, filename, charttype, orientation, axisreverse, stack): chart = Highchart() options = { 'chart': { 'type': charttype }, 'title': { 'text': title }, 'xAxis': { 'reversed': axisreverse, 'categories': categories, 'maxPadding': 0.05, 'showLastLabel': True }, 'yAxis': { 'title': { 'text': '#Cases' }, 'stackLabels': { 'enabled': stack, 'style': { 'color': 'black' } }, 'lineWidth': 2 }, 'plotOptions': { 'series': { 'dataLabels': { 'enabled': True, 'style': { 'fontWeight': 'bold', 'color': 'gray' } }, 'stacking': 'normal' } }, 'legend': { 'enabled': True }, 'tooltip': { 'shared': True, 'enabled': True } } chart.set_dict_options(options) print(options) colors = ['#1A5276', '#6E2C00', '#2C3E50'] keys = list(values.keys()) for series in keys: data = values[series] chart.add_data_set(data, charttype, series, marker={'enabled': True}, color=colors[keys.index(series)]) print(filename) chart.save_file(filename)
# -*- coding: utf-8 -*- """ Highcharts Demos Donut chart: http://www.highcharts.com/demo/pie-donut """ from highcharts import Highchart H = Highchart(width = 850, height = 400) data = [{ 'y': 55.11, 'color': 'Highcharts.getOptions().colors[0]', 'drilldown': { 'name': 'MSIE versions', 'categories': ['MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'], 'data': [10.85, 7.35, 33.06, 2.81], 'color': 'Highcharts.getOptions().colors[0]' } }, { 'y': 21.63, 'color': 'Highcharts.getOptions().colors[1]', 'drilldown': { 'name': 'Firefox versions', 'categories': ['Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'], 'data': [0.20, 0.83, 1.58, 13.12, 5.43], 'color': 'Highcharts.getOptions().colors[1]' } }, { 'y': 11.94, 'color': 'Highcharts.getOptions().colors[2]', 'drilldown': {
if query == 1: data = q.topHashtags() plot = [] if data is None: print("Sorry, No Results Are Found!") else: table = PrettyTable() table.field_names = ["Hashtag", "Count"] for row in data: hashtag = row[1] count = row[0] table.add_row([hashtag, count]) plot.append([hashtag, count]) print(table) chart = Highchart(width=664, height=400) chart.set_options('chart', {'inverted': False}) options = { 'chart': { 'type': 'pie', 'options3d': { 'enabled': True, 'alpha': 45 } }, 'title': { 'text': 'Top Hashtags' }, 'subtitle': {
# -*- coding: utf-8 -*- """ Highcharts Demos Area range and line: http://www.highcharts.com/demo/arearange-line """ from highcharts import Highchart H = Highchart(width=750, height=600) ranges = [ [1246406400000, 14.3, 27.7], [1246492800000, 14.5, 27.8], [1246579200000, 15.5, 29.6], [1246665600000, 16.7, 30.7], [1246752000000, 16.5, 25.0], [1246838400000, 17.8, 25.7], [1246924800000, 13.5, 24.8], [1247011200000, 10.5, 21.4], [1247097600000, 9.2, 23.8], [1247184000000, 11.6, 21.8], [1247270400000, 10.7, 23.7], [1247356800000, 11.0, 23.3], [1247443200000, 11.6, 23.7], [1247529600000, 11.8, 20.7], [1247616000000, 12.6, 22.4], [1247702400000, 13.6, 19.6], [1247788800000, 11.4, 22.6], [1247875200000, 13.2, 25.0], [1247961600000, 14.2, 21.6], [1248048000000, 13.1, 17.1], [1248134400000, 12.2, 15.5], [1248220800000, 12.0, 20.8],
# -*- coding: utf-8 -*- """ Highcharts Demos Spline with inverted axes: http://www.highcharts.com/demo/spline-inverted """ from highcharts import Highchart H = Highchart() # set option H.set_options('chart', {'inverted': True}) # highchart option can be also set as a dict object # first construct the dict object for all the options: options = { 'title': { 'text': 'Atmosphere Temperature by Altitude' }, 'subtitle': { 'text': 'According to the Standard Atmosphere Model' }, 'xAxis': { 'reversed': False, 'title': { 'enabled': True, 'text': 'Altitude' }, 'labels': { 'formatter': 'function () {\ return this.value + "km";\ }' },
# -*- coding: utf-8 -*- """ Highcharts Demos Time series, zoomable: http://www.highcharts.com/demo/line-time-series """ import datetime from highcharts import Highchart H = Highchart() H.set_options('chart', {'zoomType': 'x'}) H.set_options('xAxis', {'type': 'datetime', 'minRange': 14 * 24 * 3600000}) H.set_options('yAxis',{ 'title': { 'text': 'Exchange rate'}}) H.set_options('title', {'text': 'USD to EUR exchange rate from 2006 through 2008'}) H.set_options('legend', {'enabled': False}) data = [ # copy dataset from http://www.highcharts.com/samples/data/jsonp.php?filename=usdeur.json&callback=? 0.8446, 0.8445, 0.8444, 0.8451, 0.8418, 0.8264, 0.8258, 0.8232, 0.8233, 0.8258, 0.8283, 0.8278, 0.8256, 0.8292, 0.8239, 0.8239, 0.8245, 0.8265, 0.8261, 0.8269, 0.8273, 0.8244, 0.8244, 0.8172, 0.8139, 0.8146, 0.8164, 0.82, 0.8269, 0.8269, 0.8269, 0.8258, 0.8247, 0.8286, 0.8289, 0.8316, 0.832, 0.8333, 0.8352, 0.8357, 0.8355, 0.8354, 0.8403, 0.8403, 0.8406, 0.8403, 0.8396, 0.8418, 0.8409, 0.8384, 0.8386, 0.8372, 0.839, 0.84, 0.8389, 0.84, 0.8423, 0.8423, 0.8435, 0.8422, 0.838, 0.8373, 0.8316, 0.8303, 0.8303, 0.8302, 0.8369, 0.84, 0.8385, 0.84, 0.8401, 0.8402, 0.8381, 0.8351, 0.8314, 0.8273, 0.8213, 0.8207, 0.8207, 0.8215, 0.8242, 0.8273, 0.8301, 0.8346, 0.8312, 0.8312, 0.8312, 0.8306, 0.8327, 0.8282,
# used to represent the frequency of posts by user # used to create dynamic graphs from highcharts import Highchart chart = Highchart() # new highchart object # graph attributes options = { 'chart': { 'type': 'bar', 'zoomType': 'xy' }, 'title': { 'text': 'Highchart Bar' }, 'legend': { 'enabled': True }, 'xAxis': { 'categories': ['User 1', 'User 2', 'User 3', 'User 4', 'User 5'], }, 'yAxis': { 'title': { 'text': 'Number of posts (thousands)' } }, } # we can use our own data data1 = [107, 31, 635, 203, 2] data2 = [133, 156, 947, 408, 6]
# -*- coding: utf-8 -*- """ Highcharts Demos Stacked and grouped column: http://www.highcharts.com/demo/column-stacked-and-grouped """ from highcharts import Highchart H = Highchart(width=750, height=600) data1 = [5, 3, 4, 7, 2] data2 = [3, 4, 4, 2, 5] data3 = [2, 5, 6, 2, 1] data4 = [3, 0, 4, 4, 3] options = { 'title': { 'text': 'Total fruit consumtion, grouped by gender' }, 'xAxis': { 'categories': ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] }, 'yAxis': { 'allowDecimals': False, 'min': 0, 'title': { 'text': 'Number of fruits' } },
from highcharts import Highchart chart = Highchart() options = { 'chart': { 'type':'bar'}, 'title':{ 'text':'Top 10 Hashtags'}, 'xAxis':{ 'categories':['1','2','3','4','5','6','7','8','9','10']}, 'yAxis':{ 'title':{ 'text':'Number of times mentioned'} }, } data1 #This is an array. make size 10. first means first graoh chart.set_dict_options(options) chart.add_data_set(data1, 'bar', 'Count') chart.save_file('./bar-highcharts')
# used to create dynamic graphs from highcharts import Highchart chart = Highchart() # new chart object # grapgh attributes options = { 'chart': { 'type': 'line', 'zoomType': 'xy' }, 'title': { 'text': 'Highchart Line' }, 'legend': { 'enabled': True }, 'xAxis': { 'categories': [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ], 'title': { 'text': 'Months of the year' } }, 'yAxis': { 'title': { 'text': 'Number of followers' } }, }
""" Jugal Marfatia Macroeconomics homework 3. """ import numpy as np import numpy.matlib as mt import pandas as pd from highcharts import Highchart H = Highchart(width=750, height=600) H1 = Highchart(width=750, height=600) A = 1.0 alpha = 0.36 beta = 0.9 kss = (alpha*beta)**(1/(1-alpha)) # steady state # comment for Part (d) # L = 0.95 # factor lower bound # U = 1.05 # factor upper bound # n = 2 # number of grid points # uncomment for Part (d) L = 0.6 # idem U = 1.4 # idem n = 100 # idem k = np.linspace(L * kss, U * kss, n) criteria = 1.0 # init criterion for stopping iterations tol = 1e-6 # tolerance
# -*- coding: utf-8 -*- """ Highcharts Demos Column with drilldown: http://www.highcharts.com/demo/column-drilldown """ from highcharts import Highchart H = Highchart(width=850, height=400) """ Drilldown chart can be created using add_drilldown_data_set method: add_drilldown_data_set(data, series_type, id, **kwargs): id is the drilldown parameter in upperlevel dataset (Ex. drilldown parameters in data) drilldown dataset is constructed similar to dataset for other chart """ data = [{ 'name': "Microsoft Internet Explorer", 'y': 56.33, 'drilldown': "Microsoft Internet Explorer" }, { 'name': "Chrome", 'y': 24.030000000000005, 'drilldown': "Chrome" }, { 'name': "Firefox", 'y': 10.38, 'drilldown': "Firefox" }, { 'name': "Safari",