public void Init()
        {
            areaNameLabel.Content = VoivodeshipNamesExtensions.GetName(voivodeshipName);

            PieChart pieChart = new PieChart(chartPosition, chartSize);

            pieChart.Create(mapPainter.GetAreaChartValues((int)voivodeshipName));

            StatisticsData[] statisticsData = mapPainter.Holder.VoivodeshipData[(int)voivodeshipName];
            StatisticsData   minData        = mapPainter.Holder.GetMinDatasInVoivodeship(voivodeshipName);
            StatisticsData   maxData        = mapPainter.Holder.GetMaxDatasInVoivodeship(voivodeshipName);

            faces = ChernoffFace.GetFaces(pieChart, statisticsData, minData, maxData);

            pieChart.Draw(chartCanvas);
            chartCanvas.Background = Brushes.Azure;

            foreach (ChernoffFace face in faces)
            {
                face.Draw(chartCanvas);
            }

            // ChernoffFace.AdjustView(faces, chartCanvas, chartCanvasScaleTransform, chartCanvasTranslateTransform);

            foreach (string sportName in mapPainter.Holder.SportNames)
            {
                sportNameCb.Items.Add(sportName);
            }

            if (sportNameCb.Items.Count > 0)
            {
                sportNameCb.SelectedIndex = 0;
            }
        }
示例#2
0
        private void drawPreview(int areaIndex)
        {
            VoivodeshipNames areaName = (VoivodeshipNames)areaIndex;

            prevLabel.Content = VoivodeshipNamesExtensions.GetName(areaName);

            Point chartPosition = new Point(previewCanvas.Width / 2, previewCanvas.Height / 2);
            int   chartSize     = (int)(previewCanvas.Width / 4);

            PieChart pieChart = new PieChart(chartPosition, chartSize);

            pieChart.Create(mapPainter.GetAreaChartValues(areaIndex));

            StatisticsData[] statisticsData = mapPainter.Holder.VoivodeshipData[areaIndex];
            StatisticsData   minData        = mapPainter.Holder.GetMinDatasInVoivodeship(areaName);
            StatisticsData   maxData        = mapPainter.Holder.GetMaxDatasInVoivodeship(areaName);

            ChernoffFace[] faces = ChernoffFace.GetFaces(pieChart, statisticsData, minData, maxData);

            previewCanvas.Children.Clear();

            pieChart.Draw(previewCanvas);

            foreach (ChernoffFace face in faces)
            {
                face.Draw(previewCanvas);
            }
        }
示例#3
0
        public Bitmap GetChart()
        {
            var chart = new PieChart(Entries)
            {
                Title = this.Title
            };

            return(chart.Draw());
        }
示例#4
0
        private void DrawSourceGraph()
        {
            if (pbSourceGraph.Image != null)
            {
                pbSourceGraph.Image.Dispose();
            }

            _sourceChart.Add(new GraphItem(string.Format("Empty Lines{0}", Environment.NewLine), _sourceCounter.Stats.EmptyLines));
            _sourceChart.Add(new GraphItem(string.Format("Comment Lines{0}", Environment.NewLine), _sourceCounter.Stats.CommentedLines));
            _sourceChart.Add(new GraphItem(string.Format("Preprocessor{0}Lines{0}", Environment.NewLine), _sourceCounter.Stats.PreprocessorLines));
            _sourceChart.Add(new GraphItem(string.Format("Code Lines{0}", Environment.NewLine), _sourceCounter.Stats.CodeLines));

            pbSourceGraph.Image = _sourceChart.Draw(pbSourceGraph.Size, _chartSize, _chartOffset, _chartOffset, new Size(10, 10), new Font(label1.Font.FontFamily, 8, FontStyle.Regular));
        }
示例#5
0
        /// <summary>
        /// Sets values for the chart and draws them.
        /// </summary>
        /// <param name="graphics">Graphics object used for drawing.</param>
        private void DoDraw(Graphics graphics)
        {
            if (m_drawValues == null || m_drawValues.Length <= 0)
            {
                return;
            }

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            float width  = ClientSize.Width - m_leftMargin - m_rightMargin;
            float height = ClientSize.Height - m_topMargin - m_bottomMargin;

            // If the width or height if <=0 an exception would be thrown -> exit method..
            if (width <= 0 || height <= 0)
            {
                return;
            }

            PieChart?.Dispose();

            if (m_drawColors != null && m_drawColors.Length > 0)
            {
                PieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_drawColors,
                                          m_sliceRelativeHeight, m_drawTexts);
            }
            else
            {
                PieChart = new PieChart3D(m_leftMargin, m_topMargin, width, height, m_drawValues, m_sliceRelativeHeight,
                                          m_drawTexts);
            }

            PieChart.FitToBoundingRectangle(m_fitChart);
            PieChart.InitialAngle(m_initialAngle);
            PieChart.SliceRelativeDisplacements(m_drawRelativeSliceDisplacements);
            PieChart.ColorTypeOfEdge(m_edgeColorType);
            PieChart.EdgeLineWidth(m_edgeLineWidth);
            PieChart.StyleOfShadow(m_shadowStyle);
            PieChart.HighlightedIndex(m_highlightedIndex);
            PieChart.Draw(graphics);
            PieChart.Font(Font);
            PieChart.ForeColor(ForeColor);
            PieChart.PlaceTexts(graphics);
        }
示例#6
0
        private void DrawLanguageGraph()
        {
            ClearLanguageGraph();

            lblNoStats.Visible = false;

            _languageGraphItems.Clear();

            foreach (var profile in _sourceCounter.Profiles)
            {
                var stats = _sourceCounter.GetProfileStats(profile);

                if (stats != null)
                {
                    var gi = new GraphItem(profile.Name, stats.CodeLines);
                    _languageGraphItems[profile] = gi;
                    _languageChart.Add(gi);
                }
            }

            pbLanguageUsage.Image = _languageChart.Draw(pbLanguageUsage.Size, _chartSize, _chartOffset, _chartOffset, new Size(9, 9), new Font(label1.Font.FontFamily, 7.5f, FontStyle.Regular));
        }
示例#7
0
        private void DrawButtonOnClick(object sender, RoutedEventArgs e)
        {
            DataInfo.Data = new double[ListBoxWithData.Items.Count];
            for (int i = 0; i < ListBoxWithData.Items.Count; i++)
            {
                DataInfo.Data[i] = double.Parse(ListBoxWithData.Items[i].ToString());
            }

            switch (Type)
            {
            case DiagramType.Piechart:
                var pieChart = new PieChart(DataInfo.Data);
                pieChart.Draw(MainCanvas);
                TitleListBox.Text = pieChart.Title;
                break;

            case DiagramType.NormalizaedHistogram:
                var normHist = new NormalizedHistogram(DataInfo.Series);
                normHist.Draw(MainCanvas);
                TitleListBox.Text = normHist.Title;
                break;

            case DiagramType.StackedHistogram:
                var stHist = new StackedHistogram(DataInfo.Series);
                stHist.Draw(MainCanvas);
                TitleListBox.Text = stHist.Title;
                break;
            }

            AddButton.IsEnabled    = false;
            SeriesButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;
            DrawButton.IsEnabled   = false;

            DataInfo.Series.Clear();
            ListBoxWithData.Items.Clear();
        }
示例#8
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            // This is a quick check for referrer server name against host server
            // For best security practice in a deployed application, an authenticating mechanism should be in placed.
            // Image should only be rendered for authenticated users only.

            // set return type to png image format
            Response.ContentType = "image/png";

            string xValues, yValues, chartType, print;
            bool   boolPrint;

            // Get input parameters from query string
            chartType = Request.QueryString["chartType"];
            xValues   = Request.QueryString["xValues"];
            yValues   = Request.QueryString["yValues"];
            print     = Request.QueryString["Print"];

            if (chartType == null)
            {
                chartType = string.Empty;
            }

            // check for printing option
            if (print == null)
            {
                boolPrint = false;
            }
            else
            {
                try
                {
                    boolPrint = Convert.ToBoolean(print);
                }
                catch
                {
                    boolPrint = false;
                }
            }

            if (xValues != null && yValues != null)
            {
                Color bgColor;

                if (boolPrint)
                {
                    bgColor = Color.White;
                }
                else
                {
                    bgColor = Color.White;
                }

                Bitmap       StockBitMap;
                MemoryStream memStream = new MemoryStream();

                switch (chartType)
                {
                case "bar":
                    BarGraph bar = new BarGraph(bgColor);

                    bar.VerticalLabel     = string.Empty;
                    bar.VerticalTickCount = 5;
                    bar.ShowLegend        = false;
                    bar.ShowData          = false;
                    bar.Height            = 400;
                    bar.Width             = 700;

                    bar.CollectDataPoints(xValues.Split("|".ToCharArray()), yValues.Split("|".ToCharArray()));
                    StockBitMap = bar.Draw();
                    break;

                default:
                    PieChart pc = new PieChart(bgColor);

                    pc.CollectDataPoints(xValues.Split("|".ToCharArray()), yValues.Split("|".ToCharArray()));

                    StockBitMap = pc.Draw();

                    break;
                }

                // Render BitMap Stream Back To Client
                StockBitMap.Save(memStream, ImageFormat.Png);
                memStream.WriteTo(Response.OutputStream);
            }
        }