Beispiel #1
0
        public override void Initialize()
        {
            base.Initialize();

            // remove all panels
            nChartControl1.Panels.Clear();

            // create a Venn chart
            NChart chart = new NVennChart();

            // create a title
            NLabel title = new NLabel("Five Set Venn");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);

            // create a Venn series
            NVennSeries venn = (NVennSeries)chart.Series.Add(SeriesType.Venn);

            FiveSetVenn(venn);
            FiveSetVennLabels(venn);
            FiveSetVennInteractivity(venn);

            // set a tooltip tool
            nChartControl1.Controller.Selection.Add(chart);
            nChartControl1.Controller.Tools.Add(new NTooltipTool());

            // apply layout
            ConfigureStandardLayout(chart, title, null);
        }
        void FourSetVennLabels(NVennSeries venn)
        {
            string centreLabel = "ABCD";

            string[] s1 = new string[] { "A", "B", "C", "D" };
            string[] s2 = new string[] { "AC", "CD", "BD", "AD", "AB", "BC" };
            string[] s3 = new string[] { "ACD", "BCD", "ABD", "ABC" };

            venn.ClearLabels();
            venn.LabelsTextStyle.FontStyle = new NFontStyle("Verdana", 8);

            // add centre label
            venn.AddLabel(centreLabel, new NPointF(0, -8));

            // add layer 1 labels
            venn.AddLabel(s1[0], new NPointF(-12.5f - 15f, -10f + 10f));
            venn.AddLabel(s1[1], new NPointF(12.5f + 15f, -10f + 10f));
            venn.AddLabel(s1[2], new NPointF(-2.5f - 15f, 5f + 16f));
            venn.AddLabel(s1[3], new NPointF(2.5f + 15f, 5f + 16f));

            // add layer 2 labels
            venn.AddLabel(s2[0], new NPointF(-12.5f - 9f, -10f + 19f));
            venn.AddLabel(s2[1], new NPointF(0, -10f + 24f));
            venn.AddLabel(s2[2], new NPointF(12.5f + 9f, -10f + 19f));
            venn.AddLabel(s2[3], new NPointF(2.5f - 18f, 5f - 18f));
            venn.AddLabel(s2[4], new NPointF(0, -10f - 16f));
            venn.AddLabel(s2[5], new NPointF(-2.5f + 18f, 5f - 18f));

            // add layer 3 labels
            venn.AddLabel(s3[0], new NPointF(-12.5f + 1f, -10f + 10f));
            venn.AddLabel(s3[1], new NPointF(12.5f - 1f, -10f + 10f));
            venn.AddLabel(s3[2], new NPointF(2.5f - 10f, 5f - 21.5f));
            venn.AddLabel(s3[3], new NPointF(-2.5f + 10f, 5f - 21.5f));
        }
Beispiel #3
0
        void FiveSetVennLabels(NVennSeries venn)
        {
            const int nCount = 5;

            string[] s1 = new string[] { "A", "B", "C", "D", "E" };
            string[] s2 = new string[] { "AC", "BD", "CE", "DA", "EB" };
            string[] s3 = new string[] { "ABCD", "BCDE", "CDEA", "DEAB", "EABC" };

            venn.ClearLabels();
            venn.LabelsTextStyle.FontStyle = new NFontStyle("Verdana", 8);

            // add the center label
            venn.AddLabel("ABCDE", new NPointF(0, 0));

            // add layer 1 labels, angle is in radians
            NPointF[] points = CalculateLabelPositions(nCount, 35, -1.1f);
            for (int i = 0; i < nCount; i++)
            {
                venn.AddLabel(s1[i], points[i]);
            }

            // add layer 2 labels, angle is in radians
            points = CalculateLabelPositions(nCount, 25, -1.3f);
            for (int i = 0; i < nCount; i++)
            {
                venn.AddLabel(s2[i], points[i]);
            }

            // add layer 4 labels, angle is in radians
            points = CalculateLabelPositions(nCount, 17.5f, -0.5f);
            for (int i = 0; i < nCount; i++)
            {
                venn.AddLabel(s3[i], points[i]);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Four Set Venn");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // no legend
            nChartControl1.Legends.Clear();

            NVennChart chart = new NVennChart();

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            NVennSeries venn = (NVennSeries)chart.Series.Add(SeriesType.Venn);

            FourSetVenn(venn);
            FourSetVennLabels(venn);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
Beispiel #5
0
        void TwoSetVenn(NVennSeries venn)
        {
            venn.ClearContours();

            venn.AddVennContour(VennShape.Ellipse, new NPointF(-15, 0), new NSizeF(50, 50), 0, 0);
            venn.AddVennContour(VennShape.Ellipse, new NPointF(15, 0), new NSizeF(50, 50), 0, 1);
        }
        void TwoSetVennInteractivity(NVennSeries venn)
        {
            int[] arrContourIds;
            NInteractivityStyle interactivity;

            // set the default tooltip
            venn.InteractivityStyle.Tooltip.Text = "Venn Diagram";
            venn.InteractivityStyle.Cursor.Type  = CursorType.No;

            // clear previous interactivity objects
            venn.ClearSegmentInteractivityStyles();

            // Set tooltips and cursors for particular segments
            arrContourIds = new int[] { 0 };
            interactivity = new NInteractivityStyle();
            interactivity.Tooltip.Text = "Segment A";
            venn.SetInteractivityForSegment(arrContourIds, interactivity);

            arrContourIds = new int[] { 1 };
            interactivity = new NInteractivityStyle();
            interactivity.Tooltip.Text = "Segment B";
            venn.SetInteractivityForSegment(arrContourIds, interactivity);

            arrContourIds = new int[] { 0, 1 };
            interactivity = new NInteractivityStyle();
            interactivity.Tooltip.Text = "Segment AB";
            venn.SetInteractivityForSegment(arrContourIds, interactivity);
        }
        void ThreeSetVennLabels(NVennSeries venn)
        {
            string[] s1 = new string[] { "A", "B", "C" };
            string[] s2 = new string[] { "BC", "AC", "AB" };

            venn.ClearLabels();
            venn.LabelsTextStyle.FontStyle = new NFontStyle("Verdana", 8);

            // add the center label
            venn.AddLabel("ABC", new NPointF(0, 0));

            // add outer labels
            NPointF[] points = CalculateLabelPositions(3, 30, (float)(-Math.PI / 2));
            for (int i = 0; i < 3; i++)
            {
                venn.AddLabel(s1[i], points[i]);
            }

            // add middle labels
            points = CalculateLabelPositions(3, 17, (float)Math.PI / 2);
            for (int i = 0; i < 3; i++)
            {
                venn.AddLabel(s2[i], points[i]);
            }
        }
        void FourSetVenn(NVennSeries venn)
        {
            venn.ClearContours();

            venn.AddVennContour(VennShape.Ellipse, new NPointF(-12.5f, -10f), new NSizeF(60, 35), 135, 0);
            venn.AddVennContour(VennShape.Ellipse, new NPointF(12.5f, -10f), new NSizeF(60, 35), 45, 1);
            venn.AddVennContour(VennShape.Ellipse, new NPointF(-2.5f, 5), new NSizeF(60, 35), 135, 2);
            venn.AddVennContour(VennShape.Ellipse, new NPointF(2.5f, 5), new NSizeF(60, 35), 45, 3);
        }
Beispiel #9
0
        void TwoSetVennLabels(NVennSeries venn)
        {
            string[] s1 = new string[] { "A", "AB", "B" };

            venn.ClearLabels();
            venn.LabelsTextStyle.FontStyle = new NFontStyle("Verdana", 8);

            // add labels
            venn.AddLabel(s1[0], new NPointF(-25, 0));
            venn.AddLabel(s1[1], new NPointF(0, 0));
            venn.AddLabel(s1[2], new NPointF(25, 0));
        }
        void ThreeSetVenn(NVennSeries venn)
        {
            const int   nSetCount       = 3;
            const float fStartAngle     = -((float)Math.PI / 2);
            const float fScale          = 14;
            const float fCenterX        = 0;
            const float fCenterY        = 0;
            float       fIncrementAngle = (float)(2 * Math.PI / nSetCount);

            venn.ClearContours();

            for (int i = 0; i < nSetCount; i++)
            {
                float fAngle = fStartAngle + i * fIncrementAngle;
                float x      = (float)Math.Round(fCenterX + Math.Cos(fAngle) * fScale, 1);
                float y      = (float)Math.Round(fCenterY + Math.Sin(fAngle) * fScale, 1);

                venn.AddVennContour(VennShape.Ellipse, new NPointF(x, y), new NSizeF(50, 50), 0, i);
            }
        }