Giter Club home page Giter Club logo

radar-chart-d3's Introduction

Radar Chart

A reusable radar chart implementation in D3.js. Styleable, configurable and transition-capable.

Radar Example

Usage

Install

bower install [email protected]:alangrafu/radar-chart-d3.git --save

Data structure

var data = [
  {
    className: 'germany', // optional, can be used for styling
    axes: [
      {axis: "strength", value: 13, yOffset: 10},
      {axis: "intelligence", value: 6},
      {axis: "charisma", value: 5},  
      {axis: "dexterity", value: 9},  
      {axis: "luck", value: 2, xOffset: -20}
    ]
  },
  {
    className: 'argentina',
    axes: [
      {axis: "strength", value: 6},
      {axis: "intelligence", value: 7},
      {axis: "charisma", value: 10},  
      {axis: "dexterity", value: 13},  
      {axis: "luck", value: 9}
    ]
  }
];

xOffset and yOffset are optional values that allows a developer to change the position of a specific label. It is important to add them in the first group of axes.

Simple single chart drawing

<div class="chart-container"></div>
<script>
RadarChart.draw(".chart-container", data);
</script>

D3.js reusable chart API

var chart = RadarChart.chart();
var svg = d3.select('body').append('svg')
  .attr('width', 600)
  .attr('height', 800);

// draw one
svg.append('g').classed('focus', 1).datum(data).call(chart);

// draw many radars
var game = svg.selectAll('g.game').data(
  [
    data,
    data,
    data,
    data
  ]
);
game.enter().append('g').classed('game', 1);
game
  .attr('transform', function(d, i) { return 'translate(150,600)'; })
  .call(chart);

Style with CSS

.radar-chart .area {
  fill-opacity: 0.7;
}
.radar-chart.focus .area {
  fill-opacity: 0.3;
}
.radar-chart.focus .area.focused {
  fill-opacity: 0.9;
}
.area.germany, .germany .circle {
  fill: #FFD700;
  stroke: none;
}
.area.argentina, .argentina .circle {
  fill: #ADD8E6;
  stroke: none;
}

Configure

// retrieve config
chart.config();
// all options with default values
chart.config({
  containerClass: 'radar-chart', // target with css, the default stylesheet targets .radar-chart
  w: 600,
  h: 600,
  factor: 0.95,
  factorLegend: 1,
  levels: 3,
  maxValue: 0,
  minValue: 0,
  radians: 2 * Math.PI,
  color: d3.scale.category10(), // pass a noop (function() {}) to decide color via css
  axisLine: true,
  axisText: true,
  circles: true,
  radius: 5,
  open: false,  // whether or not the last axis value should connect back to the first axis value
                // if true, consider modifying the chart opacity (see "Style with CSS" section above)
  axisJoin: function(d, i) {
    return d.className || i;
  },
  tooltipFormatValue: function(d) {
    return d;
  },
  tooltipFormatClass: function(d) {
    return d;
  },
  transitionDuration: 300
});

Example

###CSV2Radar

Display a csv file as a radar chart at http://alangrafu.github.io/radar-chart-d3/csv2radar.html.

Example http://bl.ocks.org/tpreusse/2bc99d74a461b8c0acb1

radar-chart-d3's People

Contributors

alangrafu avatar davidemontersino avatar dfernandez79 avatar kanakiyajay avatar kidwm avatar martijnrusschen avatar michalgm avatar nikgraf avatar seeyoung avatar tianon avatar tuukka avatar yosifkit 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

radar-chart-d3's Issues

Transition / Update

Is there an existing method for updating data, and transitioning the SVG polygon to the new position? Thanks!

add margin config

you do nice job!
In my opinion , I would add svg margin config so that the text wouldn't be hidden when overflow.
radar-chart.js line 69: return (p < 0.4) ? "start" : ((p > 0.6) ? "end" : "middle");
should be: return (p < 0.4) ? "end" : ((p > 0.6) ? "start" : "middle");
forgive my poor english and doesn't express my thounght clearly.

it can not be installed

bower radar-chart-d3#*      not-cached [email protected]:alangrafu/radar-chart-d3.git#*
bower radar-chart-d3#*         resolve [email protected]:alangrafu/radar-chart-d3.git#*
bower radar-chart-d3#*         ECMDERR Failed to execute "git ls-remote --tags --heads [email protected]:alangrafu/radar-chart-d3.git", exit code of #128 Host key verification failed. fatal: Could not read from remote repository.  Please make sure you have the correct access rights and the repository exists.

Module is not defined

After last commit I have that error in console. I using that as a bower dependancy so I thing that will be nice to check if module exists.

Angular 4 support

Can you please tell me how to import it in angular 4 project, inside any .ts file ?

also, its not suppoting latest D3 js i.e. d3.v4.min.js, its throws lots of error with this d3 version !! could you please help ?

Is there a way to specify a label for a given value

First of all, thanks, your lib is great.
I'd like to know if it is possible to add a custom label on mouseover.

Taking an example, it would be :

d = [
     [
           {axis: "strength", value: 13, mylabel: "Congratulations"}, 
           {axis: "intelligence", value: 1, mylabel: "So bad"}, 
           {axis: "charisma", value: 8, mylabel: "Not that bad"},  
           {axis: "dexterity", value: 4, mylabel: "Some efforts are needed"},  
           {axis: "luck", value: 9, mylabel: "Not that bad"}
          ]
];

Is that possible? On the roadmap ? Easy to implement ?

Thanks for your reply

Axis label is ignored for all but first elements of "data"

If the order of elements in data.axes differs (i.e. strength and luck are swapped in data[0] relative to data[1]), the rendered radar chart is inaccurate (order is taken into account over the axis specification, and the order that is used is that of the first element, data[0] in this case). Either the documentation should change to say that you must consistently sort your axes, or this is a bug. I can submit a reproduced bug, but this description should suffice as its pretty straightforward.

var data = [
  {
    className: 'germany', // optional can be used for styling
    axes: [
      {axis: "luck", value: 2}
      {axis: "intelligence", value: 6}, 
      {axis: "charisma", value: 5},  
      {axis: "dexterity", value: 9},  
      {axis: "strength", value: 13}, 
    ]
  },
  {
    className: 'argentina',
    axes: [
      {axis: "strength", value: 6}, 
      {axis: "intelligence", value: 7}, 
      {axis: "charisma", value: 10},  
      {axis: "dexterity", value: 13},  
      {axis: "luck", value: 9}
    ]
  }
];

Thanks for an excellent library! I really appreciate it. Hope my comment is able to help you improve it.

Ie9 compatibility

Is there the possibility to make it run also on IE (9) ?

With ie9 the example page don't work at all, and on my website my chart (just 1 series of 5 points) has only the dots and not the filled line.... while in chrome it's ok

with the developer tools the console error message on my website is
SVG4602: SVG Path data has incorrect format and could not be completely parsed (i translated it in english,it was " SVG4602: Impossibile analizzare completamente l'elenco di punti SVG perché ha un formato non corretto." , but searching the original italian language message or its error code in google doesn't find anything)

for information, my code is:

<div id="level">

  <div id="chart" style="width:200px;height:200px;"></div>
<script src="{T_THEME_PATH}/d3/d3.min.js"></script>
<script src="{T_THEME_PATH}/radar/radar-chart-min.js"></script>
</div>
<script>
var d = [
          [
           {axis: "strength", value: 5}, 
           {axis: "intelligence", value: 4}, 
           {axis: "charisma", value: 3},  
           {axis: "dexterity", value: 2},  
           {axis: "luck", value: 1}
          ]
        ];

var options = { w:200, h:200};

RadarChart.draw("#chart", d, options);
</script>

However, good job!

More info: if you put the document in "ie9 standard mode", from the ie9 shift-F12 dev console , also the example page http://graves.cl/radar-chart-d3/ behaves like my web page, in both errors and visualization).

Use tags to release different bower versions

Is it possible to create tags for every version release? Without tags it is not possible to define a specific version in bower when trying to install this repo.

I reuse this radar chart implementation in one of my projects, but every time I update/install the bower dependencies, the latest changes of this repo are fetched and I must (eventually) adopt my code to those changes. With tags and releases I could implement against a strict version and can decide on myself when to upgrade to the next version.

change data by clicking

Is it possible to change the data by click the point , so that I can change the shape of the polygon.

Show all point values

Thanks for this awesome lib,
I'd like to show all the point values by default instead of only showing them when hovering.
I've been searching through the code and looked online for suggestions but cannot find anything.

Can you just point me towards the location of where this would be modified for my use?

Thanks in advance!

Hover over nodes

Is there a way to custom the hoverover event for the nodes?
e.g. hover a node to show html tooltip with clickable links

thanks,
Lucy

[Bug]Latest Radar Chart Demo on IE 9.0-The second chart doesn't show

Hi,
In console(Only in IE 9 ),
here is the error infomation :

SCRIPT87: Invalid argument.
d3.v3.min.js, line 2 character 28443

More detail :
wa.setProperty=function(n,t,e){Sa.call(this,n,t+"",e)}}

this funcition throws this error.

Could you help me to check this problem ?

Thank you very much for your time!

Steven Lee

[enhancement] Add missing bower.json.

Hey, maintainer(s) of alangrafu/radar-chart-d3!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library alangrafu/radar-chart-d3 is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "alangrafu/radar-chart-d3",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

The "axisText" position puzzled me.

I adjust the size of radar chart when the label text hideen by the svg edge.How to custermize each point (dx ,dy)? Could you give me a sample code list?Thanks a lot.

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.