我在<div id="app">
<v-app>
<v-content>
<v-container>
<v-slider v-model="sliderValue"
id="sliderId"
v-on:input="sliderInput"
:max="2018"
:min="1990"
step="1"
thumb-label
ticks></v-slider>
</v-container>
</v-content>
</v-app>
</div>
new Vue({
el: '#app',
data: () => ({
sliderValue: 1990
}),
methods: {
sliderInput (e) {
this.sliderValue = e
return this.sliderValue
}
},
mounted () {
require(["dojo/on"], function(on){
var slider = document.getElementById('sliderId')
var vm = this
function SomeFunction() {
console.log('SomeFunction executed')
}
on(slider, 'change', function (event) {
var xyz = vm.sliderValue
SomeFunction(xyz)
})
})
}
})
+ shiny
中的地图中列出了可能的着色选项,例如
leaflet
从以上变量中,我创建了一个选择列表,该列表将用于选择要在地图中着色的所需变量
vars <- c("Difference" = "diff",
"Index" = "index",
"City Cargo" = "cid_carga",
"City score" = "carga_mun_score")
但是,很显然,当我在selectInput("color", "Color", vars, selected = "carga_mun_score")
地图中创建图例标题时,标题仍然是变量的实际名称 eg ,“ cid_cargo”而不是“ City”货运”。
leaflet
有没有一种方法可以使用我的别名(在上面的示例中,“城市得分”)名称代替实际的变量名称(“ carga_mun_score”),而无需使用很长的{{1} }子句?
答案 0 :(得分:0)
简单地:
addLegend("bottomleft",pal = pal, values = df[[input$color]],
layerId = "colorLegend", title="City Score")
或将您的选择保存到可以翻译名称的变量中:
varname<-switch(input$color,
"diff" = "Difference",
"index"="Index",
"cid_carga"="City Cargo",
"carga_mun_score"="City score")
然后将该变量传递给您的传单图例:
addLegend("bottomleft",pal = pal, values = df[[input$color]],
layerId = "colorLegend", title=varname)