Git Product home page Git Product logo

viz's Introduction

viz's People

Contributors

npashap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

viz's Issues

Is there any way to set the 'width' & 'height' of viz.chord?

In the demo as below, it seems chord has default 'width' and 'height'. Setting the width and height of 'svg' cannot take effect. The result diagram still in 'fixed' size. Is there any way to change the size of chord? Thanks!

<script> //... var chord = viz.chord() .data(getData()) .source(function(d){ return d[1]}) .target(function(d){ return d[0]}) .value(function(d){ return d[2]/1000}) d3.select("g").call(chord); </script>

NPashaP -- contract work available?

Sorry, didn't know how else to contact you. We're interested in using your Chord visualization, and would like to contract with you to make some (hopefully) minor enhancements. Please let me know if interested.

Is it possible to add multiple layers of bars as an extension of biPartite graph, similar to Sankey chart?

The bipartite graph is really beautiful, unfortunately it can't fit my use case. I wish 1. being able to add multiple levers of bars, 2. currently bar height's calculation is under assumption of flow conservation, sometimes the flow conservation may not hold as in my case, I'd like to have the option to define bar height (similar to node weight) independently rather than inferred as sum of inputs or outputs, 3. when mouseover on a bar part, is it possible to just highlight related links, and don't focus related bar parts and re-scale those parts. Just wanna know if these things are in your roadmap?

Sample Code for Using Color Scales

Would you kindly provide sample code for using color scales with your biPartite layout.

For example, changing from:

var color = {Elite:"#3366CC", Grand:"#DC3912", Lite:"#FF9900", Medium:"#109618", Plus:"#990099", Small:"#0099C6"};

to:

var color = d3.scaleOrdinal(d3.schemeCategory20);

Does not work. What's the trick? Thanks and Great Work!!!

How to add custom fields?

I am using d3 v4. Drawing biPartite - Adding labels Example URL TO Example
My sample data is
var data = [ ['host1', 'Call 1', 524, 'Kb'], ['host2', 'Call 2', 56, 'Kb'], ];
I want this 4th element accessible in a variable e.g "unit"

So far I have declared unit like this

var key_scale, value_scale ,keyPrimary, keySecondary, value, unit ,width, height, orient, barSize, min, pad ,data, fill, g, edgeOpacity, duration ,sortPrimary, sortSecondary, edgeMode ;

added a function in viz.bP like this

bP.unit = function(_){ if(!arguments.length) return typeof unit !== "undefined" ? unit : function(d){ return d[3]; }; value = _; return bP; }

But it is not accessible like other variables like d.part, d.percent, d.value and d.key

I tried to add it into calculateMainBars() function as a key value pair like this

` function calculateMainBars(part){

        function v(d){ return isSelKey(d, part) ? bP.value()(d): 0;};

        var ps = d3.nest()
            .key(part=="primary"? bP.keyPrimary():bP.keySecondary())
            .sortKeys(part=="primary"? bP.sortPrimary():bP.sortSecondary())
            .rollup(function(d){ return d3.sum(d,v); })
            .entries(bP.data());

        var bars = bpmap(ps, bP.pad(), bP.min(), 0, _or=="vertical" ? bP.height() : bP.width());
        var bsize = bP.barSize();
        ps.forEach(function(d,i){
            mainBars[part].push({
                 x:_or=="horizontal"? (bars[i].s+bars[i].e)/2 : (part=="primary" ? bsize/2 : bP.width()-bsize/2)
                ,y:_or=="vertical"? (bars[i].s+bars[i].e)/2 : (part=="primary" ? bsize/2 : bP.height()-bsize/2)
                ,height:_or=="vertical"? (bars[i].e - bars[i].s)/2 : bsize/2
                ,width: _or=="horizontal"? (bars[i].e - bars[i].s)/2 : bsize/2
                ,part:part
                ,key:d.key
                ,unit:d.unit
                ,value:d.value
                ,percent:bars[i].p
            });
        });
    }`

but it is not accessible here.

I know I am missing something very basic but please help me out :)

How to export var data values

Hello, my English is not good

I first used D3.JS, I find it very interesting

I tried using "biPartite" and would like to ask

How do I use the output percentage instead of displaying the value in "var data"?

I tried to modify ".text (function (d) {return d3.format (d.percent)})"

But display object.

d.value doesn't work

Hi.
Thank you for your amazing project.
I found an issue.

I try to use d.value, but d.value is undefined value.
I confirmed source code. LINE 184 ",value:d.value" should be ",value:d.values" .

Update function issue!

This is the graph before update
image
After I click "A" it will update the graph, then
image
This is the code I made for update

`var bp = viz.biPartite()
    .height(580)
    .width(chartContainer.width() - 230)
    .keyPrimary(d=>d.group)
    .keySecondary(d=>d.subgroup)
    .value(d=>d.count)
    .data(data);

g.call(bp);

g.selectAll(".viz-biPartite-mainBar")
    .on("mouseover", mouseover)
    .on("mouseout", mouseout)
    .on("click", mouseClick);
    	
g.selectAll(".viz-biPartite-mainBar")
    .append("text")
    .attr("class","label")
    .attr("x", d => (d.part == "primary" ? -30 : 30))
    .attr("y", d => +6)
    .text(d => d.key)
    .attr("text-anchor", d => (d.part == "primary" ? "end" : "start"));

g.selectAll(".viz-biPartite-mainBar")
    .append("text")
    .attr("class", "perc")
    .attr("x", d => (d.part == "primary" ? -100 : 80))
    .attr("y", d => +6)
    .text(function (d) { return d3.format("0.0%")(d.percent) })
    .attr("text-anchor", d => (d.part == "primary" ? "end" : "start"));

function mouseClick(d){
    childChartsId.forEach( function (data) {
        if(data.group === d.key){
            sendRequest("/api/mongodb/findByID", "data", JSON.stringify(new queryObject("analysis_charts_data", data.chartId)), function (chartsData) {
                // executeFunctionByName(chartsData.functionName, chartsData, $(".resultUserCharts"));
                // g.call(bp.data(chartsData.data));                    
                bp.update(chartsData.data);
            });
        }
    })
}`

Is this a BUG?

d3 version: 4.12.2
viz version: 1.4.0

Thanks!

Remove sort on labels

This is more of question than an actual issue. One of the columns on my bP is a date (MMM-YY, JAN-16 and such). Is there a way to unsort the labels so the order shows up chronologically (because it's a date) and not alphabetically?

Label orientation

(UPDATE: Finally I've solved that problem, if you are interested you can see the changes here)

Hello,

Is there a way to rotate labels, even when it's hover?

Like this:
label-orientation

I'm working in this chart (viz and d3):
viz-chord-diagram

When hover (I'm hiding labels when its value is 0):
hover-viz-chord-diagram

Thank you!!!

Using new data

NPasha great visualization.
How does one update the data. For instance, if I wanted to have the viz change for different years selected?
Thanks

Update doesn't work properly

Pasha,
Thanks for adding the update.
However it only works when the data changes but not the number of connections.

See the example below.
As shown when you run the program, the edges do not update correctly.

<style> .mainBars{ shape-rendering: auto; fill-opacity: 0; stroke-width: 0.5px; stroke: rgb(0, 0, 0); stroke-opacity: 0; } .subBars{ shape-rendering:crispEdges; } .edges{ stroke:none; fill-opacity:0.3; } </style> <script src="https://d3js.org/d3.v4.min.js"></script> <script src="http://vizjs.org/viz.v1.1.1.min.js"></script> <script> var data={ 1:[['A','X', 1] ,['A','Y', 3] ,['B','X', 5] ,['B','Y', 8] ,['C','X', 2] ,['C','Y', 9] ], 2:[['A','X', 5] ,['A','Y', 3] ,['B','X', 10] ,['B','Y', 8] ,['C','X', 2] ,['C','Y', 1] ], 3:[['A','X', 10] ,['B','X', 15] ,['B','Y', 8] ,['C','X', 2] ,['C','Y', 9] ], 4:[['A','X', 1] ,['A','Y', 3] ,['B','X', 5] ,['B','Y', 4] ,['C','X', 2] ,['C','Y', 9] ,['D','X', 19] ,['D','Y', 4] ], 5:[['A','X', 10] ,['A','Y', 13] ,['B','X', 5] ,['B','Y', 18] ,['C','X', 21] ,['C','Y', 9] ] }; var width=960, height=700; var color = {A:"#3366CC", B:"#DC3912", C:"#FF9900"}; //create bp object var i = 1; var bp=viz.bP().data(data[i]).pad(2).fill(d=>color[d.primary]); // create svg and g elements and draw bp on it d3.select("body").append("svg").attr("width", width).attr("height", height) .append("g").attr("transform","translate(250,50)").call(bp); // refresh data every second setInterval(update,5000); function update(){ console.log(data[i]) i = i+1; // reate some random values // data.forEach(function(d){ d[2] =Math.random()*10 ;}); //set the new data and redraw if (i < 5) bp.update(data[i]); else i = 0; } // adjust the bl.ocks frame dimension. d3.select(self.frameElement).style("height", height+"px").style("width", width+"px"); </script>

How to export as an image??

I tried to export as an png image drawing the svg base64 image in a canvas but the drawImage function throw a "Uncaught InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.(anonymous function)"

I made a img and serialize the svg to svg+xml string, and then convert it to base64. this img i pass to canvas.getContext("2d").drawImage function.

this canvas i will export with canvas.toDataUrl.

the same data:image/svg+xml;base64 open nicely in a new tab, like in http://desafio.kayran.com.br/desafio page, but the same data doesnt open im img tag and no open in canvas.

how to solve this issue?

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.