Giter VIP home page Giter VIP logo

Comments (12)

wychwitch avatar wychwitch commented on June 26, 2024 1

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!

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

It would definetly be helpful if you post the full code you are using

from obsidian-charts.

wychwitch avatar wychwitch commented on June 26, 2024

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

Evaluation Error: SyntaxError: missing ) after argument list
    at DataviewInlineApi.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:12641:21)
    at evalInContext (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:12642:7)
    at eval (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:12653:36)
    at Generator.next (<anonymous>)
    at eval (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:26:71)
    at new Promise (<anonymous>)
    at __awaiter (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:22:12)
    at asyncEvalInContext (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:12648:12)
    at DataviewJSRenderer.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1215379), <anonymous>:13175:23)
    at Generator.next (<anonymous>)

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

Okay, do other dataview blocks work fine inside admonitions?

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

I cannot find any error in your code, it might actually be an issue with admonitions

from obsidian-charts.

wychwitch avatar wychwitch commented on June 26, 2024

Okay, do other dataview blocks work fine inside admonitions?

Yes they do actually! I just ran a quick test with wrapping dv.header(2, "test") in an admonition block.

I cannot find any error in your code, it might actually be an issue with admonitions

Interesting! I'll open an issue on its page then and update if I make any more progress. Thank you!

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

Does it work now?

from obsidian-charts.

wychwitch avatar wychwitch commented on June 26, 2024

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)

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

Please check with the new Update

from obsidian-charts.

wychwitch avatar wychwitch commented on June 26, 2024

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!

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

image
It is now working for me. Does the error still occur on your End?

from obsidian-charts.

phibr0 avatar phibr0 commented on June 26, 2024

Ah, no I forgot this Issue has to do with the dataview api..

from obsidian-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.