void SetupPlots()
        {
            // Create a plot that uses the data source method
            CPTRangePlot dataSourceLinePlot = new CPTRangePlot();

            dataSourceLinePlot.Identifier = (NSString)"Date Plot";

            // Add line style
            barLineStyle                    = new CPTLineStyle();
            barLineStyle.LineWidth          = 3f;
            barLineStyle.LineColor          = CPTColor.GreenColor;
            dataSourceLinePlot.BarLineStyle = barLineStyle;

            // Bar properties
            dataSourceLinePlot.BarWidth   = 10.0f;
            dataSourceLinePlot.GapWidth   = 20.0f;
            dataSourceLinePlot.GapHeight  = 20.0f;
            dataSourceLinePlot.DataSource = new RangeSource();

            // Add plot
            graph.AddPlot(dataSourceLinePlot);

            areaFillDefault     = CPTFill.FromColor(CPTColor.ClearColor);
            barLineStyleDefault = dataSourceLinePlot.BarLineStyle;

            var space = graph.DefaultPlotSpace as CPTXYPlotSpace;

            space.ScaleToFitPlots(new CPTPlot [] { dataSourceLinePlot });
        }
        void SetupGraph()
        {
            var theme = CPTTheme.ThemeNamed("Plain Black");

            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
            CPTColor transparentGreen = CPTColor.GreenColor;

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

            graph.DefaultPlotSpace.ShouldHandlePointingDeviceUpEvent = delegate {
                CPTRangePlot 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);
            };

//			graph.DefaultPlotSpace.ShouldHandlePointingDeviceUpEvent = delegate {
//				CPTRangePlot rangePlot = (CPTRangePlot)graph.PlotWithIdentifier((NSString)"Date Plot");
//				//TODO: instead of areaFillDefault -> null
//              rangePlot.AreaFill = (
//					rangePlot.AreaFill != null ? null : areaFill);
//              rangePlot.BarLineStyle = (
//					rangePlot.BarLineStyle != null ? null: barLineStyle);
//				return false;
//			};
        }
Example #3
0
		void SetupPlots ()
		{
			// Create a plot that uses the data source method
			var dataSourceLinePlot = new CPTRangePlot ();
			dataSourceLinePlot.Identifier = (NSString)"Date Plot";

			// Add line style
			barLineStyle = new CPTLineStyle();
			barLineStyle.LineWidth = 3f;
			barLineStyle.LineColor = CPTColor.GreenColor;
			dataSourceLinePlot.BarLineStyle = barLineStyle;

			// Bar properties
			dataSourceLinePlot.BarWidth = 10.0f;
			dataSourceLinePlot.GapWidth = 20.0f;
			dataSourceLinePlot.GapHeight = 20.0f;
			dataSourceLinePlot.DataSource = new RangeSource();

			// Add plot
			graph.AddPlot(dataSourceLinePlot);

			areaFillDefault = CPTFill.FromColor(CPTColor.ClearColor);
			barLineStyleDefault = dataSourceLinePlot.BarLineStyle;

			var space = graph.DefaultPlotSpace as CPTXYPlotSpace;
			space.ScaleToFitPlots (new CPTPlot [] { dataSourceLinePlot });
		}