- type:
array of object
each object has same key
example:
[{
"date": "04/23/12",
"Group1": "-20",
"Group2": "12",
"Group3": "46"
}, {
"date": "04/24/12",
"Group1": "32",
"Group2": "-20",
"Group3": "24"
}]
- type:
function
parsed data function
- type:
array of object
- field:
required
, define the data field - name:
optional
, the show name of this data. default is the same with field. - color:
optional
, show categorical color
example:
[{
field: "Group1",
name: "Group 1",
color: "red"
},
{
field: "Group2",
name: "Group 2",
color: "black"
}]
- type: string
the title of the graph
- type: int
- default:
960
the width of the graph
- type: int
- default:
500
the height of the graph
- type: object
- default:
{top: 80, right: 100, bottom: 80, left: 100}
margins of the graph
-
type: stirng
-
default :
null
please reference d3 interpolate
- type: boolean
- default:
true
- type: boolean
- default:
true
- type: boolean
- default:
true
- type: boolean
- default:
true
- type: boolean
- default:
true
- default:
d3.scale.category10()
you must send one of the d3 categorical colors. reference
- type: string
- default:
null
- type: string
- default:
null
- type: string
- default:
null
- type: string
- default:
null
- type: string
- default:
null
"use strict";
var React = require('react');
var Chart = require('react-d3-core').Chart;
var PieChart = require('react-d3-basic').PieChart;
(function() {
var generalChartData = require('dsv?delimiter=,!./data/age_pie.csv')
var width = 960,
height = 500,
radius = Math.min(width, height - 120) / 2,
margins = {top: 50, right: 50, bottom: 20, left: 50},
id = "test-chart",
title = "Pie Chart",
svgClassName = "test-chart-class",
titleClassName = "test-chart-title-class",
legendClassName = "test-legend",
showLegend = true,
value = function(d) {
return +d.population;
},
name = function(d) {
return d.age;
},
chartSeries = [
{
"field": "<5",
"name": "less than 5"
},
{
"field": "5-13",
"name": "5 to 13"
},
{
"field": "14-17",
"name": "14 to 17"
},
{
"field": "18-24",
"name": "18 to 24"
},
{
"field": "25-44",
"name": "25 to 44"
},
{
"field": "45-64",
"name": "45 to 64"
}
],
legendPosition = 'right',
outerRadius = radius - 10,
innerRadius = 0;
React.render(
<Chart
title={title}
id={id}
width={width}
height={height}
>
<PieChart
title= {title}
data= {generalChartData}
width= {width}
height= {height}
radius= {radius}
id= {id}
margins= {margins}
chartSeries= {chartSeries}
svgClassName= {svgClassName}
titleClassName= {titleClassName}
legendClassName= {legendClassName}
legendPosition= {legendPosition}
categoricalColors= {d3.scale.category10()}
showLegend= {showLegend}
value = {value}
name = {name}
outerRadius= {outerRadius}
innerRadius= {innerRadius}
pieSort = {d3.descending}
/>
</Chart>
, document.getElementById('data_pie')
)
})()