示例#1
0
        void SetupGraph()
        {
            var theme = CPTTheme.ThemeNamed(CPTTheme.PlainBlackTheme);

            graph = new CPTXYGraph {
                PaddingLeft   = 10,
                PaddingRight  = 10,
                PaddingTop    = 10,
                PaddingBottom = 10,
                Title         = "Click to Toggle Range Plot Style",

                TitleTextStyle = new CPTMutableTextStyle {
                    FontSize = 18,
                    FontName = "Helvetica",
                    Color    = CPTColor.GrayColor
                },

                TitleDisplacement = new PointF(0, -20f)
            };
            graph.ApplyTheme(theme);

            // Store area fill for use later
            var transparentGreen = CPTColor.GreenColor;

            areaFill = new CPTFill(transparentGreen.ColorWithAlphaComponent(0.2f));

            graph.DefaultPlotSpace.ShouldHandlePointingDeviceUp = delegate {
                var rangePlot = (CPTRangePlot)graph.PlotWithIdentifier((NSString)"Date Plot");
                // TODO: instead of areaFillDefault -> null (see code below in comment
                rangePlot.AreaFill     = (rangePlot.AreaFill == areaFill ? areaFillDefault : areaFill);
                rangePlot.BarLineStyle = (rangePlot.BarLineStyle == barLineStyleDefault ? barLineStyle: barLineStyleDefault);
                return(false);
            };
        }
示例#2
0
		void SetupGraph ()
		{
			var theme = CPTTheme.ThemeNamed (CPTTheme.PlainBlackTheme);

			graph = new CPTXYGraph {
				PaddingLeft = 10,
				PaddingRight = 10,
				PaddingTop = 10,
				PaddingBottom = 10,
				Title = "Click to Toggle Range Plot Style",

				TitleTextStyle = new CPTMutableTextStyle {
					FontSize = 18,
					FontName = "Helvetica",
					Color = CPTColor.GrayColor
				},

				TitleDisplacement = new PointF (0, -20f)
			};
			graph.ApplyTheme (theme);

			// Store area fill for use later
			var transparentGreen = CPTColor.GreenColor;
			areaFill = new CPTFill (transparentGreen.ColorWithAlphaComponent(0.2f));

			graph.DefaultPlotSpace.ShouldHandlePointingDeviceUp = delegate {
				var rangePlot = (CPTRangePlot) graph.PlotWithIdentifier((NSString)"Date Plot");
				// TODO: instead of areaFillDefault -> null (see code below in comment
				rangePlot.AreaFill = (rangePlot.AreaFill == areaFill ? areaFillDefault : areaFill);
				rangePlot.BarLineStyle = (rangePlot.BarLineStyle == barLineStyleDefault ? barLineStyle: barLineStyleDefault);
				return false;
			};
		}
示例#3
0
        private void Initialize()
        {
            var graph = new CPTXYGraph (this.Frame, CPTScaleType.Linear, CPTScaleType.Linear) {
                Title = "Stock History",
                BackgroundColor = new CGColor(0.982f, 0.982f, 0.890f)
            };

            var host = new CPTGraphHostingView (this.Frame) {
                HostedGraph = graph,
                BackgroundColor = UIColor.Red
            };

            this.AddSubview (host);
            this.BackgroundColor = UIColor.Red;
        }
示例#4
0
        private void Initialize()
        {
            var graph = new CPTXYGraph(this.Frame, CPTScaleType.Linear, CPTScaleType.Linear)
            {
                Title           = "Stock History",
                BackgroundColor = new CGColor(0.982f, 0.982f, 0.890f)
            };

            var host = new CPTGraphHostingView(this.Frame)
            {
                HostedGraph     = graph,
                BackgroundColor = UIColor.Red
            };

            this.AddSubview(host);
            this.BackgroundColor = UIColor.Red;
        }
示例#5
0
        void SetupGraph()
        {
            //@"Dark Gradients";	///< Dark gradient theme.
            //@"Plain White";		///< Plain white theme.
            //@"Plain Black";		///< Plain black theme.
            //@"Slate";		  			///< Slate theme.
            //@"Stocks";				///< Stocks theme.

            var theme = CPTTheme.ThemeNamed ("Dark Gradients");

            graph = new CPTXYGraph (){
                PaddingLeft = 0,
                PaddingRight = 0,
                PaddingTop = 0,
                PaddingBottom = 0
            };
            graph.ApplyTheme (theme);
        }
示例#6
0
 void SetupGraph ()
 {
     var theme = CPTTheme.ThemeNamed ("Plain Black");
     
     graph = new CPTXYGraph (new RectangleF (0, 0, 300, 300), CPTScaleType.Linear, CPTScaleType.Linear){
         PaddingLeft = 10,
         PaddingRight = 10,
         PaddingTop = 10,
         PaddingBottom = 10,
         Title = "My graph",
         
         TitleTextStyle = new CPTMutableTextStyle {
             FontSize = 18,
             FontName = "Helvetica",
             Color = CPTColor.GrayColor
         }
     };
     graph.ApplyTheme (theme);
 }
示例#7
0
        void SetupGraph()
        {
            //@"Dark Gradients";	///< Dark gradient theme.
            //@"Plain White";		///< Plain white theme.
            //@"Plain Black";		///< Plain black theme.
            //@"Slate";		            ///< Slate theme.
            //@"Stocks";				///< Stocks theme.

            var theme = CPTTheme.ThemeNamed("Dark Gradients");

            graph = new CPTXYGraph()
            {
                PaddingLeft   = 0,
                PaddingRight  = 0,
                PaddingTop    = 0,
                PaddingBottom = 0
            };
            graph.ApplyTheme(theme);
        }
示例#8
0
        void SetupGraph()
        {
            /*
             *  Dark Gradients => Dark gradient theme.
             *  Plain White    => Plain white theme.
             *  Plain Black    => Plain black theme.
             *  Slate          => Slate theme.
             *  Stocks         => Stocks theme.
             */

            var theme = CPTTheme.ThemeNamed("Dark Gradients");

            graph = new CPTXYGraph {
                PaddingLeft   = 0,
                PaddingRight  = 0,
                PaddingTop    = 0,
                PaddingBottom = 0
            };
            graph.ApplyTheme(theme);
        }
示例#9
0
        void SetupGraph()
        {
            /*
                Dark Gradients => Dark gradient theme.
                Plain White    => Plain white theme.
                Plain Black    => Plain black theme.
                Slate          => Slate theme.
                Stocks         => Stocks theme.
            */

            var theme = CPTTheme.ThemeNamed ("Dark Gradients");

            graph = new CPTXYGraph {
                PaddingLeft = 0,
                PaddingRight = 0,
                PaddingTop = 0,
                PaddingBottom = 0
            };
            graph.ApplyTheme (theme);
        }
示例#10
0
        void SetupGraph()
        {
            var theme = CPTTheme.ThemeNamed("Plain Black");

            graph = new CPTXYGraph(new RectangleF(0, 0, 300, 300), CPTScaleType.Linear, CPTScaleType.Linear)
            {
                PaddingLeft   = 10,
                PaddingRight  = 10,
                PaddingTop    = 10,
                PaddingBottom = 10,
                Title         = "My graph",

                TitleTextStyle = new CPTMutableTextStyle {
                    FontSize = 18,
                    FontName = "Helvetica",
                    Color    = CPTColor.GrayColor
                }
            };
            graph.ApplyTheme(theme);
        }
示例#11
0
		void SetupGraph ()
		{
			var theme = CPTTheme.ThemeNamed (CPTTheme.PlainBlackTheme);
			
			graph = new CPTXYGraph (new RectangleF (0, 0, 300, 300), CPTScaleType.Linear, CPTScaleType.Linear){
				PaddingLeft = 0,
				PaddingRight = 0,
				PaddingTop = 0,
				PaddingBottom = 0,
				Title = "Bar Chart",
				
				TitleTextStyle = new CPTMutableTextStyle {
					FontSize = 18,
					FontName = "Helvetica",
					Color = CPTColor.GrayColor
				},
				TitleDisplacement = new PointF(0, -20f)
			};
			graph.ApplyTheme (theme);
		}
示例#12
0
        void SetupGraph()
        {
            var theme = CPTTheme.ThemeNamed(CPTTheme.PlainBlackTheme);

            graph = new CPTXYGraph(new RectangleF(0, 0, 300, 300), CPTScaleType.Linear, CPTScaleType.Linear)
            {
                PaddingLeft   = 0,
                PaddingRight  = 0,
                PaddingTop    = 0,
                PaddingBottom = 0,
                Title         = "Bar Chart",

                TitleTextStyle = new CPTMutableTextStyle {
                    FontSize = 18,
                    FontName = "Helvetica",
                    Color    = CPTColor.GrayColor
                },
                TitleDisplacement = new PointF(0, -20f)
            };
            graph.ApplyTheme(theme);
        }
示例#13
0
        public virtual void AwakeFromNib()
        {
            // If you make sure your dates are calculated at noon, you shouldn't have to
            // worry about daylight savings. If you use midnight, you will have to adjust
            // for daylight savings time.
            NSDate refDate = NSDate.DateWithNaturalLanguageString ("12:00 Oct 27, 2010");
            double oneDay = 24 * 60 * 60;

            // Create graph from theme
            graph = new CPTXYGraph (CGRect.CGRectZero);
            CPTTheme theme = CPTTheme.ThemeNamed (CPTTheme.kCPTDarkGradientTheme);
            graph.ApplyTheme (theme);
            hostView.HostedGraph = graph;

            // Title
            CPTMutableTextStyle textStyle = CPTMutableTextStyle.TextStyle;
            textStyle.Color = CPTColor.WhiteColor;
            textStyle.FontSize = 18.0;
            textStyle.FontName = "Helvetica";
            graph.Title = "Click to Toggle Range Plot Style";
            graph.TitleTextStyle = textStyle;
            graph.TitleDisplacement = new CGPoint (0.0f, -20.0f);

            // Setup scatter plot space
            CPTXYPlotSpace plotSpace = graph.DefaultPlotSpace.CastTo<CPTXYPlotSpace> ();
            double xLow = oneDay * 0.5;
            plotSpace.XRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (xLow), NSDecimal.FromDouble (oneDay * 5.0));
            plotSpace.YRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (1.0), NSDecimal.FromDouble (3.0));

            // Axes
            CPTXYAxisSet axisSet = graph.AxisSet.CastTo<CPTXYAxisSet> ();
            CPTXYAxis x = axisSet.XAxis;
            x.MajorIntervalLength = NSDecimal.FromDouble (oneDay);
            x.OrthogonalCoordinateDecimal = NSDecimal.FromString ("2");
            x.MinorTicksPerInterval = 0;
            NSDateFormatter dateFormatter = new NSDateFormatter ().Autorelease<NSDateFormatter> ();
            dateFormatter.DateStyle = NSDateFormatterStyle.NSDateFormatterShortStyle;
            CPTTimeFormatter timeFormatter = new CPTTimeFormatter (dateFormatter).Autorelease<CPTTimeFormatter> ();
            timeFormatter.ReferenceDate = refDate;
            x.LabelFormatter = timeFormatter;

            CPTXYAxis y = axisSet.YAxis;
            y.MajorIntervalLength = NSDecimal.FromString (@"0.5");
            y.MinorTicksPerInterval = 5;
            y.OrthogonalCoordinateDecimal = NSDecimal.FromDouble (oneDay);

            // Create a plot that uses the data source method
            CPTRangePlot dataSourceLinePlot = new CPTRangePlot ().Autorelease<CPTRangePlot> ();
            dataSourceLinePlot.Identifier = PLOT_IDENTIFIER;

            // Add line style
            CPTMutableLineStyle lineStyle = CPTMutableLineStyle.LineStyle;
            lineStyle.LineWidth = 1.0;
            lineStyle.LineColor = CPTColor.GreenColor;
            barLineStyle = lineStyle.Retain<CPTLineStyle> ();
            dataSourceLinePlot.BarLineStyle = barLineStyle;

            // Bar properties
            dataSourceLinePlot.BarWidth = 10.0;
            dataSourceLinePlot.GapWidth = 20.0;
            dataSourceLinePlot.GapHeight = 20.0;
            dataSourceLinePlot.DataSource = this;

            // Add plot
            graph.AddPlot (dataSourceLinePlot);
            graph.DefaultPlotSpace.Delegate = this;

            // Store area fill for use later
            CPTColor transparentGreen = CPTColor.GreenColor.ColorWithAlphaComponent (0.2);
            areaFill = new CPTFill (transparentGreen);

            // Add some data
            NSMutableArray newData = new NSMutableArray();
            NSUInteger i;
            Random rand = new Random ();
            for (i = 0; i < 5; i++) {
                double xx = oneDay * (i + 1.0);
                double yy = 3.0 * rand.Next () / (double)Int32.MaxValue + 1.2;
                double rHigh = rand.Next () / (double)Int32.MaxValue * 0.5 + 0.25;
                double rLow = rand.Next () / (double)Int32.MaxValue * 0.5 + 0.25;
                double rLeft = (rand.Next () / (double)Int32.MaxValue * 0.125 + 0.125) * oneDay;
                double rRight = (rand.Next () / (double)Int32.MaxValue * 0.125 + 0.125) * oneDay;

                newData.AddObject (NSDictionary.DictionaryWithObjectsAndKeys (
                                                                              NSDecimalNumber.NumberWithDouble (xx), CPTRangePlot.FieldX,
                                                                              NSDecimalNumber.NumberWithDouble (yy), CPTRangePlot.FieldY,
                                                                              NSDecimalNumber.NumberWithDouble (rHigh), CPTRangePlot.FieldHigh,
                                                                              NSDecimalNumber.NumberWithDouble (rLow), CPTRangePlot.FieldLow,
                                                                              NSDecimalNumber.NumberWithDouble (rLeft), CPTRangePlot.FieldLeft,
                                                                              NSDecimalNumber.NumberWithDouble (rRight), CPTRangePlot.FieldRight,
                                                                              null));
            }

            plotData = newData;
        }
示例#14
0
        public virtual void AwakeFromNib()
        {
            // If you make sure your dates are calculated at noon, you shouldn't have to
            // worry about daylight savings. If you use midnight, you will have to adjust
            // for daylight savings time.
            NSDate refDate = NSDate.DateWithNaturalLanguageString ("12:00 Oct 27, 2010");
            double oneDay = 24 * 60 * 60;

            // Create graph from theme
            graph = new CPTXYGraph (CGRect.CGRectZero);
            CPTTheme theme = CPTTheme.ThemeNamed (CPTTheme.kCPTDarkGradientTheme);
            graph.ApplyTheme (theme);
            hostView.HostedGraph = graph;

            // Setup scatter plot space
            CPTXYPlotSpace plotSpace = graph.DefaultPlotSpace.CastTo<CPTXYPlotSpace> ();
            double xLow = oneDay * 0.5;
            plotSpace.XRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (xLow), NSDecimal.FromDouble (oneDay * 5.0));
            plotSpace.YRange = CPTPlotRange.PlotRangeWithLocationLength (NSDecimal.FromDouble (1.0), NSDecimal.FromDouble (3.0));

            // Axes
            CPTXYAxisSet axisSet = graph.AxisSet.CastTo<CPTXYAxisSet> ();
            CPTXYAxis x = axisSet.XAxis;
            x.MajorIntervalLength = NSDecimal.FromDouble (oneDay);
            x.OrthogonalCoordinateDecimal = NSDecimal.FromString ("2");
            x.MinorTicksPerInterval = 0;
            NSDateFormatter dateFormatter = new NSDateFormatter ().Autorelease<NSDateFormatter> ();
            dateFormatter.DateStyle = NSDateFormatterStyle.NSDateFormatterShortStyle;
            CPTTimeFormatter timeFormatter = new CPTTimeFormatter (dateFormatter).Autorelease<CPTTimeFormatter> ();
            timeFormatter.ReferenceDate = refDate;
            x.LabelFormatter = timeFormatter;

            CPTXYAxis y = axisSet.YAxis;
            y.MajorIntervalLength = NSDecimal.FromString (@"0.5");
            y.MinorTicksPerInterval = 5;
            y.OrthogonalCoordinateDecimal = NSDecimal.FromDouble (oneDay);

            // Create a plot that uses the data source method
            CPTScatterPlot dataSourceLinePlot = new CPTScatterPlot ().Autorelease<CPTScatterPlot> ();
            dataSourceLinePlot.Identifier = PLOT_IDENTIFIER;

            // Add line style
            CPTMutableLineStyle lineStyle = CPTMutableLineStyle.LineStyle;
            lineStyle.LineWidth = 3.0;
            lineStyle.LineColor = CPTColor.GreenColor;
            dataSourceLinePlot.DataLineStyle = lineStyle;

            // Add plot
            graph.AddPlot (dataSourceLinePlot);
            dataSourceLinePlot.DataSource = this;

            // Add some data
            NSMutableArray newData = new NSMutableArray();
            NSUInteger i;
            Random rand = new Random ();
            for (i = 0; i < 5; i++) {
                double xx = oneDay * (i + 1.0);
                double yy = 3.0 * rand.Next () / (double)Int32.MaxValue + 1.2;

                newData.AddObject (NSDictionary.DictionaryWithObjectsAndKeys (
                                                                              NSDecimalNumber.NumberWithDouble (xx), CPTScatterPlot.FieldX,
                                                                              NSDecimalNumber.NumberWithDouble (yy), CPTScatterPlot.FieldY,
                                                                              null));
            }

            plotData = newData;
        }