/// <summary> /// Start plotting /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btnPlotGraph_Click(object sender, EventArgs e) { //draw respective plot string exceptionMessage = ""; switch (this.plotType) { case CsvPlotter.PlotTypes.Histogram: { HistogramAttributes attributes = this.pgPlotProperty.SelectedObject as HistogramAttributes; if (attributes.ColumnsNamesAreValid(ref exceptionMessage)) { Bitmap image = await CsvPlotter.CreateHistogram(attributes); using (ShowPlotForm showPlotForm = new ShowPlotForm(image)) { showPlotForm.ShowDialog(); } } else { MessageBox.Show(exceptionMessage, "Exception Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; case CsvPlotter.PlotTypes.Scatter: { ScatterAttributes attributes = this.pgPlotProperty.SelectedObject as ScatterAttributes; if (attributes.ColumnsNamesAreValid(ref exceptionMessage)) { Bitmap image = await CsvPlotter.CreateScatterPlot(attributes); using (ShowPlotForm showPlotForm = new ShowPlotForm(image)) { showPlotForm.ShowDialog(); } } else { MessageBox.Show(exceptionMessage, "Exception Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } }
public void Plot_Append_Mode_False() { var fileName = Path.GetTempFileName(); var csvPlotter = new CsvPlotter(fileName, false); var testItems = new List <DataItemDto> { new DataItemDto { Date = DateTime.Today, Value = 10 }, new DataItemDto { Date = DateTime.Today.AddDays(1), Value = 10 } }; csvPlotter.Plot(testItems); csvPlotter.Plot(testItems); var lines = File.ReadAllLines(fileName); Assert.AreEqual(lines.Length, 2); File.Delete(fileName); }
public void Plot_Correct_Format() { var fileName = Path.GetTempFileName(); var csvPlotter = new CsvPlotter(fileName, true); var testItems = new List <DataItemDto> { new DataItemDto { Date = DateTime.Today, Value = 10 }, new DataItemDto { Date = DateTime.Today.AddDays(1), Value = 10 } }; csvPlotter.Plot(testItems); var fileOutput = File.ReadAllText(fileName); var expectedOutput = @"14/07/2018, 10 15/07/2018, 10 "; Assert.AreEqual(fileOutput, expectedOutput); File.Delete(fileName); }