public void Register_requires_Name_set()
        {
            var gb = new GaugeBuilder(new PrometheusRegistry(null));

            gb.Help("This is a help message");

            Assert.Throws <ArgumentException>(() => gb.Register());
        }
        public void Register_requires_Help_set()
        {
            var gb = new GaugeBuilder(new PrometheusRegistry(null));

            gb.Name("example_count");

            Assert.Throws <ArgumentException>(() => gb.Register());
        }
示例#3
0
        public ViewModel()
        {
            _maxAngle        = 270;
            GaugeTotal       = 60;
            _initialRotation = 135;

            _gaugeBuilder = new GaugeBuilder
            {
                InnerRadius            = _innerRadius,
                OffsetRadius           = _offsetRadius,
                Background             = new SolidColorPaintTask(new SKColor(0, 0, 0, 10)),
                BackgroundInnerRadius  = _backgroundInnerRadius,
                BackgroundOffsetRadius = _backgroundOffsetRadius,
                LabelFormatter         = point => $"{point.Context.Series.Name} {point.PrimaryValue}",
                LabelsPosition         = PolarLabelsPosition.Start,
                LabelsSize             = 30
            }
            .AddValue(new ObservableValue(10))
            .AddValue(new ObservableValue(25))
            .AddValue(new ObservableValue(40))
            .AddValue(new ObservableValue(50));

            Series = _gaugeBuilder.BuildSeries();
        }
示例#4
0
        public ViewModel()
        {
            GaugeTotal1 = 100;
            Series1     = new GaugeBuilder()
            {
                LabelsSize = 80,
                Background = new RadialGradientPaintTask(new SKColor(167, 192, 205, 0), new SKColor(167, 192, 205))
            }
            .AddValue(new ObservableValue(30))
            .BuildSeries();

            GaugeTotal2      = 100;
            InitialRotation2 = -90;
            Series2          = new GaugeBuilder()
            {
                LabelsSize = 80,
                Background = new RadialGradientPaintTask(new SKColor(167, 192, 205, 0), new SKColor(167, 192, 205))
            }
            .AddValue(new ObservableValue(30))
            .BuildSeries();

            GaugeTotal3      = 100;
            InitialRotation3 = -90;
            Series3          = new GaugeBuilder()
            {
                LabelsSize = 60, InnerRadius = 50
            }
            .AddValue(new ObservableValue(30))
            .BuildSeries();

            GaugeTotal4      = 100;
            InitialRotation4 = -90;
            Series4          = new GaugeBuilder()
            {
                LabelsSize             = 50,
                InnerRadius            = 50,
                BackgroundInnerRadius  = 50,
                BackgroundOffsetRadius = 10
            }
            .AddValue(new ObservableValue(30))
            .BuildSeries();

            GaugeTotal5      = 100;
            InitialRotation5 = -90;
            Series5          = new GaugeBuilder()
            {
                LabelsSize = 50, InnerRadius = 50, OffsetRadius = 10, BackgroundInnerRadius = 50
            }
            .AddValue(new ObservableValue(30))
            .BuildSeries();

            GaugeTotal6      = 100;
            InitialRotation6 = -90;
            Series6          = new GaugeBuilder()
            {
                LabelsSize            = 50,
                InnerRadius           = 50,
                BackgroundInnerRadius = 50,
                Background            = new SolidColorPaintTask(new SKColor(100, 181, 246))
            }
            .AddValue(new ObservableValue(30), null, new SolidColorPaintTask(new SKColor(21, 101, 192)))
            .BuildSeries();

            GaugeTotal7      = 100;
            InitialRotation7 = -90;
            Series7          = new GaugeBuilder()
            {
                LabelsSize            = 50,
                InnerRadius           = 75,
                BackgroundInnerRadius = 50,
                Background            = new SolidColorPaintTask(new SKColor(100, 181, 246, 90))
            }
            .AddValue(new ObservableValue(30), null, new SolidColorPaintTask(new SKColor(21, 101, 192)))
            .BuildSeries();

            GaugeTotal8      = 100;
            InitialRotation8 = -225;
            MaxAngle8        = 270;
            Series8          = new GaugeBuilder()
            {
                LabelsSize            = 50,
                InnerRadius           = 75,
                BackgroundInnerRadius = 50,
                Background            = new SolidColorPaintTask(new SKColor(100, 181, 246, 90))
            }
            .AddValue(new ObservableValue(30), null, new SolidColorPaintTask(new SKColor(21, 101, 192)))
            .BuildSeries();

            GaugeTotal9      = 100;
            InitialRotation9 = 315;
            MaxAngle9        = 270;
            Series9          = new GaugeBuilder()
            {
                LabelsSize            = 50,
                InnerRadius           = 75,
                BackgroundInnerRadius = 50,
                Background            = new SolidColorPaintTask(new SKColor(100, 181, 246, 90))
            }
            .AddValue(new ObservableValue(30), null, new SolidColorPaintTask(new SKColor(21, 101, 192)))
            .BuildSeries();

            GaugeTotal10      = 100;
            InitialRotation10 = -200;
            MaxAngle10        = 220;
            Series10          = new GaugeBuilder()
            {
                LabelsSize            = 30,
                InnerRadius           = 75,
                BackgroundInnerRadius = 50,
                Background            = new LinearGradientPaintTask(new SKColor(250, 243, 224), new SKColor(182, 137, 115))
            }
            .AddValue(new ObservableValue(30), null, new SolidColorPaintTask(new SKColor(30, 33, 45)), new SolidColorPaintTask(new SKColor(30, 33, 45)))
            .BuildSeries();

            GaugeTotal11      = 100;
            InitialRotation11 = -90;
            MaxAngle11        = 270;
            Series11          = new GaugeBuilder()
            {
                LabelsPosition        = PolarLabelsPosition.Start,
                LabelFormatter        = point => point.Context.Series.Name + " " + point.PrimaryValue,
                LabelsSize            = 20,
                InnerRadius           = 20,
                BackgroundInnerRadius = 20
            }
            .AddValue(new ObservableValue(30), "Vanessa")
            .AddValue(new ObservableValue(50), "Charles")
            .AddValue(new ObservableValue(70), "Ana")
            .BuildSeries();

            GaugeTotal12      = 100;
            InitialRotation12 = 45;
            MaxAngle12        = 270;
            Series12          = new GaugeBuilder()
            {
                LabelsPosition        = PolarLabelsPosition.Start,
                LabelFormatter        = point => point.PrimaryValue + " " + point.Context.Series.Name,
                LabelsSize            = 20,
                InnerRadius           = 20,
                OffsetRadius          = 8,
                BackgroundInnerRadius = 20
            }
            .AddValue(new ObservableValue(30), "Vanessa")
            .AddValue(new ObservableValue(50), "Charles")
            .AddValue(new ObservableValue(70), "Ana")
            .BuildSeries();

            GaugeTotal13      = 100;
            InitialRotation13 = 90;
            MaxAngle13        = 270;
            Series13          = new GaugeBuilder()
            {
                LabelsPosition         = PolarLabelsPosition.Start,
                LabelFormatter         = point => point.PrimaryValue + " " + point.Context.Series.Name,
                LabelsSize             = 20,
                InnerRadius            = 20,
                OffsetRadius           = 4,
                BackgroundInnerRadius  = 20,
                BackgroundOffsetRadius = 10
            }
            .AddValue(new ObservableValue(30), "Vanessa")
            .AddValue(new ObservableValue(50), "Charles")
            .AddValue(new ObservableValue(70), "Ana")
            .BuildSeries();

            GaugeTotal14      = 100;
            InitialRotation14 = -90;
            MaxAngle14        = 350;
            Series14          = new GaugeBuilder()
            {
                LabelsPosition       = PolarLabelsPosition.End,
                LabelFormatter       = point => point.PrimaryValue.ToString(),
                LabelsSize           = 20,
                InnerRadius          = 20,
                MaxRadialColumnWidth = 5,
                Background           = null
            }
            .AddValue(new ObservableValue(50), "Vanessa")
            .AddValue(new ObservableValue(80), "Charles")
            .AddValue(new ObservableValue(95), "Ana")
            .BuildSeries();
        }
        public void Name_should_accept_well_formed_names(string name)
        {
            var gb = new GaugeBuilder(new PrometheusRegistry(null));

            gb.Name(name);
        }
        public void Name_throws_ArgumentException_on_invalid_names(string name)
        {
            var gb = new GaugeBuilder(new PrometheusRegistry(null));

            Assert.Throws <ArgumentException>(() => gb.Name(name));
        }