-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
window.renderChart() does not work with admonition #22
Comments
It would definetly be helpful if you post the full code you are using |
Sorry about that! You're right, not sure why I didn't supply it in the first place. Here it is together with the encompassing admonition block````ad-note
title: Blood Pressure Graph Sept-Oct
icon: tint
color: 220, 20, 60
collapse: closed
```dataviewjs
var dateStart = "2021-09-01";
var dateEnd = "2021-10-31";
var dnotes = dv.pages("#daily-log").where(p =>
dv.date(p.file.name) >=
dv.date(dateStart) &&
dv.date(p.file.name) <=
dv.date(dateEnd));
var tdata = [];
var bdata = [];
var allLabels = [];
for (let i = 0; i < dnotes.length; i++) {
if (dnotes[i].avgbp){
allLabels.push(dnotes[i].file.name)
var strNum = dnotes[i].avgbp.split("/")[0]
var num = parseInt(strNum)
tdata.push(num);
var strrNum = dnotes[i].avgbp.split("/")[1]
var numm = parseInt(strrNum)
bdata.push(numm);
//console.log(parseInt(dnotes[i].avgbp.trimLeft("/"));
//console.log(parseInt(dnotes[i].avgbp.trimRight("/"))
}
}
allLabels.reverse()
tdata.reverse()
bdata.reverse()
const chartData = {
type: 'bar',
data: {
labels: allLabels,
width: "10%",
datasets: [{
label: 'Top',
data: tdata ,
backgroundColor: ['rgba(217, 121, 137)'
],
},
{
label: 'Bottom',
data: bdata,
backgroundColor: 'rgba(121, 156, 212)'}]
}
}
//console.log(allLabels)
const average = (array) => array.reduce((a, b) => a + b) / array.length;
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}
var avgBP = 'Average Blood Pressure: {0}/{1}'.format(
Math.round(
(average(tdata) + Number.EPSILON) * 100) / 100,
Math.round(
(average(bdata) + Number.EPSILON) * 100) / 100);
window.renderChart(chartData, this.container);
dv.header(2, avgBP)
```
```` Here is the full error stack, I can't make heads or tails of it sadly
|
Okay, do other dataview blocks work fine inside admonitions? |
I cannot find any error in your code, it might actually be an issue with admonitions |
Yes they do actually! I just ran a quick test with wrapping
Interesting! I'll open an issue on its page then and update if I make any more progress. Thank you! |
Does it work now? |
Sorry today has been a lot and i only just saw this! No, it's still not working (I just made sure to update and made sure admonition works with other dataviewjs blocks, and it does) |
CodeMirror Options WSYSWIG breaks because the MarkdownPostprocessorContext is not passed
Please check with the new Update |
Just ran the 'check for updates' command in obsidian, installed all updates and checked, and no it's still causing the same error. Again the code still works outside of the admonition block just not at all inside. If there's anything else you'd like me to test let me know! |
Ah, no I forgot this Issue has to do with the dataview api.. |
SORRY I NEVER SAW THIS REPLY My github notifs were flooded with a project I accidentally subscribed to YES it works!!!!!!!!!!! I have no idea what changed but its totally working!! thank you! |
Hello! I absolutely love this plugin and I intend to use it a lot more. However, I've run into a strange error. Using window.renderchart within dataviewjs that is also wrapped in a admonition block will throw the following error:
Using it without the block it works fine, but I make heavy use of admonition blocks for organizational purposes.
Is there something I'm doing wrong? I can post the full script that I'm using and the full error if needed, just let me know!
The text was updated successfully, but these errors were encountered: