diff --git a/highcharts/highcharts/highcharts.py b/highcharts/highcharts/highcharts.py index 86f38b1..714cbaa 100644 --- a/highcharts/highcharts/highcharts.py +++ b/highcharts/highcharts/highcharts.py @@ -6,12 +6,10 @@ from past.builtins import basestring from jinja2 import Environment, PackageLoader -# import sys -# reload(sys) -# sys.setdefaultencoding("utf-8") import json, uuid -import datetime, random, os, inspect +import datetime +import html from collections import Iterable from .options import BaseOptions, ChartOptions, \ ColorsOptions, CreditsOptions, DrilldownOptions, ExportingOptions, \ @@ -357,6 +355,22 @@ def buildcontainer(self): def htmlcontent(self): return self.buildhtml() + @property + def iframe(self): + htmlsrcdoc = html.escape(self.htmlcontent) + width = int(self.options['chart'].__dict__['width']) if self.options['chart'].__dict__.get('width') else 820 + height = int(self.options['chart'].__dict__['height']) if self.options['chart'].__dict__.get('height') else 520 + + if self.options['chart'].__dict__.get('options3d'): + if len(htmlsrcdoc) < 99965000 : + return '' + else: + return '' + else: + return '' + + def __str__(self): """return htmlcontent""" #self.buildhtml() diff --git a/highcharts/highmaps/highmaps.py b/highcharts/highmaps/highmaps.py index 7df1e11..0afe210 100644 --- a/highcharts/highmaps/highmaps.py +++ b/highcharts/highmaps/highmaps.py @@ -6,12 +6,12 @@ from past.builtins import basestring -from optparse import OptionParser from urllib.request import urlopen from jinja2 import Environment, PackageLoader import json, uuid -import datetime, random, os, inspect +import datetime +import html from collections import Iterable from .options import BaseOptions, ChartOptions, \ ColorsOptions, ColorAxisOptions, CreditsOptions, DrilldownOptions, ExportingOptions, \ @@ -418,6 +418,21 @@ def buildcontainer(self): def htmlcontent(self): return self.buildhtml() + @property + def iframe(self): + htmlsrcdoc = html.escape(self.htmlcontent) + width = int(self.options['chart'].__dict__['width']) if self.options['chart'].__dict__.get('width') else 820 + height = int(self.options['chart'].__dict__['height']) if self.options['chart'].__dict__.get('height') else 520 + + if self.options['chart'].__dict__.get('options3d'): + if len(htmlsrcdoc) < 99965000 : + return '' + else: + return '' + else: + return '' + def __str__(self): """return htmlcontent""" #self.buildhtml() diff --git a/highcharts/highstock/highstock.py b/highcharts/highstock/highstock.py index fe649ca..70401c5 100644 --- a/highcharts/highstock/highstock.py +++ b/highcharts/highstock/highstock.py @@ -4,11 +4,11 @@ from future.standard_library import install_aliases install_aliases() -from optparse import OptionParser from jinja2 import Environment, PackageLoader import json, uuid -import datetime, random, os, inspect +import datetime +import html from collections import Iterable from .options import BaseOptions, ChartOptions, \ ColorsOptions, CreditsOptions, ExportingOptions, \ @@ -352,6 +352,21 @@ def buildcontainer(self): def htmlcontent(self): return self.buildhtml() + @property + def iframe(self): + htmlsrcdoc = html.escape(self.htmlcontent) + width = int(self.options['chart'].__dict__['width']) if self.options['chart'].__dict__.get('width') else 820 + height = int(self.options['chart'].__dict__['height']) if self.options['chart'].__dict__.get('height') else 520 + + if self.options['chart'].__dict__.get('options3d'): + if len(htmlsrcdoc) < 99965000 : + return '' + else: + return '' + else: + return '' + def __str__(self): """return htmlcontent""" #self.buildhtml() diff --git a/highcharts/ipynb.py b/highcharts/ipynb.py index 648a2e9..20b4e3a 100644 --- a/highcharts/ipynb.py +++ b/highcharts/ipynb.py @@ -17,20 +17,7 @@ def _print_html(chart): to generate the chart. This function is bound to the ipython formatter so that charts are displayed inline.''' - import html - htmlsrcdoc = html.escape(chart.htmlcontent) - width = int(chart.options['chart'].__dict__['width']) if chart.options['chart'].__dict__.get('width') else 820 - height = int(chart.options['chart'].__dict__['height']) if chart.options['chart'].__dict__.get('height') else 520 - - if chart.options['chart'].__dict__.get('options3d'): - if len(htmlsrcdoc) < 99965000 : - return '' - else: - return '' - else: - return '' - + return chart.iframe def _setup_ipython_formatter(ip): ''' Set up the ipython formatter to display HTML formatted output inline'''