/ / como obter dados do JSON sem usar script? - json, asp.net-mvc-4, kendo-ui

como obter dados de JSON sem usar script? - json, asp.net-mvc-4, kendo-ui

Eu quero obter dados do arquivo json sem usar o código de script!

iam usando o MVC4 e quero colocar o código no arquivo .cshtml, como posso fazer isso?

(Estou usando a função kendo)

exemplo:

@{
ViewBag.Title = "Home Page";
}

<div class="chart-wrapper">
@(Html.Kendo().Chart()
.Name("chart")
.Title(title => title
.Text("Share of Internet Population Growth, 2007 - 2012")
.Position(ChartTitlePosition.Bottom))
.Legend(legend => legend
.Visible(false)
)
.DataSource(dataSource=>dataSource.Read(read=>read.Url("~/")))

.Events(e => e.SeriesClick("onSeriesHover"))
.Series(series => {
series.Pie(new dynamic[] {
new {category="Asia",value=53.8,color="#9de219"},
new {category="Europe",value=16.1,color="#90cc38"},
new {category="LatinAmerica",value=11.3,color="#068c35"},
new {category="Africa",value=9.6,color="#006634"},
new {category="MiddleEast",value=5.2,color="#004d38"},
new {category="NorthAmerica",value=3.6,color="#033939"}
})
.Labels(labels => labels
.Template("#= category #: #= value#%")
.Background("transparent")
.Visible(true)
.Color("Red")
)
.StartAngle(150);
})
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0}%")
)

)
<script>
function onSeriesClick(e) {
alert(kendo.format("Series click :: {0} ({1}): {2}",
e.series.name, e.category, e.value));
}


</script>
</div>

eu tenho uso .DataSource (dataSource => dataSource.Read (leia => read.Url ("~ /")))) mas não está funcionando

Respostas:

0 para resposta № 1

Tente assim,

Exemplo

Visão

  @(Html.Kendo().Chart<Model.DashboardPieChartModel>()
.Name("PieChartPopup")
.Events(events => events.DataBound("onDataBound"))
.Legend(legend => legend
.Visible(false)
)
.DataSource(ds =>
{
ds.Read(read => read.Action("Read_PieChart", "Dashboard"));
}
)

.Series(series =>
{
series.Pie(
model => model.Percentage,
model => model.Service, null, null
).Labels(labels => labels
.Visible(true)
.Template("${ category } - ${ value }%")

).Overlay(ChartPieSeriesOverlay.None);
})

.Tooltip(tooltip => tooltip
.Visible(true)
.Template("${ category } - ${ value }%")
)

)

Controlador

public JsonResult Read_PieChart()
{

//Whatever you do here


return Json(return your data);
}

Leia este link: http://demos.kendoui.com/dataviz/pie-charts/remote-data.html