MplD3
已回答
The mpld3 package provides a structure for implementing plugin classes that can be registered in the framework to generate javascript versions of matplotlib figures. A typical class looks like this:
class LinkedView(plugins.PluginBase):
JAVASCRIPT = """
<some javascript>
"""
def __init__(self, some_plt_elements, some_data):
self.dict_ = {"type": "linkedview",
"data": utils.get_id(some_plt_elements),
"line_ids": some_data
}
Does anyone know how to form the proper language injection regex so that whenever an editor opens content with one of these classes it will automatically inject javascript into the RHS of the JAVASCRIPT assignment?
请先登录再写评论。
Hi Erik,
No, unfortunately, it's not possible to create such custom injection trigger on the user side. In theory, it could be configurable via Settings | Editor | Language Injection page. but we support only very basic patterns for matching Python AST there so far. Meanwhile, you can always add a magical comment "# language=JavaScript" right before the assignment to JAVASCRIPT to inject JavaScript automatically in the string literal (as described in the webhelp).