Kaynağa Gözat

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

master
Garrick Aden-Buie 6 yıl önce
ebeveyn
işleme
d114592668
2 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  1. +1
    -0
      dev/dev.Rmd
  2. +4
    -1
      inst/htmlwidgets/frappeChart.js

+ 1
- 0
dev/dev.Rmd Dosyayı Görüntüle

To make this work we will: To make this work we will:


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

+ 4
- 1
inst/htmlwidgets/frappeChart.js Dosyayı Görüntüle



// TODO: define shared variables for this instance // 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 // helper function to prep the data
const prepareChartData = function(data) { const prepareChartData = function(data) {
const chartData = {labels: [], datasets: []} const chartData = {labels: [], datasets: []}
renderValue: function(x) { renderValue: function(x) {
x.data = prepareChartData(x.data) x.data = prepareChartData(x.data)


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


resize: function(width, height) { resize: function(width, height) {

Yükleniyor…
İptal
Kaydet