當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。