我想将图表小部件绑定到多选小部件的选择事件。如果在多选中触发选择,则图表将使用来自多选的数据源(最终还会根据选择过滤数据)。我有多选工作,但我无法连接事件来更新图表。
我的空图表初始化:
<script>
$("#chart").kendoChart({
seriesDefaults: { type: "bar" },
});
</script>
我的多选:
<input type="text" id="treePicker" />
<p>Pick the type of the tree: </p>
<script type="text/javascript">
var treeDataSource = new kendo.data.DataSource({
transport: {
read: {
url: "/Forest/ForestData",
dataType: "json"
}
},
});
var chart = $("#chart");
$("#treePicker").kendoMultiSelect({
dataSource: treeDataSource,
dataTextField: "Type",
select: function (e) {
chart.dataSource = this.dataSource;
}
});
</script>
我的模特/控制器
public class Tree
{
public string Type { get; set; }
public int Size { get; set; }
}
public class ForestController : Controller
{
public ActionResult ForestData()
{
List<Tree> forest = new List<Tree>();
forest.Add(new Tree { Type = "Pine", Size = 4 });
forest.Add(new Tree { Type = "Oak", Size = 10 });
forest.Add(new Tree { Type = "Apple", Size = 5 });
return Json(forest, JsonRequestBehavior.AllowGet);
}
public ActionResult Forest()
{
return View();
}
答案 0 :(得分:0)
有效。我修改了图表:
sdrLabel.text = String(Float(NSUserDefaults.standardUserDefaults().integerForKey("TotalScore") / NSUserDefaults.standardUserDefaults().integerForKey("TotalDeath")))
和多选的一部分:
<android.support.design.widget.CoordinatorLayout ... >
<android.support.design.widget.AppBarLayout
android:elevation="16dp">
<android.support.design.widget.CollapsingToolbarLayout ... >
<android.support.v7.widget.Toolbar ... />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>