コード例 #1
0
ファイル: GraphViewTests.cs プロジェクト: hong1990/gui.cs
        private GraphView GetGraph(out FakeBarSeries series, out FakeHAxis axisX, out FakeVAxis axisY)
        {
            GraphViewTests.InitFakeDriver();

            var gv = new GraphView();

            gv.ColorScheme = new ColorScheme();

            // y axis goes from 0.1 to 1 across 10 console rows
            // x axis goes from 0 to 10 across 20 console columns
            gv.Bounds   = new Rect(0, 0, 20, 10);
            gv.CellSize = new PointF(0.5f, 0.1f);

            gv.Series.Add(series = new FakeBarSeries());

            // don't show axis labels that means any labels
            // that appaer are explicitly from the bars
            gv.AxisX = axisX = new FakeHAxis()
            {
                Increment = 0
            };
            gv.AxisY = axisY = new FakeVAxis()
            {
                Increment = 0
            };

            return(gv);
        }
コード例 #2
0
ファイル: GraphViewTests.cs プロジェクト: hong1990/gui.cs
        private GraphView GetGraph(out FakeHAxis axisX, out FakeVAxis axisY)
        {
            GraphViewTests.InitFakeDriver();

            var gv = new GraphView();

            gv.ColorScheme = new ColorScheme();
            gv.Bounds      = new Rect(0, 0, 50, 30);
            // graph can't be completely empty or it won't draw
            gv.Series.Add(new ScatterSeries());

            axisX    = new FakeHAxis();
            axisY    = new FakeVAxis();
            gv.AxisX = axisX;
            gv.AxisY = axisY;

            return(gv);
        }
コード例 #3
0
ファイル: GraphViewTests.cs プロジェクト: hong1990/gui.cs
 private GraphView GetGraph(out FakeHAxis axis)
 {
     return(GetGraph(out axis, out _));
 }
コード例 #4
0
ファイル: GraphViewTests.cs プロジェクト: hong1990/gui.cs
        public void TestRendering_MultibarSeries()
        {
            GraphViewTests.InitFakeDriver();

            var gv = new GraphView();

            gv.ColorScheme = new ColorScheme();

            // y axis goes from 0.1 to 1 across 10 console rows
            // x axis goes from 0 to 20 across 20 console columns
            gv.Bounds       = new Rect(0, 0, 20, 10);
            gv.CellSize     = new PointF(1f, 0.1f);
            gv.MarginBottom = 1;
            gv.MarginLeft   = 1;

            var multibarSeries = new MultiBarSeries(2, 4, 1);

            //nudge them left to avoid float rounding errors at the boundaries of cells
            foreach (var sub in multibarSeries.SubSeries)
            {
                sub.Offset -= 0.001f;
            }

            gv.Series.Add(multibarSeries);

            FakeHAxis fakeXAxis;

            // don't show axis labels that means any labels
            // that appaer are explicitly from the bars
            gv.AxisX = fakeXAxis = new FakeHAxis()
            {
                Increment = 0
            };
            gv.AxisY = new FakeVAxis()
            {
                Increment = 0
            };

            gv.Redraw(gv.Bounds);

            // Since bar series has no bars yet no labels should be displayed
            Assert.Empty(fakeXAxis.LabelPoints);

            multibarSeries.AddBars("hey", 'M', 0.5001f, 0.5001f);
            fakeXAxis.LabelPoints.Clear();
            gv.Redraw(gv.Bounds);

            Assert.Equal(4, fakeXAxis.LabelPoints.Single());

            multibarSeries.AddBars("there", 'M', 0.24999f, 0.74999f);
            multibarSeries.AddBars("bob", 'M', 1, 2);
            fakeXAxis.LabelPoints.Clear();
            gv.Redraw(gv.Bounds);

            Assert.Equal(3, fakeXAxis.LabelPoints.Count);
            Assert.Equal(4, fakeXAxis.LabelPoints[0]);
            Assert.Equal(8, fakeXAxis.LabelPoints[1]);
            Assert.Equal(12, fakeXAxis.LabelPoints [2]);

            string looksLike =
                @" 
 │          MM
 │       M  MM
 │       M  MM
 │  MM   M  MM
 │  MM   M  MM
 │  MM   M  MM
 │  MM  MM  MM
 │  MM  MM  MM
 ┼──┬M──┬M──┬M──────
   heytherebob  ";

            GraphViewTests.AssertDriverContentsAre(looksLike);
        }