You can get it here:
https://gitlab.com/dvenkatsagar/reveal-chart
Reveal.initialize({
dependencies : [
// Chart.min.js
{ src: 'plugin/chartjs/Chart.min.js'},
// the plugin
{ src: 'plugin/chartjs/charted.js'}
]
});
Note: Press down arrow for more info.
Step 1 : In the <section> tag, add an iframe in this format:
<section>
<iframe id="some-selector" data-chart></iframe>
</section>
Step 2 : In the Reveal.initialize function, add an option "chart" like this:
Reveal.initialize({
chart : {
path : "" // Optional path to Chart.js
items : [
{
// selector must be iframe id,
selector : "#some-selector",
// type can be pie/doughtnut/line/bar/radar/polararea
type : "",
// The chart data can also be [], check chartjs docs
data : {},
// The chart options, check chartjs docs
options : {},
// optional
canvas : {
// width of iframe -> canvas element.
// default : 250px
width : "",
// height of iframe -> canvas element.
// default : 150px
height : ""
}
}
]
}
});
Note : "canvas" property in the "chart" option is optional.
Reveal.initialize({
chart : {
// Taken from chartjs documentation
items : [
{
selector : "#chart-frame-1",
type : "line",
data : {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
},
options : {
responsive:true
}
}
]
}
});
Reveal.initialize({
chart : {
// Taken from chartjs documentation
items : [
{
selector : "#chart-frame-2",
type : "bar",
data : {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
},
options : {
responsive : true
}
}
]
}
});
Reveal.initialize({
chart : {
// Taken from chartjs documentation
items : [
{
selector : "#chart-frame-3",
type : "bar",
data : {
labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 90, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 96, 27, 100]
}
]
},
options :{
responsive : true,
pointLabelFontSize : 15
}
}
]
}
});
Reveal.initialize({
chart : {
// Taken from chartjs documentation
items : [
{
selector : "#chart-frame-4",
type : "polararea",
data : [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 40,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
],
options : {
responsive : true
}
}
]
}
});
Reveal.initialize({
chart : {
// Taken from chartjs documentation
items : [
{
selector : "#chart-frame-5",
type : "pie",
data : [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
}
],
options : {
responsive : true
}
}
]
}
});
Reveal.initialize({
chart : {
// Taken from chartjs documentation
items : [
{
selector : "#chart-frame-6",
type : "doughnut",
data : [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
}
],
options : {
percentageInnerCutout : 50,
responsive : true
}
}
]
}
});
The "RevealChart" variable collects the information about all the charts when changing slides.
Add some functionality after the Reveal.initialize function like this for example:
Reveal.addEventListener("slidechanged",function(){
setTimeout(function(){ // Timeout required to load the plugin
// the RevealChart has iframe ids as properties
// (replacing "-" with "_")
console.log(RevealChart);
},500);
},false);
For good results:
Chart.defaults.global.responsive = true;
<iframe class="stretch" id="chart-frame" data-chart></iframe>