我试图将我的 Facebook 页面的点赞数显示为图表,以便用户知道哪些页面最受欢迎。我设法提取并显示我的 facebook 页面名称数据以表示图表上的颜色,我似乎无法相应地获得在 y 轴上出现的点赞数。我认为这与将我的 Json 转换为整数有关吗?任何帮助,将不胜感激!我将此链接用作图表的参考。
private void topPageBtn_Click(object sender, EventArgs e)
{
try
{
chart1.Visible = true;
FacebookAPI api = new Facebook.FacebookAPI(myToken.Default.token);
JSONObject pageData = api.Get("/me/accounts");
var data = pageData.Dictionary["data"];
List<JSONObject> pageList = data.Array.ToList<JSONObject>();
foreach (var page in pageList)
{
string[] seriesArray = { page.Dictionary["name"].String };
//pull more page information from the page ID
JSONObject pageInfo = api.Get(page.Dictionary["id"].String);
//store the number of likes
int[] pointsArray = {pageInfo.Dictionary["likes"].String};
// Add series.
for (int i = 0; i < seriesArray.Length; i++)
{
// Add series.
Series series = this.chart1.Series.Add(seriesArray[i]);
series.Points.Add(pointsArray[i]);
}
}
// Set palette.
this.chart1.Palette = ChartColorPalette.EarthTones;
// Set title.
this.chart1.Titles.Add("No. of Page likes");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}