I would like to import a cell, for example a chart, from another notebook without explicitly requiring its dependent stylesheet again.
Here is the example:
I have a chart
defined in the notebook. The chart
depends on 3rd party libs and styles.
and I import the chart
in the other notebook
First of all, it is not intuitive to me. Why the 3rd party lib is implicitly imported with the chart
but not the stylesheet?
it is not rendered correctly unless I explicitly import and evaluate the stylesheet
from the source notebook.
If I write something like this in the source notebook. It will still not work. The html
function does not put the <link>
into current document as I expect.
Chartist = {
let stylesheet = html`<link rel='stylesheet';
href='https://unpkg.com/chartist@0.11.0/dist/chartist.min.css' />`;
return await require('chartist');
}
This will work as I expect, but it is pretty tedious…
Chartist = {
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = 'https://unpkg.com/chartist@0.11.0/dist/chartist.min.css';
document.getElementsByTagName("head")[0].appendChild(link);
return await require('chartist');
}
looking for advice. Thanks