Ejemplo n.º 1
0
        public static string verticalGroupedTest()
        {
            int[] data1 = new int[] { 10, 5, 20, 15 };

            BarChart barChart = new BarChart(150, 150, BarChartOrientation.Vertical, BarChartStyle.Grouped);
            barChart.SetTitle("Vertical Grouped");
            barChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));
            barChart.AddAxis(new ChartAxis(ChartAxisType.Left));
            barChart.SetData(data1);

            barChart.SetDatasetColors(new string[] { "FF0000", "00AA00" });

            return barChart.GetUrl();
        }
Ejemplo n.º 2
0
        public static string horizontalStackedTest()
        {
            int[] data1 = new int[] { 10, 5, 20, 15 };
            int[] data2 = new int[] { 10, 10, 10, 10 };

            List<int[]> dataset = new List<int[]>();
            dataset.Add(data1);
            dataset.Add(data2);

            BarChart barChart = new BarChart(150, 150, BarChartOrientation.Horizontal, BarChartStyle.Stacked);
            barChart.SetTitle("Horizontal Stacked");
            barChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));
            barChart.AddAxis(new ChartAxis(ChartAxisType.Left));
            barChart.SetData(dataset);

            barChart.SetDatasetColors(new string[] { "FF0000", "00AA00" });

            return barChart.GetUrl();
        }
Ejemplo n.º 3
0
 public async void createBarGraph(string fileName, string title, int width, int height, List<int[]> data, string[] labels, BarChartOrientation overload, StatType type)
 {
     StorageFolder folder = KnownFolders.PicturesLibrary;
     StorageFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
     string url = "";
     BarChart chart = new BarChart(width, height, overload, BarChartStyle.Stacked);
     chart.SetTitle(title);
     chart.SetLegend(labels);
     chart.SetDatasetColors(new string[] { "FF0000", "00AA00", "E6E6FA", "333333", "32cd32", "00FF00", "740001" });
     chart.AddAxis(new ChartAxis(ChartAxisType.Left));
     chart.SetData(data);
     chart.AddSolidFill(new SolidFill(ChartFillTarget.Background, @"00000000"));
     url = chart.GetUrl();
     HttpWebRequest lxRequest = (HttpWebRequest)WebRequest.Create(url);
     // returned values are returned as a stream, then read into a string
     String lsResponse = string.Empty;
     using (var lxResponse = await lxRequest.GetResponseAsync())
     {
         using (BinaryReader reader = new BinaryReader(lxResponse.GetResponseStream()))
         {
             byte[] lnByte = reader.ReadBytes(1 * 1024 * 1024 * 10);
             await FileIO.WriteBufferAsync(file, lnByte.AsBuffer());
         }
     }
     using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
     {
         // Set the image source to the selected bitmap 
         BitmapImage bitmapImage = new BitmapImage();
         bitmapImage.DecodePixelWidth = width; //match the target Image.Width, not shown
         bitmapImage.DecodePixelHeight = height;
         await bitmapImage.SetSourceAsync(fileStream);
         if (type == StatType.Age)
         {
             barAge.Source = bitmapImage;
         }
         else if (type == StatType.Ethnicity)
         {
             barEthnic.Source = bitmapImage;
         }
         else if (type == StatType.Fairness)
         {
             barFair.Source = bitmapImage;
         }
         else if (type == StatType.Income)
         {
             barIncome.Source = bitmapImage;
         }
         else
         {
             barWait.Source = bitmapImage;
         }
         //barImg.Source = bitmapImage;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Prints the data.
        /// </summary>
        private void PrintData(params MultiRunBenchmark[] benchmarks)
        {
            DataTable data = new DataTable();
            data.Columns.Add("Server");
            data.Columns.Add("Run");
            data.Columns.Add("Type");
            data.Columns.Add("Time (seconds)");

            //Populate data table
            foreach (var m in benchmarks) {
                Dictionary<string, List<int[]>> graphData = new Dictionary<string, List<int[]>>();
                for (int i = 0; i < m.NumOfRuns; i++) {
                    for (int j = 0; j < m.ServerBenchmark[i].Results.Length; j++) {
                        BenchmarkBase b = m.ServerBenchmark[i].Results[j];
                        AppendDataTable(data, m.ServerBenchmark[i].ServerName, i + 1, b);
                    }
                }
            }

            //Insert Graph
            BarChart insertBarChart = new BarChart(320, 220, BarChartOrientation.Vertical, BarChartStyle.Grouped);
            insertBarChart.SetTitle("Inserts");
            insertBarChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));
            var c = new ChartAxis(ChartAxisType.Left);
            c.SetRange(0, 60000);
            insertBarChart.AddAxis(c);
            insertBarChart.SetData(benchmarks[0].Results
                .Where(b => b.Type == "Insert")
                .ToList()
                .ConvertAll<float>(b => b.Time.ElapsedMilliseconds)
                .ToArray());

            //Print table
            using (GridView table = new GridView()) {
                table.CellPadding = 5;
                table.CellSpacing = 5;
                table.DataSource = data;
                table.DataBind();

                StringBuilder text = new StringBuilder();
                text.AppendFormat("<img src=\"{0}\" /><br/>", insertBarChart.GetUrl());
                using (StringWriter wr = new StringWriter(text))
                using (HtmlTextWriter htmlWr = new HtmlTextWriter(wr)) {
                    table.RenderControl(htmlWr);
                    this.ReportData.Replace("<%DATA%>", text.ToString());
                }
            }
        }