public MainViewModel() { try { //We declared Engine before initializing it so we could put this in a try/catch block, and //have the rest of the code outside. Engine = new Salience(_licensePath, _dataPath); } catch (SalienceException e) { /*If the SalienceEngine constructor throws an error, one of these is likely to be true: * 1) The license file is missing/invalid/out of date * 2) The data directory was missing or contained incorrect files * 3) Salience6.dll could not be found. */ System.Console.WriteLine("Error Loading SalienceEngine: " + e.Message); return; } PieChartItems.Add(new KeyValuePair <string, int>("Positive", 25)); PieChartItems.Add(new KeyValuePair <string, int>("Negative", 25)); PieChartItems.Add(new KeyValuePair <string, int>("Mixed", 25)); PieChartItems.Add(new KeyValuePair <string, int>("Neutral", 25)); }
private void createPieChart() { IEnumerable <UsersInfo> sortTweets = TwitterDB.UsersTable.ToList().OrderByDescending(x => x.TweetsCounter); List <PieChartItems> chart = new List <PieChartItems>(); int top10Counter = 1; foreach (var i in sortTweets) { if (top10Counter >= 10) { break; } var item = new PieChartItems { UserScreenName = i.ScreenName, UserTweetsAmount = i.TweetsCounter }; chart.Add(item); top10Counter++; } string chartItemsString = chart.ToJSON(); ViewBag.ChartData = chartItemsString; }