You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the exact template of your Gauge widget to try to create a histogram widget (.js and .R files below).
The core of the .js file works. If you just paste the whole var chart = c3.generate({...}) statement into http://c3js.org/samples/chart_bar.html, adding the lines
in RStudio, nothing shows. So, I believe that my bindings are at fault, but I couldn't find what's wrong. Could you please have a quick look? Your help would be much appreciated.
If you need to reproduce the error, you can install my fork of C3 with devtools::install_github("tixierae/shinyJsTutorials/tutorials/materials2/C3"). Note that I created a C3Hist.yaml file, and added export(C3Hist);export(C3HistOutput) to the NAMESPACE file.
HTMLWidgets.widget({name: 'C3Hist',type: 'output',factory: function(el,width,height){// create an empty chartvarchart=null;return{renderValue: function(x){// check if the chart existsif(chart===null){// the chart did not exist and we want to create a new chart via c3.generatevarchart=c3.generate({bindto : el,data: {columns: [['x1'].concat(x.x1),['prob'].concat(x.prob)],type: 'bar',xs: {'prob': 'x1',},colors: {prob: function(d){return(x.prob.indexOf(d.value)>=x.my_th) ? '#aec7e8':'#1f77b4';}},onclick: function(d,element){Shiny.onInputChange(el.id,d)}},bar: {width: {ratio: 1// this makes bar width 100% of length between ticks}},legend: {show: false},// take care of color in tooltiptooltip: {contents: function(d,defaultTitleFormat,defaultValueFormat,color){color=function(){return(x.prob.indexOf(d[0].value)>=x.my_th) ? '#aec7e8':'#1f77b4';};returnchart.internal.getTooltipContent.call(this,d,defaultTitleFormat,defaultValueFormat,color)}}});// store the chart on el so we can get it latterel.chart=chart;}// at this stage the chart always exists// load the new datachart.load({columns: [['x1'].concat(x.x1),['prob'].concat(x.prob)]});},resize: function(width,height){// this will vary based on the JavaScript library// in the case of C3 we are fortunate that there is a resize method// http://c3js.org/samples/api_resize.htmlchart.resize({height:height,width:width})}};}});
The text was updated successfully, but these errors were encountered:
I followed the exact template of your Gauge widget to try to create a histogram widget (
.js
and.R
files below).The core of the
.js
file works. If you just paste the wholevar chart = c3.generate({...})
statement into http://c3js.org/samples/chart_bar.html, adding the linesat the top, the histogram shows as expected. However, when executing
in RStudio, nothing shows. So, I believe that my bindings are at fault, but I couldn't find what's wrong. Could you please have a quick look? Your help would be much appreciated.
If you need to reproduce the error, you can install my fork of
C3
withdevtools::install_github("tixierae/shinyJsTutorials/tutorials/materials2/C3")
. Note that I created aC3Hist.yaml
file, and addedexport(C3Hist);export(C3HistOutput)
to theNAMESPACE
file.C3Hist.R
C3Hist.js
The text was updated successfully, but these errors were encountered: