0
DataTable
에 Json 개체가 채워진 Google 원형 차트를 그릴 수 없습니다.Json 개체를 Google 파이 차트로 변환
이것은 내 코드에서 데이터 객체를 생성하는 코드입니다.
public string getJsonObj()
{
Utility utils = new Utility();
List<Item> dataList = new List<Item>();
dataList.Add(new Item("Mosta",50));
dataList.Add(new Item("Naxxar",60));
string json = utils.JsonString(dataList);
this.ChartData.Value = json;
return json;
}
아이템 등급이 표시되지 않는 이유
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(drawChart);
<script type="text/javascript">
function drawPieChart() {
var data = google.visualization.DataTable(document.getElementById("ChartData").value));
var options = {
title: 'Test Pie Chart'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart1'));
chart.draw(data, options);
}
</script>
<div id="piechart1" style="width: auto; height: auto;"></div>
어떤 사람이 나에게 설명해 주시겠습니까
public class Item
{
private string location = "";
private int frequency = 0;
public Item(string location, int frequency)
{
this.Location = location;
this.Frequency = frequency;
}
public string Location
{
get { return location; }
set { location = value; }
}
public int Frequency
{
get { return frequency; }
set { frequency = value; }
}
}
HTML. 감사.