Esempio n. 1
0
    def _add_graph_cell(self, fig_name):
        """Add a HTML table cell to hold the plot"""

        div_js = """
            <script>
            var ilp_req = require.config( {

                paths: {
                    "dygraph-sync": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/synchronizer") + """',
                    "dygraph": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/dygraph-combined") + """',
                    "ILinePlot": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/ILinePlot") + """',
                    "underscore": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/underscore-min") + """',
                },

                shim: {
                    "dygraph-sync": ["dygraph"],
                    "ILinePlot": {

                        "deps": ["dygraph-sync", "dygraph", "underscore"],
                        "exports":  "ILinePlot"
                    }
                }
            });
                ilp_req(["require", "ILinePlot"], function() {
                ILinePlot.generate('""" + fig_name + """', '""" + IPythonConf.add_web_base("") + """');
            });
            </script>
        """

        cell = '<td style="border-style: hidden;"><div class="ilineplot" id="{}">{}</div></td>'.format(fig_name, div_js)

        self._html.append(cell)
Esempio n. 2
0
    def _init_html(self):
        """Initialize HTML for the plot"""
        div_js = """
        <script>
            var req = require.config( {

                paths: {

                    "EventPlot": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/EventPlot") + """',
                    "d3-tip": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.tip.v0.6.3") + """',
                    "d3-plotter": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.min") + """'
                },
                shim: {
                    "d3-plotter" : {
                        "exports" : "d3"
                    },
                    "d3-tip": ["d3-plotter"],
                    "EventPlot": {

                        "deps": ["d3-tip", "d3-plotter" ],
                        "exports":  "EventPlot"
                    }
                }
            });
            req(["require", "EventPlot"], function() {
               EventPlot.generate('""" + self._fig_name + """', '""" + IPythonConf.add_web_base("") + """');
            });
        </script>
        """

        self._html.append(
            '<div id="{}" class="eventplot">{}</div>'.format(self._fig_name,
                                                             div_js))
def change_resource_paths(txt):
    """Change the resource paths from local to
       Web URLs
    """

    # Replace the path for d3-tip
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.tip.v0.6.3"),
        "http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.v3.min"),
        "http://d3js.org/d3.v3.min")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/EventPlot/EventPlot"),
        "https://rawgit.com/sinkap/7f89de3e558856b81f10/raw/46144f8f8c5da670c54f826f0c634762107afc66/EventPlot")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/synchronizer"),
        "http://dygraphs.com/extras/synchronizer")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/dygraph-combined"),
        "http://cdnjs.cloudflare.com/ajax/libs/dygraph/1.1.1/dygraph-combined")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/ILinePlot"),
        "https://rawgit.com/sinkap/648927dfd6985d4540a9/raw/69d6f1f9031ae3624c15707315ce04be1a9d1ac3/ILinePlot")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/underscore-min"),
        "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min")

    logging.info("Updated Library Paths...")
    return txt
def change_resource_paths(txt):
    """Change the resource paths from local to
       Web URLs
    """

    # Replace the path for d3-tip
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.tip.v0.6.3"),
        IPythonConf.D3_TIP_URL)
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.v3.min"),
        IPythonConf.D3_PLOTTER_URL)
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/EventPlot/EventPlot"),
        "https://rawgit.com/sinkap/7f89de3e558856b81f10/raw/46144f8f8c5da670c54f826f0c634762107afc66/EventPlot")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/synchronizer"),
        IPythonConf.DYGRAPH_SYNC_URL)
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/dygraph-combined"),
        IPythonConf.DYGRAPH_COMBINED_URL)
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/ILinePlot"),
        "https://rawgit.com/sinkap/648927dfd6985d4540a9/raw/69d6f1f9031ae3624c15707315ce04be1a9d1ac3/ILinePlot")
    txt = txt.replace(
        IPythonConf.add_web_base("plotter_scripts/ILinePlot/underscore-min"),
        IPythonConf.UNDERSCORE_URL)

    logging.info("Updated Library Paths...")
    return txt
Esempio n. 5
0
    def _init_html(self):
        """Initialize HTML for the plot"""
        div_js = ''
        for url in [IPythonConf.D3_PLOTTER_URL, IPythonConf.D3_TIP_URL]:
            div_js += '<!-- TRAPPY_PUBLISH_SOURCE_LIB = "{}" -->\n'.format(url)

        div_js += """
        <script>
            /* TRAPPY_PUBLISH_IMPORT = "plotter/js/EventPlot.js" */
            /* TRAPPY_PUBLISH_REMOVE_START */
            var req = require.config( {

                paths: {

                    "EventPlot": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/EventPlot") + """',
                    "d3-tip": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.tip.v0.6.3") + """',
                    "d3-plotter": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.min") + """'
                },
                waitSeconds: 15,
                shim: {
                    "d3-plotter" : {
                        "exports" : "d3"
                    },
                    "d3-tip": ["d3-plotter"],
                    "EventPlot": {

                        "deps": ["d3-tip", "d3-plotter" ],
                        "exports":  "EventPlot"
                    }
                }
            });
            /* TRAPPY_PUBLISH_REMOVE_STOP */
            """

        div_js += """
        req(["require", "EventPlot"], function() { /* TRAPPY_PUBLISH_REMOVE_LINE */
            EventPlot.generate('""" + self._fig_name + "', '" + IPythonConf.add_web_base("") + "', " + self._data + """);
        }); /* TRAPPY_PUBLISH_REMOVE_LINE */
        </script>
        """

        self._html.append(
            '<div id="{}" class="eventplot">\n{}</div>'.format(self._fig_name,
                                                             div_js))
Esempio n. 6
0
    def _init_html(self):
        """Initialize HTML for the plot"""
        div_js = ''
        for url in [IPythonConf.D3_PLOTTER_URL, IPythonConf.D3_TIP_URL]:
            div_js += '<!-- TRAPPY_PUBLISH_SOURCE_LIB = "{}" -->\n'.format(url)

        div_js += """
        <script>
            /* TRAPPY_PUBLISH_IMPORT = "plotter/js/EventPlot.js" */
            /* TRAPPY_PUBLISH_REMOVE_START */
            var req = require.config( {

                paths: {

                    "EventPlot": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/EventPlot") + """',
                    "d3-tip": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.tip.v0.6.3") + """',
                    "d3-plotter": '""" + IPythonConf.add_web_base("plotter_scripts/EventPlot/d3.min") + """'
                },
                waitSeconds: 15,
                shim: {
                    "d3-plotter" : {
                        "exports" : "d3"
                    },
                    "d3-tip": ["d3-plotter"],
                    "EventPlot": {

                        "deps": ["d3-tip", "d3-plotter" ],
                        "exports":  "EventPlot"
                    }
                }
            });
            /* TRAPPY_PUBLISH_REMOVE_STOP */
            """

        div_js += """
        req(["require", "EventPlot"], function() { /* TRAPPY_PUBLISH_REMOVE_LINE */
            EventPlot.generate('""" + self._fig_name + "', '" + IPythonConf.add_web_base("") + "', " + self._data + """);
        }); /* TRAPPY_PUBLISH_REMOVE_LINE */
        </script>
        """

        self._html.append(
            '<div id="{}" class="eventplot">\n{}</div>'.format(self._fig_name,
                                                             div_js))
Esempio n. 7
0
    def _add_graph_cell(self, fig_name, color_map):
        """Add a HTML table cell to hold the plot"""

        colors_opt_arg = ", " + to_dygraph_colors(color_map) if color_map else ""

        graph_js = ''
        lib_urls =  [IPythonConf.DYGRAPH_COMBINED_URL, IPythonConf.DYGRAPH_SYNC_URL,
                     IPythonConf.UNDERSCORE_URL]
        for url in lib_urls:
            graph_js += '<!-- TRAPPY_PUBLISH_SOURCE_LIB = "{}" -->\n'.format(url)

        graph_js += """
            <script>
            /* TRAPPY_PUBLISH_IMPORT = "plotter/js/ILinePlot.js" */
            /* TRAPPY_PUBLISH_REMOVE_START */
            var ilp_req = require.config( {

                paths: {
                    "dygraph-sync": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/synchronizer") + """',
                    "dygraph": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/dygraph-combined") + """',
                    "ILinePlot": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/ILinePlot") + """',
                    "underscore": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/underscore-min") + """',
                },

                shim: {
                    "dygraph-sync": ["dygraph"],
                    "ILinePlot": {

                        "deps": ["dygraph-sync", "dygraph", "underscore"],
                        "exports":  "ILinePlot"
                    }
                }
            });
                /* TRAPPY_PUBLISH_REMOVE_STOP */
                ilp_req(["require", "ILinePlot"], function() { /* TRAPPY_PUBLISH_REMOVE_LINE */
                ILinePlot.generate(""" + fig_name + "_data" + colors_opt_arg + """);
            }); /* TRAPPY_PUBLISH_REMOVE_LINE */
            </script>
        """

        cell = '<td style="border-style: hidden;"><div class="ilineplot" id="{}"></div></td>'.format(fig_name)

        self._html.append(cell)
        self._js.append(graph_js)
Esempio n. 8
0
    def _add_graph_cell(self, fig_name, color_map):
        """Add a HTML table cell to hold the plot"""

        colors_opt_arg = ", " + to_dygraph_colors(color_map) if color_map else ""

        graph_js = ''
        lib_urls =  [IPythonConf.DYGRAPH_COMBINED_URL, IPythonConf.DYGRAPH_SYNC_URL,
                     IPythonConf.UNDERSCORE_URL]
        for url in lib_urls:
            graph_js += '<!-- TRAPPY_PUBLISH_SOURCE_LIB = "{}" -->\n'.format(url)

        graph_js += """
            <script>
            /* TRAPPY_PUBLISH_IMPORT = "plotter/js/ILinePlot.js" */
            /* TRAPPY_PUBLISH_REMOVE_START */
            var ilp_req = require.config( {

                paths: {
                    "dygraph-sync": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/synchronizer") + """',
                    "dygraph": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/dygraph-combined") + """',
                    "ILinePlot": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/ILinePlot") + """',
                    "underscore": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/underscore-min") + """',
                },

                shim: {
                    "dygraph-sync": ["dygraph"],
                    "ILinePlot": {

                        "deps": ["dygraph-sync", "dygraph", "underscore"],
                        "exports":  "ILinePlot"
                    }
                }
            });
                /* TRAPPY_PUBLISH_REMOVE_STOP */
                ilp_req(["require", "ILinePlot"], function() { /* TRAPPY_PUBLISH_REMOVE_LINE */
                ILinePlot.generate(""" + fig_name + "_data" + colors_opt_arg + """);
            }); /* TRAPPY_PUBLISH_REMOVE_LINE */
            </script>
        """

        cell = '<td style="border-style: hidden;"><div class="ilineplot" id="{}"></div></td>'.format(fig_name)

        self._html.append(cell)
        self._js.append(graph_js)
Esempio n. 9
0
    def _init_html(self):
        """Initialize HTML for the plot"""
        div_js = """
        <script>
            var req = require.config( {

                paths: {

                    "EventPlot": '""" + IPythonConf.add_web_base(
            "plotter_scripts/EventPlot/EventPlot") + """',
                    "d3-tip": '""" + IPythonConf.add_web_base(
                "plotter_scripts/EventPlot/d3.tip.v0.6.3") + """',
                    "d3-plotter": '""" + IPythonConf.add_web_base(
                    "plotter_scripts/EventPlot/d3.v3.min") + """'
                },
                shim: {
                    "d3-plotter" : {
                        "exports" : "d3"
                    },
                    "d3-tip": ["d3-plotter"],
                    "EventPlot": {

                        "deps": ["d3-tip", "d3-plotter" ],
                        "exports":  "EventPlot"
                    }
                }
            });
            req(["require", "EventPlot"], function() {
               EventPlot.generate('""" + self._fig_name + """', '""" + IPythonConf.add_web_base(
                        "") + """');
            });
        </script>
        """

        self._html.append('<div id="{}" class="eventplot">{}</div>'.format(
            self._fig_name, div_js))
Esempio n. 10
0
    def _add_graph_cell(self, fig_name):
        """Add a HTML table cell to hold the plot"""

        width = int(self._attr["width"] / self._cols)
        div_js = """
            <script>
            var ilp_req = require.config( {

                paths: {
                    "dygraph-sync": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/synchronizer") + """',
                    "dygraph": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/dygraph-combined") + """',
                    "ILinePlot": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/ILinePlot") + """',
                    "underscore": '""" + IPythonConf.add_web_base("plotter_scripts/ILinePlot/underscore-min") + """',
                },

                shim: {
                    "dygraph-sync": ["dygraph"],
                    "ILinePlot": {

                        "deps": ["dygraph-sync", "dygraph", "underscore"],
                        "exports":  "ILinePlot"
                    }
                }
            });
                ilp_req(["require", "ILinePlot"], function() {
                ILinePlot.generate('""" + fig_name + """', '""" + IPythonConf.add_web_base("") + """');
            });
            </script>
        """

        cell = '<td style="border-style: hidden;"><div class="ilineplot" id="{0}" style="width: \
{1}px; height: {2}px;">{3}</div></td>'.format(fig_name,
                                           width,
                                           self._attr["height"], div_js)

        self._html.append(cell)