Ejemplo n.º 1
0
        private string DrawChart(ProjectStatsGraph graph, ProjectStatsGraphData graphData, IList <string> xLabels)
        {
            // Draw chart
            using (FluentChart chart = FluentChart.Create(graph.GraphName, graph.XAxisTitle, graph.YAxisTitle))
            {
                chart.SetLabelsToXAxis(xLabels);

                int xScaleMaxValue = 1;

                foreach (ProjectStatsGraphParameter parameter in graph.GraphParameters)
                {
                    SortedList <int, double> values = graphData.GetValuesForParameter(parameter.ParameterName);
                    xScaleMaxValue = values.Count;
                    chart
                    .AddLineSeries(parameter.ParameterName, parameter.SeriesColor)
                    .AddData(values)
                    .SetSymbol(SymbolType.Circle, parameter.SeriesColor, 4, true);
                }

                string chartImageFileName = fileManager.GetProjectFullFileName(
                    projectId,
                    ModuleId,
                    string.Format(CultureInfo.InvariantCulture, "CCNet{0}Chart.png", graph.GraphName.Replace(" ", string.Empty)),
                    true);

                chart
                .SetXAxis(1, xScaleMaxValue)
                .ExportToBitmap(chartImageFileName, ImageFormat.Png, 2000, 800);

                return(chartImageFileName);
            }
        }
Ejemplo n.º 2
0
        public void DrawChartTest()
        {
            ProjectStatsGraph graph = new ProjectStatsGraph();

            graph.GraphName  = "Build duration";
            graph.YAxisTitle = "Seconds";
            graph.AddParameter <TimeSpan>("Duration", "Green");

            ProjectStatsData data = GetStatisticDataFromFile();

            //Labels on X-Axis
            List <string> xLabels = new List <string> {
                "Test0_1233345667", "Test1_1233345667", "Test2_1233345667", "Test3_1233345667", "Test4_1233345667", "Test5_1233345667"
            };

            ProjectStatsGraphData graphData = new ProjectStatsGraphData(data);

            graphData.SetValue(0, "Duration", 12);
            graphData.SetValue(1, "Duration", 52);
            graphData.SetValue(2, "Duration", 2);
            graphData.SetValue(3, "Duration", 60);
            graphData.SetValue(4, "Duration", 10);
            graphData.SetValue(5, "Duration", 61);

            using (FluentChart chart = FluentChart.Create(graph.GraphName, graph.XAxisTitle, graph.YAxisTitle))
            {
                foreach (ProjectStatsGraphParameter parameter in graph.GraphParameters)
                {
                    chart
                    .AddLineSeries(parameter.ParameterName, parameter.SeriesColor)
                    .AddData(graphData.GetValuesForParameter(parameter.ParameterName))
                    .SetSymbol(SymbolType.Circle, parameter.SeriesColor, 4, true);
                }

                chart.SetXAxis(1, 6);
                chart.SetLabelsToXAxis(xLabels);

                chart
                .ExportToBitmap("test.png", ImageFormat.Png, 2000, 800);
            }
        }