Setting the order in d3plus stacked area plot -


how can set ordering of areas in stacked area plot in d3plus?

i use following example http://d3plus.org/examples/basic/9029462/:

<script>   // sample data array   var sample_data = [     {"year": 1993, "name":"alpha", "value": 20},     {"year": 1994, "name":"alpha", "value": 30},     {"year": 1995, "name":"alpha", "value": 60},     {"year": 1993, "name":"beta", "value": 40},     {"year": 1994, "name":"beta", "value": 60},     {"year": 1995, "name":"beta", "value": 10},     {"year": 1994, "name":"gamma", "value": 10},     {"year": 1995, "name":"gamma", "value": 40}   ]   // instantiate d3plus   var visualization = d3plus.viz()     .container("#viz")  // container div hold visualization     .data(sample_data)  // data use visualization     .type("stacked")    // visualization type     .id("name")         // key our data unique on     .text("name")       // key use display text     .y("value")         // key use y-axis     .x("year")          // key use x-axis     .time("year")       // key use time     .draw()             // finally, draw visualization! </script> 

the ordering gamma, beta, alpha. how can make custom ordering?

i tried .order({'value': ['beta', 'alpha', 'gamma']} without effect. .order({'sort': 'asc'}) works. again, .order({'agg': 'min'}) (which should yield gamma, alpha, beta) doesn't work either.

i had similar issue stacked bar chart. think it's bug in d3plus. change x-axis field (in case 'year') string field instead of integer. ordering might start working.

e.g. {"year": "1993", "name":"alpha", "value": 20}


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -