private void btnGraph_Click(object sender, EventArgs e) { switch (GType) { case GraphDataModel.GraphType.BarGraph: canvasHeight = lblPanel.Height; canvasWidth = lblPanel.Width; DrawBarGraph(graphData.GetItemList()); break; case GraphDataModel.GraphType.PieChart: canvasHeight = lblPanel.Height; canvasWidth = lblPanel.Width; DrawPieChart(graphData.GetItemList()); break; case GraphDataModel.GraphType.LineGraph: canvasHeight = lblPanel.Height; canvasWidth = lblPanel.Width; DrawLineGraph(graphData.GetItemList()); break; default: MessageBox.Show("A graph type was not chosen.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
private void btnCreate_Click(object sender, EventArgs e) { if (graphData.GetItemList().Count > 0) { graphData.gType = CheckRadioButton(); graphFrm graphFrm = new graphFrm(graphData); graphFrm.Show(); } else { MessageBox.Show("There is no data to draw.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLoad_Click(object sender, EventArgs e) { GraphDataModel testData = new GraphDataModel("Ethnic Groups in Nepal", "Percentage", "Ethnic Group"); testData.AddItem("Chhetteri", 16.6); testData.AddItem("Brahman - Hill", 16.6); testData.AddItem("Magar", 7.1); testData.AddItem("Tharu", 6.6); testData.AddItem("Tamang", 5.8); testData.AddItem("Newar", 5); testData.AddItem("Kami", 4.8); testData.AddItem("Muslim", 4.4); testData.AddItem("Yadav", 4); testData.AddItem("Rai", 2.3); testData.AddItem("Gurung", 2); testData.AddItem("Damai / Dholii", 1.8); testData.AddItem("Thakuri", 1.6); testData.AddItem("Limbu", 1.5); testData.AddItem("Sarki", 1.4); testData.AddItem("Teli", 1.4); testData.AddItem("Chamar / Harijan / Ram", 1.3); testData.AddItem("Kooiri / Kushwaha", 1.2); testData.AddItem("Other", 19); Random rnd = new Random(); List <ItemModel> items = testData.GetItemList(); foreach (ItemModel item in items) { testData.ChangeItemAt(items.IndexOf(item), item.Name, item.Data, Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256))); } testData.gType = 0; graphData = testData; UpdateForm(1); }