How to bind Kendo stacked bar chart through Model

痞子三分冷 提交于 2019-12-12 06:17:41

问题


I am trying to bind a stacked kendo Bar chart Through MVC model ,but getting an error "cannot convert lambda expression to type 'double' because it is not a delegate type".

@(Html.Kendo().Chart(Model)
    .Name("chart3")
    .Title(title => title
        .Text("Comments per day")
        .Align(ChartTextAlignment.Left)
    )
    .Legend(legend => legend
        .Visible(false)
    )
    .Series(series =>
    {
        series.Column(new  double[]{model => model.PerIdlingHours}
        )
        .Labels(labels => labels.Background("transparent").Visible(true));
    })
    .CategoryAxis(axis => axis
        .Categories(model => model.DataDate)
        .MajorGridLines(lines => lines.Visible(false))
        .Line(line => line.Visible(false))
    )
    .ValueAxis(axis => axis.Numeric()
        .Max(28)
        .MajorGridLines(lines => lines.Visible(false))
        .Visible(false)
    )
) 

回答1:


This is how we can create the kendo bar chart

@model IEnumerable< Hitec.Blackbox.Models.AllMachinesUtilization>
<div class="chart-wrapper">
@(Html.Kendo().Chart(Model)
    .Name("DailyChart")
        .HtmlAttributes(new { style = "width:auto;height:200px" })
    .Title(title => title
        .Text("Daily Utilization Chart")
        .Align(ChartTextAlignment.Left)
    )
    .Legend(legend => legend
        .Visible(true)
        .Position(ChartLegendPosition.Bottom)  
    )
    .SeriesDefaults(seriesDefaults =>
        seriesDefaults.Column().Stack(ChartStackType.Stack100))
    .Series(series =>
    {
        series.Column(model => model.IdlingHours).Color("#b8b8b8");
        series.Column(model => model.StopHours).Color("#bb6e36");
        series.Column(model => model.EngineWorkingHours).Color("#f3ac32"); 
  })
            .CategoryAxis(axis => axis
                .Categories(model => model.DataDate)
                .MajorGridLines(lines => lines.Visible(false))
                .Line(line => line.Visible(false))
            )
                    .ValueAxis(axis => axis.Numeric()
                       // .Max(100)
                       .Visible(false)
                            .Line(line => line.Visible(false))
                        .MajorGridLines(lines => lines.Visible(true))
                        .Visible(false)
                    )
       .Tooltip(tooltip => tooltip
            .Visible(true)
            .Template("#= series.name #:<br/> #= value #")
                ))
            </div>


来源:https://stackoverflow.com/questions/31554225/how-to-bind-kendo-stacked-bar-chart-through-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!