Przeglądaj źródła

make the created `chart` object available outside `renderValue()`

master
Garrick Aden-Buie 6 lat temu
rodzic
commit
d114592668
2 zmienionych plików z 5 dodań i 1 usunięć
  1. +1
    -0
      dev/dev.Rmd
  2. +4
    -1
      inst/htmlwidgets/frappeChart.js

+ 1
- 0
dev/dev.Rmd Wyświetl plik

@@ -501,3 +501,4 @@ where `data` is the `data` part of the initial options object.
To make this work we will:

1. refactor the JS-side data processing code
1. make the created `chart` object available outside `renderValue()`

+ 4
- 1
inst/htmlwidgets/frappeChart.js Wyświetl plik

@@ -8,6 +8,9 @@ HTMLWidgets.widget({

// TODO: define shared variables for this instance

// we'll create chart in renderValue but want to access it elsewhere
let chart = null

// helper function to prep the data
const prepareChartData = function(data) {
const chartData = {labels: [], datasets: []}
@@ -31,7 +34,7 @@ HTMLWidgets.widget({
renderValue: function(x) {
x.data = prepareChartData(x.data)

const chart = new frappe.Chart(el, x)
chart = new frappe.Chart(el, x)
},

resize: function(width, height) {

Ładowanie…
Anuluj
Zapisz