-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs would be greatly appreciated #22
Comments
Hi! |
Hi Dmytro, I am running into similar issues as well. Seeing this issue, I am not creating a separate issue. First, the first block you have is: //Some plotly examples require d3 library to work.
//Since it's large and used by few examples,
//I propose a workaround to import d3;
//You need to download dependency from https://d3js.org/d3.v7.min.js
//and place it in your vault.
let path = app.vault.adapter.basePath;//absolute path to your vault
var d3 = require(path+"\\utils\\d3.v7.min.js"); Do we set the absolute path as Next, if The next part of the code is: var data = [
x: ['giraffes', 'orangutans', 'monkeys'], y: [20, 14, 23], name: 'SF Zoo', type: 'bar'
];
var layout = {barmode: 'stack'};
var config = {displaylogo:false}; The final code: //Some plotly examples require d3 library to work.
//Since it's large and used by few examples,
//I propose a workaround to import d3;
//You need to download dependency from https://d3js.org/d3.v7.min.js
//and place it in your vault.
let path = app.vault.adapter.basePath;//absolute path to your vault
var d3 = require(path+"\\utils\\d3.v7.min.js");
//Replace this block with any example from plotly.com
//NOTE: `Plotly.newPlot` won't work here, use `window.renderPlotly` instead
var data = [
x: ['giraffes', 'orangutans', 'monkeys'], y: [20, 14, 23], name: 'SF Zoo', type: 'bar'
];
var layout = {barmode: 'stack'};
var config = {displaylogo:false};
window.renderPlotly(this.container, data, layout, config) The code does not run, even if I set the absolute path with The complete final code above does not render a graph. It just sits there without execution. Thank you. |
Hello @tolga-balci ! First thing is that let path = app.vault.adapter.basePath;
console.log(path); // you should see "C:\Users\Tolga\MyNotes" And yes, my examples assumes you to have d3 library here: "C:\Users\Tolga\MyNotes\utils\d3.v7.min.js" Second, there is an error with your data object, which Plotly API expects to be an array of objects like this [{x,y},{x,y},{x,y}]. This patched version of your example should work fine: let data = [{
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
name: 'SF Zoo',
type: 'bar'
}];
let layout = {barmode: 'stack'};
let config = {displaylogo:false};
window.renderPlotly(this.container, data, layout, config) Thank you for using the plugin. |
Many thanks @Dmytro-Shulha for your detailed explanation. |
Do you have DataView plugin installed? |
OK, now it fits. It seems that it is related to DataView and JS execution settings. |
Pasting code directly from Plotly website is not working.
The text was updated successfully, but these errors were encountered: