Raphy Charts
Beautiful HTML5/SVG Charts with sane defaults for all browsers,
including Internet Explorer. Built on Raphael.js & Apache 2 Licensed
<!--
Raphael.js is required to use Raphy Charts. For a quick install use these scripts.
Note you have to download them, not link directly from raw.github.com:
-->
<script src="https://raw.github.com/DmitryBaranovskiy/raphael/master/raphael-min.js"></script>
<script src="https://raw.github.com/jcarver989/raphy-charts/master/compiled/charts.min.js"></script>
Line Chart The granddaddy of all charts. Time series data and multi-axis lines supported out of the box
| Action |
Total |
Sparkline |
| Visitors |
500k |
|
| Signups |
250k |
|
| Conversions |
10k |
|
Usage
First, initialize the chart
<!-- Assuming this Div exists somewhere on the page: (width & height MUST be set) -->
<div id='chart1' style='width: 300px; height: 100px;'></div>
// Can pass in the id
var chart = new Charts.LineChart('chart1');
// Or the DOM node
var node = document.getElementById('chart1');
var chart = new Charts.LineChart(node);
// If you want to override default options
var chart = new Charts.LineChart('chart1', {
show_grid: false,
label_max: false,
label_min: false
});
Then add some lines
// Data is an array of arrays where the first slot is the x label and the 2nd the (y) value to graph
chart.add_line({
data: [[1, 828906],[2, 566933],[3, 584150],[4, 1072143],[5, 1622455],[6, 2466746],[7, 2427789]]
});
// Line charts also support custom tooltips, eg:
chart.add_line({
data: [[1, 828906, {tooltip: "my special point"}],[2, 566933],[3, 584150],[4, 1072143],[5, 1622455],[6, 2466746],[7, 2427789]]
});
// x Labels can also be dates, making time series charts easy
var day1 = new Date(d.getFullYear(), d.getMonth(), 1);
var day2 = new Date(d.getFullYear(), d.getMonth(), 2);
chart.add_line({
data: [[day1, 828906],[day2, 566933]],
// line level options passed here
options: {
line_color: "#00aadd"
}
});
Finally Draw the Chart
chart.draw();
Complete Example
A MultiAxis Chart With Gradient Fill
var multi_axis = new Charts.LineChart('multiaxis', {
show_grid: true,
show_y_labels: true,
label_max: false,
label_min: false,
multi_axis: true,
max_y_labels: 4,
x_padding: 45
});
multi_axis.add_line({
data: [[1, 828906],[2, 566933],[3, 584150],[4, 1072143],[5, 1622455],[6, 2466746],[7, 2427789]],
options: {
line_color: "#00aadd",
dot_color: "#00aadd",
area_color: "230-#88c9dd-rgba(255,255,255,0)",
area_opacity: 0.2,
dot_size: 5,
line_width: 4
}
});
multi_axis.add_line({
data: [[1, 305],[2, 336],[3, 378],[4, 449],[5, 635],[6, 935],[7, 782]],
options: {
line_color: "#ffee33",
dot_color: "#ffee33",
fill_area: false,
line_width: 2,
dot_size: 3
}
});
multi_axis.draw()
Line Chart Options
Chart
| Type |
Option |
Description |
Default |
Chart/Line |
| boolean |
show_grid |
render a background grid |
true |
chart only |
| boolean |
multi_axis |
render chart with 2 y axes |
false |
chart only |
| number |
x_padding |
how much to pad the x-axis (px) |
45 |
chart only |
| number |
y_padding |
how much to pad the y-axis |
40 |
chart only |
| array |
y_axis_scale |
force the y-axis range, eg. [0, 100] |
inferred |
chart only |
Dots
| Type |
Option |
Description |
Default |
Chart/Line |
| number |
dot_size |
size of dots |
5 |
both |
| css-color |
dot_color |
color of dots |
"#00aadd" |
both |
| css-color |
dot_stroke_color |
color of dot border |
"#fff" |
both |
| number |
dot_stroke_size |
size of dot border |
2 |
both |
Lines
| Type |
Option |
Description |
Default |
Chart/Line |
| number |
line_width |
width of line |
3 |
both |
| css-color |
line_color |
color of line |
"#00aadd" |
both |
| number |
smoothing |
0.0 to 1.0, 0 = no smoothing, 1.0= ultra smoothing |
0.4 |
both |
| boolean |
fill_area |
shade the area under a line |
true |
both |
| css-color |
area_color |
color of area under a line |
"#00aadd" |
both |
| number |
area_opacity |
0.0 to 1.0 opacity of shading under a line |
0.2 |
both |
Bars (for bar time series instead of a line)
| Type |
Option |
Description |
Default |
Chart/Line |
| string |
render |
"bar" or "line" |
"line" |
chart only |
| number |
bar_width |
width of bars (px) |
20 |
both |
Labels
| Type |
Option |
Description |
Default |
Chart/Line |
| boolean |
show_x_labels |
display x axis labels |
true |
chart only |
| boolean |
show_y_labels |
show y axis labels |
true |
chart only |
| boolean |
label_max |
label max point of line with tooltip |
true |
both |
| boolean |
label_min |
label min point of line with tooltip |
true |
both |
| number |
max_x_labels |
max number of x axis labels to show |
10 |
chart only |
| number |
max_y_labels |
max number of y axis labels to show |
3 |
chart only |
| number |
x_label_size |
size of x labels (pixels) |
14 |
chart only |
| number |
y_label_size |
size of y labels (pixels) |
14 |
chart only |
| string |
font_family |
which font to use |
"Helvetica, Arial, sans-serif" |
chart only |
| number |
label_format |
format string for date labels |
"%m%d" |
Label Formatting Macros
- %m - month (1-12)
- %d - date (1-31)
- %Y - year (eg. 2011)
- %H - hours (0-24)
- %I - hours (1-12)
- %p - am/pm indicator
- %M - minutes (0-59)
Example: label_format: "%m/%d/%Y" -> "11/05/2011"
Point Options (eg chart.add_line([[1,2, {tooltip: "foo"}]])
| Type |
Option |
Description |
Default |
| boolean |
no_dot |
don't render a dot + tooltip on this point |
false |
| boolean |
show_dot |
show dot + tooltip as active on page load |
false |
| string |
tooltip |
custom tooltip label on a particular point |
the point's y value |
Bar Chart Your standard bar charts with all the fixin's
Usage
First, initialize the chart
<!-- Assuming this Div exists somewhere on the page: (width & height MUST be set) -->
<div id='chart1' style='width: 300px; height: 100px;'></div>
// Can pass in the id
var chart = new Charts.BarChart('chart1');
// Or the DOM node
var node = document.getElementById('chart1');
var chart = new Charts.BarChart(node);
// If you want to override default options
var chart = new Charts.BarChart('chart1', {
show_grid: false,
label_max: false,
label_min: false
});
Then add some bars
chart.add({
label: "doo",
value: 300
});
chart.add({
label: "moo",
value: 800,
options: {
bar_color: "#53ba03"
}
});
Finally draw the chart
chart.draw();
Complete Example
var bars = new Charts.BarChart('barchart', {
x_label_color: "#333333",
bar_width: 45,
rounding: 10,
});
bars.add({
label: "foo",
value: 600
});
bars.add({
label: "moo",
value: 800,
options: {
bar_color: "#53ba03"
}
});
bars.add({
label: "doo",
value: 300
});
bars.draw();
Bar Chart Options
Chart
| Type |
Option |
Description |
Default |
Chart/Bar |
| boolean |
show_grid |
render a background grid |
false |
chart only |
| boolean |
show_x_labels |
display bar labels |
true |
chart only |
| boolean |
show_y_labels |
display bar values |
true |
chart only |
| number |
x_label_size |
size of bar labels |
14 |
chart only |
| number |
y_label_size |
size of bar values |
14 |
chart only |
| css-color |
x_label_color |
color of bar label |
#333 |
chart only |
| css-color |
y_label_color |
color of bar values |
#333 |
chart only |
| number |
x_padding |
how much to pad the x-axis (px) |
25 |
chart only |
| number |
y_padding |
how much to pad the y-axis (px) |
40 |
chart only |
| string |
font_family |
font stack to use for the labels |
font_family: "Helvetica, Arial, sans-serif" |
chart only |
Bars
| Type |
Option |
Description |
Default |
Chart/Bar |
| number |
bar_width |
width of the bars |
20 |
both |
| number |
bar_spacing |
how far apart to place bars |
20 |
both |
| css-color |
bar_color |
color of the bar's fill |
#00aadd |
both |
| number |
rounding |
how much to round the bars (0 makes square bars) |
0 |
both |
Bullet Charts When you need more than a simple bar chart
Bullet Charts are still being developed, it's not recommended for use (yet) as there aren't labels for the values.
Index Chart A specialized chart to show you how well you track against an index
Usage
First, initialize the chart
<!-- Assuming this Div exists somewhere on the page: (width & height MUST be set) -->
<div id='chart1' style='width: 300px; height: 100px;'></div>
// Can pass in the id
var chart = new Charts.IndexChart('chart1');
// Or the DOM node
var node = document.getElementById('chart1');
var chart = new Charts.IndexChart(node);
// If you want to override default options
var chart = new Charts.IndexChart('chart1', {
rounding: 10
});
Then add some bars
// add(*Label*, *raw value*, *index score*)
// index score of 100 == average
chart.add("Retail", 18316, 65);
chart.add("IT Software",28977,1331);
chart.add("Engineering/Technical",28977,282);
Then add the guider (dotted) lines
// add_guide_line(*Label*, *index value*, *opacity*)
// index score of 100 == average
chart.add_guide_line("Average", 100, 1)
chart.add_guide_line("Above Average", 500, 0.25)
chart.add_guide_line("High", 1000, 0.25)
Label the Raw Values
index.add_raw_label("Uniques")
Finally, draw the chart
chart.draw();
Complete Example
var node = document.getElementById('indexchart');
var index = Charts.IndexChart(node);
index.add("Retail",18316,65)
index.add("IT Software",28977,1331)
index.add("Engineering/Technical",28977,282)
index.add("Education",20839,106)
index.add("Media & Internet",22488,92)
index.add("Business Services",19397,85)
index.add_guide_line("Average", 100, 1)
index.add_guide_line("Above Average", 500, 0.25)
index.add_guide_line("High", 1000, 0.25)
index.draw()
Index Chart Options
Chart
| Type |
Option |
Description |
Default |
| number |
x_padding |
left hand x padding |
160 |
| number |
x_padding_right |
right hand x padding |
100 |
| number |
y_padding |
y padding |
50 |
| number |
label_size |
size of labels |
14 |
| string |
font_family |
font stack to use |
Helvetica, Arial, sans-serif |
| number |
dash_width |
how thick to draw guider lines |
3 |
Bars
| Type |
Option |
Description |
Default |
| number |
bar_margin |
spacing between bars |
30 |
| css-color |
bar_bg_color |
background color of bar |
#bdced3 |
| css-color |
bar1_color |
color of bar when lower than 100 index |
90-#2f5e78-#4284a8 |
| css-color |
bar2_color |
color of bar when higher than 100 index |
90-#173e53-#225d7c |
| css-color |
raw_value_bar_color |
color of bar displaying the raw values |
9eb7bf |
| number |
rounding |
how much to round the bars (0 makes square bars) |
3 |
| number |
bg_bar_padding |
controls how big the background bar is relative to its contents (px) |
14 |
Progress Chart A chart widget to show a percentage of total
Usage
First, initialize the chart
<!-- Assuming this Div exists somewhere on the page: (width & height MUST be set) -->
<div id='chart1' style='width: 300px; height: 100px;'></div>
// Can pass in the id
// constructor parameters: *dom_id OR node*, *label*, *percentage value*
var chart = new Charts.CircleProgress('chart1', 'Sales', 80);
// Or the DOM node
var node = document.getElementById('chart1');
var chart = new Charts.CircleProgress(node, 'Sales', 80);
// If you want to override default options
var chart = new Charts.CircleProgress('chart1', 'Sales', 80, {
fill_color: "#222"
});
Then draw the chart
chart.draw();
Complete Example
var progress1 = new Charts.CircleProgress(
'progress-1',
'Sales',
80,
{
font_color: "#fff",
fill_color: "#222",
label_color: "#333",
text_shadow: "rgba(0,0,0,.4)",
stroke_color: "#6a329e"
});
progress1.draw()
Progress Chart Options
Chart
| Type |
Option |
Description |
Default |
| number |
radius |
radius of circle (how big chart is) |
55 |
| number |
stroke_width |
size of colored indicator on outside of circle |
30 |
| css-color |
fill_color |
color of circle |
#fff |
| css-color |
stroke_color |
color of indicator outside of circle |
#81ae14 |
| css-color |
font_color |
color of font inside circle |
#333 |
| css-color |
label_color |
color of label outside circle |
#333 |
| css-color |
text_shadow |
text shadow on label |
false |
Fly Chart Visualize parts of a whole by clicking on the circles
Usage
First, initialize the chart
<!-- Assuming this Div exists somewhere on the page: (width & height MUST be set) -->
<div id='chart1' style='width: 300px; height: 100px;'></div>
// Can pass in the id
var chart = new Charts.PathMenu('chart1');
// Or the DOM node
var node = document.getElementById('chart1');
var chart = new Charts.PathMenu('chart1');
// If you want to override default options
var chart = new Charts.PathMenu('chart1', {
bounce_radius: 1.5
});
Add some items
menu.add({
label: "Software",
value: 5000,
children: [
{ label: "Cloud Based", value: 1500 },
{ label: "OEM Based", value: 1500 },
{ label: "Gaming", value: 2000 }
]
})
menu.add({
label: "Food",
value: 400,
children: [
{ label: "Groceries", value: 100 },
{ label: "Restaurants", value: 150 },
{ label: "Snacks", value: 150 }
]
})
menu.add({
label: "Movies",
value: 1500,
children: []
});
Then draw the chart
chart.draw();
Complete Example
var menu = new Charts.PathMenu("fly-1", {});
menu.add({
label: "Manufacturing",
value: 3000,
children: [
{ label: "Automobiles", value: 1500 },
{ label: "Aerospace", value: 1500 },
]
});
menu.add({
label: "Software",
value: 5000,
children: [
{ label: "Cloud Based", value: 1500 },
{ label: "OEM Based", value: 1500 },
{ label: "Gaming", value: 2000 }
]
})
menu.add({
label: "Food",
value: 400,
children: [
{ label: "Groceries", value: 100 },
{ label: "Restaurants", value: 150 },
{ label: "Snacks", value: 150 }
]
})
menu.add({
label: "Movies",
value: 1500,
children: []
});
menu.add({
label: "Consumer Electronics",
value: 1500,
children: []
});
menu.add({
label: "Real Estate",
value: 1500,
children: []
});
menu.add({
label: "Commercial Banking",
value: 1500,
children: []
});
menu.draw();
Options
| Type |
Option |
Description |
Default |
| number |
main_circle_radius |
size of main menu circle |
70 |
| number |
child_radius_multiplier |
size of children relative to their parent |
0.15 |
| number |
hover_scale_multiplier |
how much bigger items become on mouseover |
1.2 |
| number |
outer_radius_multiplier |
how far 1st level menu items appear from their parent |
1.35 |
| number |
outer_radius2_multiplier |
how far 2st level menu items appear from their parent |
1.5 |
| number |
bounce_radius |
how much menu items "bounce" in animation |
1.2 |
| number |
inactive_opacity |
opacity of inactive (unopened items) |
0.4 |
| css-color |
fill_color |
color of circles |
#00a6dd |