当前位置: 首页>>代码示例>>Python>>正文


Python resources.CDN属性代码示例

本文整理汇总了Python中bokeh.resources.CDN属性的典型用法代码示例。如果您正苦于以下问题:Python resources.CDN属性的具体用法?Python resources.CDN怎么用?Python resources.CDN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在bokeh.resources的用法示例。


在下文中一共展示了resources.CDN属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _output_plot_file

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def _output_plot_file(self, model, idx, filename=None, template="basic.html.j2"):
        if filename is None:
            tmpdir = tempfile.gettempdir()
            filename = os.path.join(tmpdir, f"bt_bokeh_plot_{idx}.html")

        env = Environment(loader=PackageLoader('backtrader_plotting.bokeh', 'templates'))
        templ = env.get_template(template)
        templ.globals['now'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        html = file_html(model,
                         template=templ,
                         resources=CDN,
                         template_variables=dict(
                             stylesheet=self._output_stylesheet(),
                             show_headline=self.p.scheme.show_headline,
                             )
                         )

        with open(filename, 'w') as f:
            f.write(html)

        return filename 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:24,代码来源:bokeh.py

示例2: index

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def index():
	# Create the plot
	plot = create_figure()
	# tag here means the tag to reference to the new bokeh chart, saved as a js file
	js, plot_tag = components(plot, CDN, "/Users/brendantham/Desktop/FYP/Flask/static/plots")

	# TODO: 
	# 1) fix URLS
	# 2) figure out where to store the js files for future load use 

	# with open('/Users/brendantham/Desktop/FYP/Flask/static/plots/plot1.js', 'w') as f:  
	# 	f.write(js)
		
	return render_template("index.html", script1 = js, plot1 = plot_tag)

# With debug=True, Flask server will auto-reload 
# when there are code changes 
开发者ID:wywongbd,项目名称:pairstrade-fyp-2019,代码行数:19,代码来源:app.py

示例3: getHTML

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def getHTML(self, params):
        ticker = params['ticker']
        if ticker == 'empty':
            ticker = params['custom_ticker'].upper()
        df = self.getData(params)  # get data
        try:
            bokeh_plot = plotting.line(
                df.index, df['Close'], color='#1c2980',
                legend="Close", x_axis_type="datetime", title=ticker
            )
        except AttributeError:
            bokeh_plot = plotting.figure(x_axis_type='datetime', title=ticker)
            bokeh_plot.line(df.index, df['Close'], color='#1c2980', legend="Close")
        bokeh_plot.line(df.index, df['High'], color='#80641c', legend="High")
        bokeh_plot.line(df.index, df['Low'], color='#80321c', legend="Low")

        script, div = components(bokeh_plot, CDN)
        html = "%s\n%s" % (script, div)
        return html 
开发者ID:adamhajari,项目名称:spyre,代码行数:21,代码来源:stocks_w_bokeh_example.py

示例4: pvalue_plot

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def pvalue_plot( date, pvalues_lower, pvalues_upper ):
    plot = figure(x_axis_type = "datetime", plot_height=250, plot_width=600)
    plot.line(date, pvalues_lower, legend='Lower', line_color='green')
    plot.line(date, pvalues_upper, legend='Upper', line_color='red')
    plot.legend.orientation = "top_left"
    plot.title = '-log(P Values)'

    script, div = components(plot, CDN)
    return { 'script': script, 'div': div } 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:11,代码来源:views.py

示例5: counts_plot

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def counts_plot( date, baseline_counts, target_counts ):
    counts_t = np.sum(target_counts)
    counts_b = np.sum(baseline_counts)
    scale_baseline = counts_b >= 10*counts_t
    if scale_baseline:
        baseline_counts *= np.sum(target_counts)/np.sum(baseline_counts)

    plot = figure(x_axis_type = "datetime", plot_height=250, plot_width=600)
    plot.line(date, baseline_counts, legend='Scaled Baseline' if scale_baseline else 'Baseline')
    plot.line(date, target_counts, line_color='orange', legend='Target')
    plot.legend.orientation = "top_left"
    plot.title = 'Counts'

    script, div = components(plot, CDN)
    return { 'script': script, 'div': div } 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:17,代码来源:views.py

示例6: html

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def html(self, obj, fmt=None, css=None, resources='CDN', **kwargs):
        """
        Renders plot or data structure and wraps the output in HTML.
        The comm argument defines whether the HTML output includes
        code to initialize a Comm, if the plot supplies one.
        """
        plot, fmt =  self._validate(obj, fmt)
        figdata, _ = self(plot, fmt, **kwargs)
        if isinstance(resources, basestring):
            resources = resources.lower()
        if css is None: css = self.css

        if isinstance(plot, Viewable):
            doc = Document()
            plot._render_model(doc)
            if resources == 'cdn':
                resources = CDN
            elif resources == 'inline':
                resources = INLINE
            return file_html(doc, resources)
        elif fmt in ['html', 'json']:
            return figdata
        else:
            if fmt == 'svg':
                figdata = figdata.encode("utf-8")
            elif fmt == 'pdf' and 'height' not in css:
                _, h = self.get_size(plot)
                css['height'] = '%dpx' % (h*self.dpi*1.15)

        if isinstance(css, dict):
            css = '; '.join("%s: %s" % (k, v) for k, v in css.items())
        else:
            raise ValueError("CSS must be supplied as Python dictionary")

        b64 = base64.b64encode(figdata).decode("utf-8")
        (mime_type, tag) = MIME_TYPES[fmt], HTML_TAGS[fmt]
        src = HTML_TAGS['base64'].format(mime_type=mime_type, b64=b64)
        html = tag.format(src=src, mime_type=mime_type, css=css)
        return html 
开发者ID:holoviz,项目名称:holoviews,代码行数:41,代码来源:renderer.py

示例7: getHTML

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def getHTML(self, params):
        state = params['state']
        if state == 'all':
            data = self.data
        else:
            data = self.data[self.data['state'] == state]

        TOOLS = "pan,wheel_zoom,box_zoom,reset,hover,previewsave"

        try:
            fig = plotting.patches(
                data['lons'], data['lats'], fill_color=data['color'], fill_alpha=0.7, tools=TOOLS,
                line_color="white", line_width=0.5, title=state.upper() + " Unemployment 2009"
            )
        except Exception:
            fig = plotting.figure(title=state.upper() + " Unemployment 2009", tools=TOOLS)
            fig.patches(
                data['lons'], data['lats'], fill_color=data['color'],
                fill_alpha=0.7, line_color="white", line_width=0.5
            )

        hover = fig.select(dict(type=HoverTool))
        hover.tooltips = OrderedDict([
            ("index", "$index")
        ])

        script, div = components(fig, CDN)
        html = "%s\n%s" % (script, div)
        return html 
开发者ID:adamhajari,项目名称:spyre,代码行数:31,代码来源:unemployment_example.py

示例8: save

# 需要导入模块: from bokeh import resources [as 别名]
# 或者: from bokeh.resources import CDN [as 别名]
def save(self_or_cls, obj, basename, fmt='auto', key={}, info={},
             options=None, resources='inline', title=None, **kwargs):
        """
        Save a HoloViews object to file, either using an explicitly
        supplied format or to the appropriate default.
        """
        if info or key:
            raise Exception('Renderer does not support saving metadata to file.')

        if kwargs:
            param.main.warning("Supplying plot, style or norm options "
                               "as keyword arguments to the Renderer.save "
                               "method is deprecated and will error in "
                               "the next minor release.")

        with StoreOptions.options(obj, options, **kwargs):
            plot, fmt = self_or_cls._validate(obj, fmt)

        if isinstance(plot, Viewable):
            from bokeh.resources import CDN, INLINE, Resources
            if isinstance(resources, Resources):
                pass
            elif resources.lower() == 'cdn':
                resources = CDN
            elif resources.lower() == 'inline':
                resources = INLINE
            if isinstance(basename, basestring):
                if title is None:
                    title = os.path.basename(basename)
                if fmt in MIME_TYPES:
                    basename = '.'.join([basename, fmt])
            plot.layout.save(basename, embed=True, resources=resources, title=title)
            return

        rendered = self_or_cls(plot, fmt)
        if rendered is None: return
        (data, info) = rendered
        encoded = self_or_cls.encode(rendered)
        prefix = self_or_cls._save_prefix(info['file-ext'])
        if prefix:
            encoded = prefix + encoded
        if isinstance(basename, (BytesIO, StringIO)):
            basename.write(encoded)
            basename.seek(0)
        else:
            filename ='%s.%s' % (basename, info['file-ext'])
            with open(filename, 'wb') as f:
                f.write(encoded) 
开发者ID:holoviz,项目名称:holoviews,代码行数:50,代码来源:renderer.py


注:本文中的bokeh.resources.CDN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。