コード例 #1
0
        public void LegendNormalUsage_WithoutBorder()
        {
            var gv     = GraphViewTests.GetGraph();
            var legend = new LegendAnnotation(new Rect(2, 0, 5, 3));

            legend.AddEntry(new GraphCellToRender('A'), "Ant");
            legend.AddEntry(new GraphCellToRender('B'), "?");               // this will exercise pad
            legend.AddEntry(new GraphCellToRender('C'), "Cat");
            legend.AddEntry(new GraphCellToRender('H'), "Hattter");         // not enough space for this oen
            legend.Border = false;

            gv.Annotations.Add(legend);
            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │AAnt
 ┤B?
 ┤CCat
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected, output);


            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }
コード例 #2
0
        public void LegendNormalUsage_WithBorder()
        {
            var gv     = GraphViewTests.GetGraph();
            var legend = new LegendAnnotation(new Rect(2, 0, 5, 3));

            legend.AddEntry(new GraphCellToRender('A'), "Ant");
            legend.AddEntry(new GraphCellToRender('B'), "Bat");

            gv.Annotations.Add(legend);
            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │┌───┐
 ┤│AAn│
 ┤└───┘
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected, output);


            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }
コード例 #3
0
        private void MultiBarGraph()
        {
            graphView.Reset();

            about.Text = "Housing Expenditures by income thirds 1996-2003";

            var black   = Application.Driver.MakeAttribute(graphView.ColorScheme.Normal.Foreground, Color.Black);
            var cyan    = Application.Driver.MakeAttribute(Color.BrightCyan, Color.Black);
            var magenta = Application.Driver.MakeAttribute(Color.BrightMagenta, Color.Black);
            var red     = Application.Driver.MakeAttribute(Color.BrightRed, Color.Black);

            graphView.GraphColor = black;

            var series = new MultiBarSeries(3, 1, 0.25f, new [] { magenta, cyan, red });

            var stiple = Application.Driver.Stipple;

            series.AddBars("'96", stiple, 5900, 9000, 14000);
            series.AddBars("'97", stiple, 6100, 9200, 14800);
            series.AddBars("'98", stiple, 6000, 9300, 14600);
            series.AddBars("'99", stiple, 6100, 9400, 14950);
            series.AddBars("'00", stiple, 6200, 9500, 15200);
            series.AddBars("'01", stiple, 6250, 9900, 16000);
            series.AddBars("'02", stiple, 6600, 11000, 16700);
            series.AddBars("'03", stiple, 7000, 12000, 17000);

            graphView.CellSize = new PointF(0.25f, 1000);
            graphView.Series.Add(series);
            graphView.SetNeedsDisplay();

            graphView.MarginLeft   = 3;
            graphView.MarginBottom = 1;

            graphView.AxisY.LabelGetter = (v) => '$' + (v.Value / 1000f).ToString("N0") + 'k';

            // Do not show x axis labels (bars draw their own labels)
            graphView.AxisX.Increment       = 0;
            graphView.AxisX.ShowLabelsEvery = 0;
            graphView.AxisX.Minimum         = 0;


            graphView.AxisY.Minimum = 0;

            var legend = new LegendAnnotation(new Rect(graphView.Bounds.Width - 20, 0, 20, 5));

            legend.AddEntry(new GraphCellToRender(stiple, series.SubSeries.ElementAt(0).OverrideBarColor), "Lower Third");
            legend.AddEntry(new GraphCellToRender(stiple, series.SubSeries.ElementAt(1).OverrideBarColor), "Middle Third");
            legend.AddEntry(new GraphCellToRender(stiple, series.SubSeries.ElementAt(2).OverrideBarColor), "Upper Third");
            graphView.Annotations.Add(legend);
        }
コード例 #4
0
ファイル: GraphViewTests.cs プロジェクト: hong1990/gui.cs
        public void LegendNormalUsage_WithBorder()
        {
            var gv     = GraphViewTests.GetGraph();
            var legend = new LegendAnnotation(new Rect(2, 0, 5, 3));

            legend.AddEntry(new GraphCellToRender('A'), "Ant");
            legend.AddEntry(new GraphCellToRender('B'), "Bat");

            gv.Annotations.Add(legend);
            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │┌───┐
 ┤│AAn│
 ┤└───┘
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);
        }