Skip to content
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

setTimeout with clusters problematic with programmatic edits and no callback #133

Closed
timelyportfolio opened this issue Mar 9, 2015 · 2 comments

Comments

@timelyportfolio
Copy link

This is selfish, but with our R htmlwidget, we need to render each diagram one by one rather than the total sweep behavior expected by mermaid. Due to this, the internal counter i will result in duplicated id for mermaidChart*, so we change the id. We love the new cluster ability, but in these lines, the setTimeout will multiple diagrams on a page causes trouble even if we set our timeout > 20. I'm not a JavaScript pro, but I think this can be handled without negative consequence by very gently changing the setTimeout in the lines referenced above to be.

    setTimeout(function(el){
        debugger;
        var i = 0;
        subGraphs.forEach(function(subG){

            var clusterRects = el.querySelectorAll('.clusters rect');
            var clusters     = el.querySelectorAll('.cluster');


            if(subG.title !== 'undefined'){
                var xPos = clusterRects[i].x.baseVal.value;
                var yPos = clusterRects[i].y.baseVal.value;
                var width = clusterRects[i].width.baseVal.value;
                var cluster = d3.select(clusters[i]);
                var te = cluster.append('text');
                te.attr('x', xPos+width/2);
                te.attr('y', yPos +14);
                te.attr('fill', 'black');
                te.attr('stroke','none');
                te.attr('id', id+'Text');
                te.style('text-anchor', 'middle');
                te.text(subG.title);
            }
            i = i + 1;
        });
    }(svg[0][0]),20);
};

Thanks so much for your incredible package. It is gaining quick traction in the R community with our DiagrammeR htmlwidget wrapper.

@knsv
Copy link
Collaborator

knsv commented Mar 10, 2015

Glad to hear that. Perhaps this pullrequest made by @bollwyvl is what you need:
#135

This was merged just now.

@knsv
Copy link
Collaborator

knsv commented Jun 7, 2015

I am closing issues and see this one as closed. As part of release 0.5.0 the rendering of clustering was updated and the timeout has been removed.

Let me know if you feel differently!

@knsv knsv closed this as completed Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants