/// <summary> /// Chart tweet word count data /// </summary> /// <param name="wdData"></param> private void chartWords(List <wordData> wdData) { if (chart1.InvokeRequired) { var d = new ChartingWordDelegate(chartWords); chart2.Invoke(d, new object[] { wdData }); } else { lock (tight) { // initialize number of bars int numBars = 10; int cntr = 0; this.chart2.Series.Clear(); // limit number of bars // hardcoded for now // numBars will eventually come from GUI if (numBars < 200) { // iterate through list foreach (wordData cData in wdData) { // create series and add data points try { Series series = this.chart2.Series.Add(cData.word); series.Points.Add(cData.wordCnt); } catch { } cntr++; } } else { MessageBox.Show("Try a smaller number and re-start."); this.chartingThread.Suspend(); start_btn.Text = "Start"; done = true; } // refresh chart this.chart2.ChartAreas[0].RecalculateAxesScale(); this.Refresh(); } } }
private void Form1_Load(object sender, EventArgs e) { // set delegates to their appropriate method ChartingDelegate chartDel = new ChartingDelegate(chartData); PostTweetDelegate postTweetDel = new PostTweetDelegate(postTweet); ChartingWordDelegate chartWordDel = new ChartingWordDelegate(chartWords); // cc = new ChartingClass(chartDel, postTweetDel, chartWordDel); // only look at recent tweets dt = DateTime.Now.ToString("MM/dd/yyyy H:mm:ss"); // clear all the series in chart 1 and 2 this.chart1.Series.Clear(); this.chart2.Series.Clear(); // Set chart1 palette this.chart1.Palette = ChartColorPalette.Light; // Set chart titles this.chart1.Titles.Add("Hate Tweet Stats"); this.chart2.Titles.Add("Tweet Word Stats"); }