Beispiel #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);
            }
        }
Beispiel #2
0
        private void PrepareDataMatrix(
            ProjectStatsData data,
            ProjectStatsGraph graph,
            ProjectStatsGraphData graphData,
            List <string> xLabels)
        {
            int buildId = 0;

            xLabels.Clear();

            // go through all builds
            for (int i = 0; i < data.Builds.Count; i++)
            {
                // show last 50 builds on graph if parameter is set to false
                if (!showBuildProjectHistory)
                {
                    if (i < data.Builds.Count - BuildNumbers)
                    {
                        continue;
                    }
                }

                ProjectStatsBuildEntry entry = data.Builds[i];

                // ignore unsuccessful builds
                if (graph.IgnoreFailures && entry.Parameters["Success"] == "0")
                {
                    continue;
                }

                // flag, that marks if parameter value will be added to the list or
                // value will increase existing value (depends on buildId)
                bool addValue = false;

                // if the current build label has not already been added to the xLabels
                if (entry.BuildLabel != xLabels.Find(temp => temp == entry.BuildLabel))
                {
                    // add build name to list. Build name will be shown on x-axis
                    xLabels.Add(entry.BuildLabel);

                    addValue = true;
                    buildId  = entry.BuildId;
                }

                // go through all graph parameters
                foreach (ProjectStatsGraphParameter parameter in graph.GraphParameters)
                {
                    double value = 0;

                    // if parameter exists in build statistic then get parameter value
                    if (entry.Parameters.ContainsKey(parameter.ParameterName))
                    {
                        if (parameter.ParameterType == typeof(TimeSpan))
                        {
                            value = TimeSpan.Parse(entry.Parameters[parameter.ParameterName]).TotalSeconds;
                        }
                        else if (parameter.ParameterType == typeof(double))
                        {
                            value = Convert.ToDouble(
                                entry.Parameters[parameter.ParameterName],
                                CultureInfo.InvariantCulture);
                        }
                    }

                    if (addValue)
                    {
                        // set value
                        graphData.SetValue(buildId, parameter.ParameterName, value);
                    }
                    else
                    {
                        // increment value
                        graphData.IncValue(buildId, parameter.ParameterName, value);
                    }
                }
            }
        }