2014-12-10 6 views
0

MVC의 Telerik 's Kendo UI 파이 차트에 문제가 있습니다. 나는 그들의 사이트에서 괜찮은 코드 예제를 찾을 수 없습니다. 발견 한 데모는 코드의 절반 만 보여 주므로 코드를 작동시키는 방법을 추측 해 보았습니다. 오류가 발생했습니다. 오류를 제거하려고 시도했지만 아무 문제가없는 것 같습니다. 시리즈에 문제가 있습니다. 실제로 데이터를 바인딩하는 부분. 나는 그들의 예제에 있던 코드를 복사했고 마치 람다 식을 사용했다. model => model.Percentage and model => model.StatusName 내 뷰 모델에서 작동합니다. 그러나이 오류 메시지와 함께 최초의 람다에 오류 아웃 :검도 원형 차트 MVC 데이터 바인딩

CS1660 :

: 그것은 대리자 형식 여기

하지 않기 때문에 '문자열을'입력 람다 식을 변환 할 수 없습니다하면 관련 코드

뷰 모델 /보기 :

public class StatusPercentageViewModel 
{ 
    public string StatusName { get; set; } 
    public int Count { get; set; } 
    public double Percentage { get; set; } 
} 


@model IEnumerable<StatusPercentageViewModel> 
@(Html.Kendo().Chart(Model) 
    .Name("StatusBreakdown") 
    .Legend(legend => legend 
     .Position(ChartLegendPosition.Bottom) 
    ) 
    .Series(series => 
    { 
     series.Pie(
      model => model.Percentage, 
      model => model.StatusName, 
      null, 
      null 
     ); 
    }) 
    .Tooltip(tooltip => tooltip. 
     Template("${ category } - ${ value }%").Visible(true) 
    ) 
) 

답변

0

당신은 아마 당신이 그런 당신의 시리즈를 정의하려면 모델을 지정해야합니다. (당신은 지금 무엇을 더 유사)

@(Html.Kendo().Chart<StatusPercentageViewModel>() 
    .Name("StatusBreakdown") 
    .Legend(legend => legend.Position(ChartLegendPosition.Bottom)) 
    .DataSource(ds => ds.Read(read => read.Action("GetStatus", "Status"))) 
    .Series(series => 
    { 
     series.Pie(
      model => model.Percentage, 
      model => model.StatusName 
     ); 
    }) 
    .Tooltip(tooltip => tooltip.Template("${ category } - ${ value }%").Visible(true)) 
) 

또 다른 방법이 될 것 할 : 예를 들어 this example

표시 내용이 문제에 대한

@model IEnumerable<StatusPercentageViewModel> 
@(Html.Kendo().Chart() 
    .Name("StatusBreakdown") 
    .Legend(legend => legend.Position(ChartLegendPosition.Bottom)) 
    .Series(series => series.Pie(Model)) 
    .Tooltip(tooltip => tooltip.Template("${ category } - ${ value }%").Visible(true)) 
) 
+0

을 ??? http://stackoverflow.com/questions/28897992/showing-data-by-percentage-on-pie-charts-in-mvc –