答案 0 :(得分:1)
I put together an example在不完全知道要显示/隐藏的内容的情况下,在所有系列均关闭时隐藏了x / y轴。为此,我按照其文档中有关how write an onClick
handler for the legend的说明进行操作。
以下是该处理程序的相关代码:
{
...
options: {
scales: {
yAxes: [{
display: true, // <-- Added to make sure property was in options to read
...
}],
xAxes: [{
display: true // <-- Added to make sure property was in options to read
}]
},
legend: {
onClick: function (e, legendItem) {
const index = legendItem.datasetIndex;
const ci = this.chart;
var meta = ci.getDatasetMeta(index);
meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
/* Start: Custom code to handle the showing/hiding */
const allHidden = ci.data.datasets.every((dataSet, index) => ci.getDatasetMeta(index).hidden);
ci.options.scales.yAxes[0].display = !allHidden;
ci.options.scales.xAxes[0].display = !allHidden;
/* End: Custom code to handle the showing/hiding */
// We hid a dataset ... rerender the chart
ci.update();
}
}
}
});
答案 1 :(得分:1)
我遵循Daniel的建议,并重写了自定义onClick函数。现在它的工作完全符合我的预期。
private void MWebview_Download(object sender, DownloadEventArgs e)
{
var url = e.Url;
DownloadManager.Request request = new
DownloadManager.Request(Uri.Parse(url));
request.AllowScanningByMediaScanner();
request.SetNotificationVisibility(DownloadManager.Request.VisibilityVisibleNotifyCompleted); //Notify client once download is completed!
request.SetDestinationInExternalPublicDir(Environment.DirectoryDownloads, "CPPPrimer");
DownloadManager dm = (DownloadManager)GetSystemService("download");
dm.Enqueue(request);
Toast.MakeText(ApplicationContext, "Downloading File",ToastLength.Long//To notify the Client that the file is being downloaded
).Show();
}