apexcharter/inst/htmlwidgets/apexcharter.js

41 lines
661 B
JavaScript
Raw Normal View History

2018-07-30 22:54:39 +02:00
HTMLWidgets.widget({
name: 'apexcharter',
type: 'output',
factory: function(el, width, height) {
var ax_opts, chart;
return {
renderValue: function(x) {
// Global options
ax_opts = x.ax_opts;
// Sizing
ax_opts.chart.width = width;
ax_opts.chart.height = height;
// Generate chart
chart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
chart.render();
},
resize: function(width, height) {
chart.updateOptions({
chart: {
width: width,
height: height
}
});
}
};
}
});