0
使用Dataviz和MVC,我想創建一個堆棧圖(這是工作)。但是我想只顯示系列標籤,如果該系列的值大於零。如何使系列標籤可見性有條件?
這裏是標記
@(Html.Kendo().Chart<ChartModel>(Model)
.Name("chart")
.Title("Pending Orders")
.Legend(legend => legend
.Visible(false)
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Column().Stack(true)
.Labels(labels => labels.Background("transparent").Visible(true).Font("40px sans-serif").Position(ChartBarLabelsPosition.Center).Color("black"))
)
.Series(series =>
{
series.Column(model => model.OnTimeCount).Name("On Time").Color("Green");
series.Column(model => model.WarningCount).Name("Warning").Color("Yellow");
series.Column(model => model.AlertCount).Name("Alert").Color("Red");
})
.CategoryAxis(axis => axis
.Categories(model => model.Day)
.MajorGridLines(lines => lines.Visible(false))
)
.ValueAxis(axis => axis
.Numeric()
.Line(line => line.Visible(false))
.MajorGridLines(lines => lines.Visible(false))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Template("#= series.name #: #= value #")
)
)
在系列違約,標籤設置爲可見。我無法弄清楚在那裏放置什麼條件。我試過蘭巴表達式,並沒有奏效。我認爲必須有一種方法來獲得系列值,但我無法弄清楚。
這裏是問題
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Column().Stack(true)
.Labels(labels => labels.Background("transparent").Visible(true).Font("40px sans-serif").Position(ChartBarLabelsPosition.Center).Color("black"))
)