public static void CreateChart(string imagePath,string name, IEnumerable<BenchResult> results, Func<BenchResult,double> selector)
        {
            Chart chart = new Chart();
            chart.Width = 500;
            chart.Height = 400;
            chart.Titles.Add(name);
            var area = new ChartArea("Default");
            chart.ChartAreas.Add(area);
            var series = new Series("Default");
            chart.Series.Add(series);
            area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90;
            area.AxisX.LabelStyle.TruncatedLabels = false;
            area.AxisX.Interval = 1;
            series.ChartType = SeriesChartType.Column;
            series.IsValueShownAsLabel = true;
            series.XValueType = ChartValueType.String;

            series.YValueType = ChartValueType.Int32;

            foreach(var r in results.OrderBy( r => selector(r)))
            {
                DataPoint point = new DataPoint();
                point.SetValueXY(r.Serializer.Replace("Adapter",""),(int)Math.Round(selector(r)));
                point.AxisLabel = r.Serializer.Replace("Adapter", "");
                series.Points.Add(point);
            }

            chart.SaveImage(imagePath, ChartImageFormat.Png);
        }
Beispiel #2
0
        public MemoryStream BuildChart(int? type, IDictionary<string, float> dataPoints)
        {
            // default to line
            var chartType = type == null ? SeriesChartType.Line : (SeriesChartType)type;

            var chart = new Chart();

            // configure your chart area (dimensions, etc) here.
            var area = new ChartArea();
            chart.ChartAreas.Add(area);
            TickMark tm = new TickMark();

            // create and customize your data series.
            var series = new Series();
            foreach (var item in dataPoints)
            {
                series.Points.AddXY(item.Key, item.Value);
            }

            //series.Label = "#PERCENT{P0}";
            series.Font = new Font("Segoe UI", 8.0f, FontStyle.Bold);
            series.ChartType = chartType;
            series["PieLabelStyle"] = "Outside";

            chart.Series.Add(series);

            var returnStream = new MemoryStream();
            chart.ImageType = ChartImageType.Png;
            chart.SaveImage(returnStream);
            returnStream.Position = 0;

            return returnStream;
        }
Beispiel #3
0
		public ChartWindow(CandleSeries candleSeries, DateTime from, DateTime to)
		{
			InitializeComponent();

			if (candleSeries == null)
				throw new ArgumentNullException("candleSeries");

			_candleSeries = candleSeries;
			_trader = MainWindow.Instance.Trader;

			Chart.ChartTheme = "ExpressionDark";

			var area = new ChartArea();
			Chart.Areas.Add(area);

			_candleElem = new ChartCandleElement
			{
				Antialiasing = false, 
				UpFillColor = Colors.White,
				UpBorderColor = Colors.Black,
				DownFillColor = Colors.Black,
				DownBorderColor = Colors.Black,
			};

			area.Elements.Add(_candleElem);

			_trader.NewCandles += ProcessNewCandles;
			_trader.SubscribeCandles(_candleSeries, from, to);
		}
        public ActionResult Details(int width = 500, int height = 500)
        {
            var chart = new Chart { Height = height, Width = width };
            var chartArea = new ChartArea("Area1")
            {
                AxisX = { Interval = 1 },
                Area3DStyle = { Enable3D = true },
                BackColor = Color.Transparent
            };
            chart.ChartAreas.Add(chartArea);

            chart.BackColor = Color.Transparent;

            var seriescountAll = new Series("项目统计");
            var countAll =
                _iProjectInfoStateService.GetAll()
                    .Select(a => new { Key = a.ProjectInfoStateName, Count = a.ProjectInfos.Count(b => !b.Deleted) });
            seriescountAll.ChartArea = "Area1";
            seriescountAll.IsVisibleInLegend = true;
            seriescountAll.IsValueShownAsLabel = true;
            seriescountAll.Label = "#VALX  #VALY";
            seriescountAll.Points.DataBind(countAll, "Key", "Count", "");
            seriescountAll.ChartType = SeriesChartType.Funnel;
            chart.Series.Add(seriescountAll);

            var imageStream = new MemoryStream();
            chart.SaveImage(imageStream, ChartImageFormat.Png);
            imageStream.Position = 0;
            return new FileStreamResult(imageStream, "image/png");
        }
		public ChartWindow(CandleSeries candleSeries)
		{
			InitializeComponent();

			if (candleSeries.IsNull())
				throw new ArgumentNullException("candleSeries");

			_candleSeries = candleSeries;
			_trader = MainWindow.Instance.Trader;

			Chart.ChartTheme = "ExpressionDark";

			var area = new ChartArea();
			Chart.Areas.Add(area);

			_candleElem = new ChartCandleElement
			{
				Antialiasing = false, 
				UpFillColor = Colors.White,
				UpBorderColor = Colors.Black,
				DownFillColor = Colors.Black,
				DownBorderColor = Colors.Black,
			};

			area.Elements.Add(_candleElem);

			_trader.NewCandles += ProcessNewCandles;
			_trader.SubscribeCandles(_candleSeries, DateTime.Today - TimeSpan.FromTicks(((TimeSpan)candleSeries.Arg).Ticks * 100), DateTimeOffset.MaxValue);
		}
Beispiel #6
0
		public CursorEventArgs(ChartArea chartArea, Axis axis, double newSelectionStart, double newSelectionEnd)
		{
			this.ChartArea = chartArea;
			this.Axis = axis;
			this.NewSelectionStart = newSelectionStart;
			this.NewSelectionEnd = newSelectionEnd;
		}
 public ChartArea CreateColumnChartArea()
 {
     ChartArea chartArea = new ChartArea();
     chartArea.Name = "Result Chart";
     chartArea.BackColor = Color.Transparent;
     chartArea.AxisX.IsLabelAutoFit = false;
     chartArea.AxisY.IsLabelAutoFit = false;
     chartArea.AxisX.LabelStyle.Font =
        new Font("Verdana,Arial,Helvetica,sans-serif",
                 8F, FontStyle.Regular);
     chartArea.AxisY.LabelStyle.Font =
        new Font("Verdana,Arial,Helvetica,sans-serif",
                 8F, FontStyle.Regular);
     chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.Interval = 1;
     chartArea.AxisX.LabelStyle.Enabled = false;
     chartArea.Position.Height = 80;
     chartArea.Position.Width = 85;
     chartArea.Position.X = 2;
     chartArea.Position.Y = 14;
     return chartArea;
 }
		public HistoryCandlesWindow(Security security)
		{
			if (security == null)
				throw new ArgumentNullException("security");

			_security = security;

			InitializeComponent();
			Title = _security.Code + LocalizedStrings.Str3747;

			TimeFramePicker.ItemsSource = new[]
			{
				TimeSpan.FromMinutes(1),
				TimeSpan.FromMinutes(5),
				TimeSpan.FromMinutes(15),
				TimeSpan.FromMinutes(60),
				TimeSpan.FromDays(1),
				TimeSpan.FromDays(7),
				TimeSpan.FromTicks(TimeHelper.TicksPerMonth)
			};
			TimeFramePicker.SelectedIndex = 1;

			DateFromPicker.Value = DateTime.Today.AddDays(-7);
			DateToPicker.Value = DateTime.Today;

			var area = new ChartArea();
			_candlesElem = new ChartCandleElement();
			area.Elements.Add(_candlesElem);

			Chart.Areas.Add(area);
		}
		public MainWindow()
		{
			InitializeComponent();

			_logManager.Listeners.Add(new GuiLogListener(LogControl));

			_area = new ChartArea();
			_chart.Areas.Add(_area);
		}
Beispiel #10
0
		public MainWindow()
		{
			InitializeComponent();

			_area = new ChartArea();
			Chart.Areas.Add(_area);

			// попробовать сразу найти месторасположение Quik по запущенному процессу
			Path.Text = QuikTerminal.GetDefaultPath();
		}
		public ChartWindow()
		{
			InitializeComponent();

			var area = new ChartArea();
			Chart.Areas.Add(area);

			_candlesElem = new ChartCandleElement();
			area.Elements.Add(_candlesElem);
		}
        public FileResult Details(int width = 1000, int height = 618)
        {
            var sysUserLog = _sysUserLogService.GetAllEnt();
            var sysLog = _sysLogService.GetAllEnt();

            var chart = new Chart { Height = height, Width = width };
            var chartArea = new ChartArea("Area1") {AxisX = {Interval = 1}};
            chart.ChartAreas.Add(chartArea);
            var legend = new Legend();
            chart.Legends.Add(legend);

            var seriescountAll = new Series("使用次数");
            var countAll =
                sysUserLog.GroupBy(a => EntityFunctions.TruncateTime(a.CreatedDate))
                         .Select(a => new { Key = a.Key.Value, Count = a.Count() })
                         .OrderBy(a => a.Key);
            seriescountAll.ChartArea = "Area1";
            seriescountAll.IsVisibleInLegend = true;
            seriescountAll.IsValueShownAsLabel = true;
            seriescountAll.Points.DataBind(countAll, "Key", "Count", "");
            seriescountAll.ChartType = SeriesChartType.Column;
            chart.Series.Add(seriescountAll);


            var seriescountUser = new Series("登陆用户数量");
            var countUser =
                sysUserLog.GroupBy(a => EntityFunctions.TruncateTime(a.CreatedDate)).Select(
                    a => new { Key = a.Key.Value, Count = a.Select(c => c.SysUserId).Distinct().Count() })
                         .OrderBy(a => a.Key);
            seriescountUser.ChartArea = "Area1";
            seriescountUser.IsVisibleInLegend = true;
            seriescountUser.IsValueShownAsLabel = true;
            seriescountUser.Points.DataBind(countUser, "Key", "Count", "");
            seriescountUser.ChartType = SeriesChartType.Column;
            chart.Series.Add(seriescountUser);


            var seriessysLogChart = new Series("系统日志");
            var sysLogChart =
                sysLog.GroupBy(a => EntityFunctions.TruncateTime(a.CreatedDate))
                      .Select(a => new { Key = a.Key.Value, Count = a.Count() })
                      .OrderBy(a => a.Key);
            seriessysLogChart.ChartArea = "Area1";
            seriessysLogChart.IsVisibleInLegend = true;
            seriessysLogChart.IsValueShownAsLabel = true;
            seriessysLogChart.Points.DataBind(sysLogChart, "Key", "Count", "");
            seriessysLogChart.ChartType = SeriesChartType.Column;
            chart.Series.Add(seriessysLogChart);


            var imageStream = new MemoryStream();
            chart.SaveImage(imageStream, ChartImageFormat.Png);
            imageStream.Position = 0;
            return new FileStreamResult(imageStream, "image/png");
        }
		public ChartAddElementCommand(ChartArea area, IChartElement element)
		{
			if (area == null)
				throw new ArgumentNullException("area");

			if (element == null)
				throw new ArgumentNullException("element");

			Area = area;
			Element = element;
		}
		public ChartRemoveElementCommand(ChartArea area, IChartElement element)
		{
			if (area == null)
				throw new ArgumentNullException(nameof(area));

			if (element == null)
				throw new ArgumentNullException(nameof(element));

			Area = area;
			Element = element;
		}
		public ChartAddElementCommand(ChartArea area, IChartElement element, CandleSeries series = null)
		{
			if (area == null)
				throw new ArgumentNullException(nameof(area));

			if (element == null)
				throw new ArgumentNullException(nameof(element));

			Area = area;
			Element = element;
			Series = series;
		}
 private Chart GenerateChartConrol()
 {
     var testChart = new Chart { ImageStorageMode = ImageStorageMode.UseImageLocation };
     var tmpSeria = GenerateSeria();
     var tmpChartArea = new ChartArea("");
     testChart.ChartAreas.Add(tmpChartArea);
     testChart.Legends.Add(new Legend(""));
     testChart.Series.Add(tmpSeria);
     testChart.Width = Parameters.ChartWidth;
     testChart.Height = Parameters.ChartHeight;
     return testChart;
 }
        protected override ChartArea CreateChartArea()
        {
            ChartArea chartArea = new ChartArea();
            chartArea.AxisX.IsMarginVisible = false;
            chartArea.AxisX.LabelStyle.Enabled = false;
            chartArea.BorderDashStyle = ChartDashStyle.NotSet;

            ConfigureAxis(chartArea.AxisX);
            ConfigureAxis(chartArea.AxisY);

            return chartArea;
        }
Beispiel #18
0
        /// <summary>
        /// Creates Y axis for the specified series.
        /// </summary>
        /// <param name="chart">Chart control.</param>
        /// <param name="area">Original chart area.</param>
        /// <param name="series">Series.</param>
        /// <param name="axisOffset">New Y axis offset in relative coordinates.</param>
        /// <param name="labelsSize">Extar space for new Y axis labels in relative coordinates.</param>
        public void CreateYAxis(Chart chart, ChartArea area, Series series, float axisOffset, float labelsSize)
        {
            // Create new chart area for original series
            ChartArea areaSeries = chart.ChartAreas.Add("ChartArea_" + series.Name);
            areaSeries.BackColor = Color.Transparent;
            areaSeries.BorderColor = Color.Transparent;
            areaSeries.Position.FromRectangleF(area.Position.ToRectangleF());
            areaSeries.InnerPlotPosition.FromRectangleF(area.InnerPlotPosition.ToRectangleF());
            areaSeries.AxisX.MajorGrid.Enabled = false;
            areaSeries.AxisX.MajorTickMark.Enabled = false;
            areaSeries.AxisX.LabelStyle.Enabled = false;
            areaSeries.AxisY.MajorGrid.Enabled = false;
            areaSeries.AxisY.MajorTickMark.Enabled = false;
            areaSeries.AxisY.LabelStyle.Enabled = false;
            areaSeries.AxisY.IsStartedFromZero = area.AxisY.IsStartedFromZero;

            series.ChartArea = areaSeries.Name;

            // Create new chart area for axis
            ChartArea areaAxis = chart.ChartAreas.Add("AxisY_" + series.ChartArea);
            areaAxis.BackColor = Color.Transparent;
            areaAxis.BorderColor = Color.Transparent;
            areaAxis.Position.FromRectangleF(chart.ChartAreas[series.ChartArea].Position.ToRectangleF());
            areaAxis.InnerPlotPosition.FromRectangleF(chart.ChartAreas[series.ChartArea].InnerPlotPosition.ToRectangleF());

            // Create a copy of specified series
            Series seriesCopy = chart.Series.Add(series.Name + "_Copy");
            seriesCopy.ChartType = series.ChartType;
            foreach(DataPoint point in series.Points)
            {
                seriesCopy.Points.AddXY(point.XValue, point.YValues[0]);
            }

            // Hide copied series
            seriesCopy.IsVisibleInLegend = false;
            seriesCopy.Color = Color.Transparent;
            seriesCopy.BorderColor = Color.Transparent;
            seriesCopy.ChartArea = areaAxis.Name;

            // Disable drid lines & tickmarks
            areaAxis.AxisX.LineWidth = 0;
            areaAxis.AxisX.MajorGrid.Enabled = false;
            areaAxis.AxisX.MajorTickMark.Enabled = false;
            areaAxis.AxisX.LabelStyle.Enabled = false;
            areaAxis.AxisY.MajorGrid.Enabled = false;
            areaAxis.AxisY.IsStartedFromZero = area.AxisY.IsStartedFromZero;
            areaAxis.AxisY.LabelStyle.Font = area.AxisY.LabelStyle.Font;

            // Adjust area position
            areaAxis.Position.X -= axisOffset;
            areaAxis.InnerPlotPosition.X += labelsSize;
        }
Beispiel #19
0
    private void AddNewChartArea(int areaIndex)
    {
        if (areaIndex >= mChart.ChartAreas.Count)
        {
            ChartArea ca = new ChartArea("mChartArea" + mChart.ChartAreas.Count);

            mChart.ChartAreas.Add(ca);

            if (areaIndex >= mChart.ChartAreas.Count)
                AddNewChartArea(areaIndex);
            else
                return;
        }
    }
Beispiel #20
0
		protected override void OnStarted()
		{
			_series = new CandleSeries(typeof(TimeFrameCandle), Security, TimeFrame);

			_shortSma.Length = ShortSmaPeriod;
			_longSma.Length = LongSmaPeriod;

			if (_area == null)
			{
				_area = new ChartArea();

				_area.Elements.Add(new ChartCandleElement());
				_area.Elements.Add(new ChartIndicatorElement { Color = Colors.Green, StrokeThickness = 1 });
				_area.Elements.Add(new ChartIndicatorElement { Color = Colors.Red, StrokeThickness = 1 });
				_area.Elements.Add(new ChartTradeElement());

				new ChartAddAreaCommand(_area).Process(this);
			}

			this
				.WhenNewMyTrades()
				.Do(trades =>
				{
					foreach (var myTrade in trades)
					{
						new ChartDrawCommand(myTrade.Trade.Time, new Dictionary<IChartElement, object>
						{
							{ _area.Elements[3], myTrade }
						}).Process(this);
					}
				})
				.Apply(this);

			_series
				.WhenCandles()
				.Do(Process)
				.Apply(this);

			this.GetCandleManager().Start(_series);

			Security
				.WhenMarketDepthChanged(SafeGetConnector())
				.Do(md => new UpdateMarketDepthCommand(md).Process(this))
				.Apply(this);

			SafeGetConnector().RegisterMarketDepth(Security);

			base.OnStarted();
		}
Beispiel #21
0
		public MainWindow()
		{
			InitializeComponent();

			_logManager = new LogManager();
			_logManager.Listeners.Add(new GuiLogListener(Log));

			var area = new ChartArea();
			Chart.Areas.Add(area);

			_candlesElem = new ChartCandleElement();
			area.Elements.Add(_candlesElem);

			GuiDispatcher.GlobalDispatcher.AddPeriodicalAction(ProcessCandles);
		}
Beispiel #22
0
 public ChartArea CreateChartArea()
 {
     var chartArea = new ChartArea();
     chartArea.Name = "Sales Chart";
     chartArea.BackColor = Color.Transparent;
     chartArea.AxisX.IsLabelAutoFit = false;
     chartArea.AxisY.IsLabelAutoFit = false;
     chartArea.AxisX.LabelStyle.Font = new Font("Verdana,Arial,Helvetica,sans-serif", 8F, FontStyle.Regular);
     chartArea.AxisY.LabelStyle.Font = new Font("Verdana,Arial,Helvetica,sans-serif", 8F, FontStyle.Regular);
     chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.Interval = 1;
     return chartArea;
 }
 public ChartAreaSettingsWrapper(ChartArea area)
 {
     Background = new BackgroundSettingsWrapper(area.Background);
     CornerBottomLeft = area.CornerBottomLeft;
     CornerBottomRight = area.CornerBottomRight;
     CornerSize = area.CornerSize;
     CornerTopLeft = area.CornerTopLeft;
     CornerTopRight = area.CornerTopRight;
     DefaultCorner = area.DefaultCorner;
     Label = new LabelSettingsWrapper(area.Label);
     LegendBox = new LegendBoxSettingsWrapper(area.LegendBox);
     Shadow = new ShadowSettingsWrapper(area.Shadow);
     Title = area.Title;
     TitleBox = new BoxSettingsWrapper(area.TitleBox);
     XAxis = new AxisSettingsWrapper(area.XAxis);
     YAxis = new AxisSettingsWrapper(area.YAxis);
 }
Beispiel #24
0
        public Chart2D()
        {
            InitializeComponent();

            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            _synchronizationContext = SynchronizationContext.Current;

            _area = new ChartArea(this);
            _grid = new Grid2D(this);
            _title = new ChartTitle(this);
            _labels = new AxesLabels(this);
            _axes = new Axes2D(this);

            _seriesList = new List<Series2D>();
            _areaSeriesList = new List<AreaSeries2D>();
        }
 /// <summary>
 /// Восстановить сохранненые значения.
 /// </summary>
 public void RestoreSettings(ChartArea area)
 {
     Background.RestoreSettings(area.Background);
     area.CornerBottomLeft = CornerBottomLeft;
     area.CornerBottomRight = CornerBottomRight;
     area.CornerSize = CornerSize;
     area.CornerTopLeft = CornerTopLeft;
     area.CornerTopRight = CornerTopRight;
     area.DefaultCorner = DefaultCorner;
     Label.RestoreSettings(area.Label);
     LegendBox.RestoreSettings(area.LegendBox);
     Shadow.RestoreSettings(area.Shadow);
     area.Title = Title;
     TitleBox.RestoreSettings(area.TitleBox);
     XAxis.RestoreSettings(area.XAxis);
     YAxis.RestoreSettings(area.YAxis);
 }
		public MainWindow()
		{
			InitializeComponent();

			_logManager = new LogManager();
			_logManager.Listeners.Add(new GuiLogListener(Log));

			var area = new ChartArea();
			Chart.Areas.Add(area);

			_candlesElem = new ChartCandleElement();
			area.Elements.Add(_candlesElem);

			GuiDispatcher.GlobalDispatcher.AddPeriodicalAction(ProcessCandles);

			Level1AddressCtrl.Text = IQFeedAddresses.DefaultLevel1Address.To<string>();
			Level2AddressCtrl.Text = IQFeedAddresses.DefaultLevel2Address.To<string>();
			LookupAddressCtrl.Text = IQFeedAddresses.DefaultLookupAddress.To<string>();
		}
		public HistoryCandlesWindow(Security security)
		{
			if (security == null)
				throw new ArgumentNullException(nameof(security));

			_security = security;

			InitializeComponent();
			Title = _security.Code + LocalizedStrings.Str3747;

			TimeFramePicker.ItemsSource = IQFeedMarketDataMessageAdapter.TimeFrames;
			TimeFramePicker.SelectedIndex = 1;

			DateFromPicker.Value = DateTime.Today.AddDays(-7);
			DateToPicker.Value = DateTime.Today;

			var area = new ChartArea();
			_candlesElem = new ChartCandleElement();
			area.Elements.Add(_candlesElem);

			Chart.Areas.Add(area);
		}
        public ChartArea CreateChartArea(string name, string yAxisTitle = "Chaos Orb Equivalent")
        {
            ChartArea chartArea = new ChartArea();
            chartArea.Name = name;
            chartArea.BackColor = Color.Transparent;
            chartArea.AxisY.Title = yAxisTitle;
            chartArea.AxisX.IsLabelAutoFit = false;
            chartArea.AxisY.IsLabelAutoFit = false;
            chartArea.AxisX.LabelStyle.Font =
               new Font("Verdana,Arial,Helvetica,sans-serif",
                        7F, FontStyle.Regular);
            chartArea.AxisY.LabelStyle.Font =
               new Font("Verdana,Arial,Helvetica,sans-serif",
                        7F, FontStyle.Regular);
            chartArea.AxisX.LabelStyle.Angle = 15;
            chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
            chartArea.AxisX.Interval = 2;

            return chartArea;
        }
Beispiel #29
0
        public MainWindow()
        {
            InitializeComponent();
            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

            this.Title = String.Format("{0} - {1}", this._version, MainOptVarItem);

            // изменяет текущий формат, чтобы нецелое числа интерпритировалось как разделенное точкой.
            var cci = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name) { NumberFormat = { NumberDecimalSeparator = "." } };
            Thread.CurrentThread.CurrentCulture = cci;

            SetDefaultHistoryRange();

            // попробовать сразу найти месторасположение Quik по запущенному процессу
            this.Path.Text = QuikTerminal.GetDefaultPath();

            _area = new ChartArea();
            _chart.Areas.Add(_area);

            _logManager.Sources.Add(_log);
            _logManager.Listeners.Add(new GuiLogListener(Monitor));
            _logManager.Listeners.Add(new EmailUnitedLogListener());
            _logManager.Listeners.Add(new JabberLogListener());
        }
 public ChartArea CreateChartArea()
 {
     var chartArea = new ChartArea
     {
         Name = "Position Chart",
         BackColor = Color.Transparent,
         AxisX = {IsLabelAutoFit = false},
         AxisY = {IsLabelAutoFit = false},
     };
     chartArea.AxisX.LabelStyle.Font =
        new Font("Verdana,Arial,Helvetica,sans-serif",
                 8F, FontStyle.Regular);
     chartArea.AxisY.LabelStyle.Font =
        new Font("Verdana,Arial,Helvetica,sans-serif",
                 8F, FontStyle.Regular);
     chartArea.AxisY.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64);
     chartArea.AxisX.Interval = 1;
     chartArea.AxisY.Interval = 1;
     chartArea.AxisY.Title = "Position";
     return chartArea;
 }
        public override double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex)
        {
            if (totalPerPoint == null)
            {
                int num = 0;
                foreach (Series item in common.DataManager.Series)
                {
                    if (string.Compare(item.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) == 0 && item.ChartArea == area.Name && item.IsVisible())
                    {
                        num++;
                    }
                }
                Series[] array = new Series[num];
                int      num2  = 0;
                foreach (Series item2 in common.DataManager.Series)
                {
                    if (string.Compare(item2.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) == 0 && item2.ChartArea == area.Name && item2.IsVisible())
                    {
                        array[num2++] = item2;
                    }
                }
                common.DataManipulator.CheckXValuesAlignment(array);
                totalPerPoint = new double[series.Points.Count];
                for (int i = 0; i < series.Points.Count; i++)
                {
                    totalPerPoint[i] = 0.0;
                    Series[] array2 = array;
                    foreach (Series series4 in array2)
                    {
                        totalPerPoint[i] += Math.Abs(series4.Points[i].YValues[0]);
                    }
                }
            }
            if (!area.Area3DStyle.Enable3D)
            {
                if (totalPerPoint[pointIndex] == 0.0)
                {
                    int num3 = 0;
                    foreach (Series item3 in common.DataManager.Series)
                    {
                        if (string.Compare(item3.ChartTypeName, Name, ignoreCase: true, CultureInfo.CurrentCulture) == 0 && item3.ChartArea == area.Name && item3.IsVisible())
                        {
                            num3++;
                        }
                    }
                    return(100.0 / (double)num3);
                }
                return(point.YValues[0] / totalPerPoint[pointIndex] * 100.0);
            }
            double num4 = double.NaN;

            if (yValueIndex == -1)
            {
                double num5 = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName).Crossing;
                num4 = GetYValue(common, area, series, point, pointIndex, 0);
                if (area.Area3DStyle.Enable3D && num4 < 0.0)
                {
                    num4 = 0.0 - num4;
                }
                if (num4 >= 0.0)
                {
                    if (!double.IsNaN(prevPosY))
                    {
                        num5 = prevPosY;
                    }
                }
                else if (!double.IsNaN(prevNegY))
                {
                    num5 = prevNegY;
                }
                return(num4 - num5);
            }
            prevPosY      = double.NaN;
            prevNegY      = double.NaN;
            prevPositionX = double.NaN;
            foreach (Series item4 in common.DataManager.Series)
            {
                if (string.Compare(series.ChartArea, item4.ChartArea, ignoreCase: true, CultureInfo.CurrentCulture) == 0 && string.Compare(series.ChartTypeName, item4.ChartTypeName, ignoreCase: true, CultureInfo.CurrentCulture) == 0 && series.IsVisible())
                {
                    num4 = item4.Points[pointIndex].YValues[0] / totalPerPoint[pointIndex] * 100.0;
                    if (!double.IsNaN(num4) && area.Area3DStyle.Enable3D && num4 < 0.0)
                    {
                        num4 = 0.0 - num4;
                    }
                    if (num4 >= 0.0 && !double.IsNaN(prevPosY))
                    {
                        num4 += prevPosY;
                    }
                    if (num4 < 0.0 && !double.IsNaN(prevNegY))
                    {
                        num4 += prevNegY;
                    }
                    if (string.Compare(series.Name, item4.Name, StringComparison.Ordinal) == 0)
                    {
                        break;
                    }
                    if (num4 >= 0.0)
                    {
                        prevPosY = num4;
                    }
                    else
                    {
                        prevNegY = num4;
                    }
                    prevPositionX = item4.Points[pointIndex].XValue;
                    if (prevPositionX == 0.0 && ChartElement.IndexedSeries(series))
                    {
                        prevPositionX = pointIndex + 1;
                    }
                }
            }
            if (num4 > 100.0)
            {
                return(100.0);
            }
            return(num4);
        }
        public virtual double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex)
        {
            double num = double.NaN;

            if (area.Area3DStyle.Enable3D)
            {
                switch (yValueIndex)
                {
                case -2:
                    break;

                case -1:
                {
                    Axis   axis     = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
                    double crossing = axis.Crossing;
                    num = this.GetYValue(common, area, series, point, pointIndex, 0);
                    if (num >= 0.0)
                    {
                        if (!double.IsNaN(this.prevPosY))
                        {
                            crossing = this.prevPosY;
                        }
                    }
                    else if (!double.IsNaN(this.prevNegY))
                    {
                        crossing = this.prevNegY;
                    }
                    return(num - crossing);
                }

                default:
                    this.prevPosY = double.NaN;
                    this.prevNegY = double.NaN;
                    {
                        foreach (Series item in common.DataManager.Series)
                        {
                            if (string.Compare(series.ChartArea, item.ChartArea, StringComparison.Ordinal) == 0 && string.Compare(series.ChartTypeName, item.ChartTypeName, StringComparison.OrdinalIgnoreCase) == 0 && item.IsVisible())
                            {
                                string seriesStackGroupName = StackedColumnChart.GetSeriesStackGroupName(item);
                                if (this.stackGroupNameUsed && seriesStackGroupName != this.currentStackGroup)
                                {
                                    continue;
                                }
                                if (double.IsNaN(num))
                                {
                                    num = item.Points[pointIndex].YValues[0];
                                }
                                else
                                {
                                    num = item.Points[pointIndex].YValues[0];
                                    if (num >= 0.0 && !double.IsNaN(this.prevPosY))
                                    {
                                        num += this.prevPosY;
                                    }
                                    if (num < 0.0 && !double.IsNaN(this.prevNegY))
                                    {
                                        num += this.prevNegY;
                                    }
                                }
                                if (string.Compare(series.Name, item.Name, StringComparison.Ordinal) != 0)
                                {
                                    if (num >= 0.0)
                                    {
                                        this.prevPosY = num;
                                    }
                                    if (num < 0.0)
                                    {
                                        this.prevNegY = num;
                                    }
                                    continue;
                                }
                                return(num);
                            }
                        }
                        return(num);
                    }
                }
            }
            return(point.YValues[0]);
        }
        public void DrawLabels3D(CommonElements common, ChartGraphics graph, ChartArea area, DataPoint3D pointEx, int pointIndex, Series series, RectangleF rectangle)
        {
            DataPoint    dataPoint    = pointEx.dataPoint;
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            Region clip = graph.Clip;

            graph.Clip = new Region();
            if (dataPoint.ShowLabelAsValue || dataPoint.Label.Length > 0)
            {
                string text;
                if (dataPoint.Label.Length == 0)
                {
                    double value = this.GetYValue(common, area, series, dataPoint, pointIndex, -2);
                    if (this.hundredPercentStacked && dataPoint.LabelFormat.Length == 0)
                    {
                        value = Math.Round(value, 2);
                    }
                    text = ValueConverter.FormatValue(series.chart, dataPoint, value, dataPoint.LabelFormat, series.YValueType, ChartElementType.DataPoint);
                }
                else
                {
                    text = dataPoint.ReplaceKeywords(dataPoint.Label);
                    if (series.chart != null && series.chart.LocalizeTextHandler != null)
                    {
                        text = series.chart.LocalizeTextHandler(dataPoint, text, dataPoint.ElementId, ChartElementType.DataPoint);
                    }
                }
                PointF pointF = PointF.Empty;
                pointF.X = (float)(rectangle.X + rectangle.Width / 2.0);
                pointF.Y = (float)(rectangle.Y + rectangle.Height / 2.0);
                Point3D[] array = new Point3D[1]
                {
                    new Point3D(pointF.X, pointF.Y, pointEx.zPosition + pointEx.depth)
                };
                area.matrix3D.TransformPoints(array);
                pointF.X = array[0].X;
                pointF.Y = array[0].Y;
                int   angle     = dataPoint.FontAngle;
                SizeF labelSize = SizeF.Empty;
                if (series.SmartLabels.Enabled)
                {
                    labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                    bool markerOverlapping = series.SmartLabels.MarkerOverlapping;
                    LabelAlignmentTypes movingDirection = series.SmartLabels.MovingDirection;
                    series.SmartLabels.MarkerOverlapping = true;
                    if (series.SmartLabels.MovingDirection == (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom | LabelAlignmentTypes.Right | LabelAlignmentTypes.Left | LabelAlignmentTypes.TopLeft | LabelAlignmentTypes.TopRight | LabelAlignmentTypes.BottomLeft | LabelAlignmentTypes.BottomRight))
                    {
                        series.SmartLabels.MovingDirection = (LabelAlignmentTypes.Top | LabelAlignmentTypes.Bottom);
                    }
                    pointF = area.smartLabels.AdjustSmartLabelPosition(common, graph, area, series.SmartLabels, pointF, labelSize, ref stringFormat, pointF, new SizeF(0f, 0f), LabelAlignmentTypes.Center);
                    series.SmartLabels.MarkerOverlapping = markerOverlapping;
                    series.SmartLabels.MovingDirection   = movingDirection;
                    angle = 0;
                }
                if (!pointF.IsEmpty)
                {
                    if (labelSize.IsEmpty)
                    {
                        labelSize = graph.GetRelativeSize(graph.MeasureString(text, dataPoint.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                    }
                    RectangleF empty = RectangleF.Empty;
                    SizeF      sizeF = new SizeF(labelSize.Width, labelSize.Height);
                    sizeF.Height += (float)(labelSize.Height / 8.0);
                    sizeF.Width  += sizeF.Width / (float)text.Length;
                    empty         = new RectangleF((float)(pointF.X - sizeF.Width / 2.0), (float)(pointF.Y - sizeF.Height / 2.0 - labelSize.Height / 10.0), sizeF.Width, sizeF.Height);
                    graph.DrawPointLabelStringRel(common, text, dataPoint.Font, new SolidBrush(dataPoint.FontColor), pointF, stringFormat, angle, empty, dataPoint.LabelBackColor, dataPoint.LabelBorderColor, dataPoint.LabelBorderWidth, dataPoint.LabelBorderStyle, series, dataPoint, pointIndex);
                }
            }
            graph.Clip = clip;
        }
        protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
        {
            GraphicsPath graphicsPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath) ? new GraphicsPath() : null;

            if (centerPointIndex == int.MaxValue)
            {
                centerPointIndex = GetCenterPointIndex(points);
            }
            DataPoint3D dataPoint3D        = (DataPoint3D)points[pointIndex];
            int         neighborPointIndex = pointIndex;
            DataPoint3D dataPoint3D2       = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, multiSeries ? dataPoint3D : null, ref neighborPointIndex);
            DataPoint3D dataPoint3D3       = dataPoint3D;

            if (prevDataPointEx.dataPoint.Empty)
            {
                dataPoint3D3 = prevDataPointEx;
            }
            else if (dataPoint3D2.index > dataPoint3D.index)
            {
                dataPoint3D3 = dataPoint3D2;
            }
            Color          backColor   = useBorderColor ? dataPoint3D3.dataPoint.BorderColor : dataPoint3D3.dataPoint.Color;
            ChartDashStyle borderStyle = dataPoint3D3.dataPoint.BorderStyle;

            if (dataPoint3D3.dataPoint.Empty && dataPoint3D3.dataPoint.Color == Color.Empty)
            {
                backColor = Color.Gray;
            }
            if (dataPoint3D3.dataPoint.Empty && dataPoint3D3.dataPoint.BorderStyle == ChartDashStyle.NotSet)
            {
                borderStyle = ChartDashStyle.Solid;
            }
            DataPoint3D dataPoint3D4 = new DataPoint3D();

            dataPoint3D4.xPosition = dataPoint3D.xPosition;
            dataPoint3D4.yPosition = dataPoint3D2.yPosition;
            bool flag = true;

            if (pointIndex + 1 < points.Count && ((DataPoint3D)points[pointIndex + 1]).index == dataPoint3D2.index)
            {
                flag = false;
            }
            if (centerPointIndex != int.MaxValue && pointIndex >= centerPointIndex)
            {
                flag = false;
            }
            GraphicsPath graphicsPath2;
            GraphicsPath graphicsPath3;

            if (flag)
            {
                dataPoint3D4.dataPoint = dataPoint3D.dataPoint;
                graphicsPath2          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D2, dataPoint3D4, points, pointIndex, 0f, operationType, LineSegmentType.First, showPointLines ? true : false, forceThickBorder: false, area.reverseSeriesOrder, multiSeries, 0, clipInsideArea: true);
                graph.frontLinePen     = null;
                dataPoint3D4.dataPoint = dataPoint3D2.dataPoint;
                graphicsPath3          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D4, dataPoint3D, points, pointIndex, 0f, operationType, LineSegmentType.Last, showPointLines ? true : false, forceThickBorder: false, area.reverseSeriesOrder, multiSeries, 0, clipInsideArea: true);
                graph.frontLinePen     = null;
            }
            else
            {
                dataPoint3D4.dataPoint = dataPoint3D2.dataPoint;
                graphicsPath3          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D4, dataPoint3D, points, pointIndex, 0f, operationType, LineSegmentType.Last, showPointLines ? true : false, forceThickBorder: false, area.reverseSeriesOrder, multiSeries, 0, clipInsideArea: true);
                graph.frontLinePen     = null;
                dataPoint3D4.dataPoint = dataPoint3D.dataPoint;
                graphicsPath2          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D2, dataPoint3D4, points, pointIndex, 0f, operationType, LineSegmentType.First, showPointLines ? true : false, forceThickBorder: false, area.reverseSeriesOrder, multiSeries, 0, clipInsideArea: true);
                graph.frontLinePen     = null;
            }
            if (graphicsPath != null)
            {
                if (area.Common.ProcessModeRegions && graphicsPath2 != null && graphicsPath2.PointCount > 0)
                {
                    area.Common.HotRegionsList.AddHotRegion(graphicsPath2, relativePath: false, graph, prevDataPointEx.dataPoint, prevDataPointEx.dataPoint.series.Name, prevDataPointEx.index - 1);
                }
                if (graphicsPath3 != null && graphicsPath3.PointCount > 0)
                {
                    graphicsPath.AddPath(graphicsPath3, connect: true);
                }
            }
            return(graphicsPath);
        }
Beispiel #35
0
        async Task AddDataPointsAsync(MeasurementHolder measurementHolder)
        {
            var dictPerfCtrCurrentMeasurements = measurementHolder.GetLastMeasurements();

            if (_dataPoints.Count == 0) // nothing yet
            {
                for (int i = 0; i < NumDataPoints; i++)
                {
                    _dataPoints[i] = new List <uint>(dictPerfCtrCurrentMeasurements.Values); // let all init points be equal, so y axis scales IsStartedFromZero
                }
            }
            else
            {
                _dataPoints[_bufferIndex++] = new List <uint>(dictPerfCtrCurrentMeasurements.Values);
                if (_bufferIndex == _dataPoints.Count) // wraparound?
                {
                    _bufferIndex = 0;
                }
            }
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (DoFullGCPerSample)
            {
                DoGC();// do a GC.Collect on main thread for every sample (the graphing uses memory)
            }
            // this needs to be done on UI thread
            _chart.Series.Clear();
            _chart.ChartAreas.Clear();
            ChartArea chartArea = new ChartArea("ChartArea");

            chartArea.AxisY.LabelStyle.Format = "{0:n0}";
            chartArea.AxisY.LabelStyle.Font   = new System.Drawing.Font("Consolas", 12);
            _chart.ChartAreas.Add(chartArea);
            int ndxSeries = 0;

            chartArea.AxisY.IsStartedFromZero = false;
            if (SetMaxGraphTo100)
            {
                _chart.ChartAreas[0].AxisY.Maximum = 100;
            }
            foreach (var entry in dictPerfCtrCurrentMeasurements)
            {
                var series = new Series
                {
                    ChartType = SeriesChartType.Line,
                    Name      = entry.Key.ToString()
                };
                _chart.Series.Add(series);
                if (UpdateInterval == 0) // if we're not doing auto update on timer, we're iterating or doing manual measurement
                {
                    series.MarkerSize  = 10;
                    series.MarkerStyle = MarkerStyle.Circle;
                }
                for (int i = 0; i < _dataPoints.Count; i++)
                {
                    var ndx = _bufferIndex + i;
                    if (ndx >= _dataPoints.Count)
                    {
                        ndx -= _dataPoints.Count;
                    }
                    var dp = new DataPoint(i + 1, _dataPoints[ndx][ndxSeries]);
                    series.Points.Add(dp);
                }
                ndxSeries++;
            }
            _chart.Legends.Clear();
            _chart.Legends.Add(new Legend());
            _chart.DataBind();

            if (_editorTracker != null)
            {
                var(openedViews, lstLeakedViews) = _editorTracker.GetCounts();
                OpenedViews.Clear();
                LeakedViews.Clear();
                foreach (var dictEntry in openedViews)
                {
                    var sp = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    sp.Children.Add(new TextBlock()
                    {
                        Text = $"{ dictEntry.Key,-15} {dictEntry.Value,3}", FontFamily = FontFamilyMono
                    });
                    OpenedViews.Add(sp);
                }

                foreach (var entry in lstLeakedViews)
                {
                    var sp = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    sp.Children.Add(new TextBlock()
                    {
                        Text = $"{ entry._contentType,-15} Ser#={entry._serialNo,3} {entry._dtCreated:hh:mm:ss} {entry._filename}", FontFamily = FontFamilyMono
                    });
Beispiel #36
0
        private static void CreateChartPrimaryAxis(ChartArea chartArea, IChart iChart)
        {
            if (chartArea.Series[0].Type != ChartTypes.Bar && chartArea.Series[0].Type != ChartTypes.StackingBar && chartArea.Series[0].Type != ChartTypes.StackingBar100)
            {
                #region Primary Horizontal Axis Implementation.
                if (iChart.PrimaryCategoryAxis.Visible)
                {
                    chartArea.PrimaryAxis.Header           = iChart.PrimaryCategoryAxis.Title;
                    chartArea.PrimaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryCategoryAxis.Font.FontName);
                    chartArea.PrimaryAxis.LabelFontSize    = iChart.PrimaryCategoryAxis.Font.Size;
                    chartArea.PrimaryAxis.LabelRotateAngle = iChart.PrimaryCategoryAxis.TextRotationAngle;

                    if (!iChart.PrimaryCategoryAxis.HasMajorGridLines && !iChart.PrimaryCategoryAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.PrimaryAxis, false);
                    }

                    ///In excel Primary X and Primary Y axis will be Value axis for Scatter Charts.
                    ///For others Primary and secondary X axis is category axis
                    /// and Primary and secondary Y axis is value axis. It will work vice versily for Bar chart
                    if (chartArea.Series[0].Type == ChartTypes.Scatter || chartArea.Series[0].Type == ChartTypes.FastScatter)
                    {
                        chartArea.PrimaryAxis.IsAutoSetRange = false;
                        chartArea.PrimaryAxis.ValueType      = ChartValueType.Double;
                        if (iChart.PrimaryCategoryAxis.MinimumValue == 0 && iChart.PrimaryCategoryAxis.MaximumValue == 0)
                        {
                            ComputeRange(chartArea, iChart, "CategoryAxis");
                        }
                        else
                        {
                            DoubleRange doubleRange = new DoubleRange(iChart.PrimaryCategoryAxis.MinimumValue, iChart.PrimaryCategoryAxis.MaximumValue);
                            chartArea.PrimaryAxis.Range    = doubleRange;
                            chartArea.PrimaryAxis.Interval = iChart.PrimaryCategoryAxis.MajorUnit;
                        }
                    }

                    else if (!iChart.PrimaryCategoryAxis.AutoTickLabelSpacing)
                    {
                        if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasDateTime)
                        {
                            chartArea.PrimaryAxis.ValueType        = ChartValueType.DateTime;
                            chartArea.PrimaryAxis.DateTimeInterval = TimeSpan.FromDays(iChart.PrimaryCategoryAxis.TickLabelSpacing);
                            string format = iChart.PrimaryCategoryAxis.NumberFormat;
                            format = format.Replace("m", "M");
                            chartArea.PrimaryAxis.LabelDateTimeFormat = format;
                            chartArea.PrimaryAxis.IsAutoSetRange      = true;
                        }
                        else if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasNumber)
                        {
                            chartArea.PrimaryAxis.ValueType = ChartValueType.Double;
                            chartArea.PrimaryAxis.Interval  = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                        else
                        {
                            chartArea.PrimaryAxis.Interval = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                    }
                }
                else
                {
                    chartArea.PrimaryAxis.AxisVisibility = Visibility.Hidden;
                }
                #endregion

                #region Primary Vertical Axis Implementation
                if (iChart.PrimaryValueAxis.Visible)
                {
                    chartArea.SecondaryAxis.IsAutoSetRange   = false;
                    chartArea.SecondaryAxis.Header           = iChart.PrimaryValueAxis.Title;
                    chartArea.SecondaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryValueAxis.Font.FontName);
                    chartArea.SecondaryAxis.LabelFontSize    = iChart.PrimaryValueAxis.Font.Size;
                    chartArea.SecondaryAxis.LabelRotateAngle = iChart.PrimaryValueAxis.TextRotationAngle;

                    if (!iChart.PrimaryValueAxis.HasMajorGridLines && !iChart.PrimaryValueAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.PrimaryAxis, false);
                    }

                    if (iChart.PrimaryValueAxis.MinimumValue == 0 && iChart.PrimaryValueAxis.MaximumValue == 0)
                    {
                        ComputeRange(chartArea, iChart, "ValueAxis");
                    }
                    else
                    {
                        DoubleRange doubleRange = new DoubleRange(iChart.PrimaryValueAxis.MinimumValue, iChart.PrimaryValueAxis.MaximumValue);
                        chartArea.SecondaryAxis.Range    = doubleRange;
                        chartArea.SecondaryAxis.Interval = iChart.PrimaryValueAxis.MajorUnit;
                    }
                }
                else
                {
                    chartArea.SecondaryAxis.AxisVisibility = Visibility.Hidden;
                }
                #endregion
            }
            #region Axis Implementation for Bar Chart
            else
            {
                //Axis Implementation for Bar Type Chart, because it differs from all Chart.
                //PrimaryAxis Code for BarChart.
                if (iChart.PrimaryValueAxis.Visible)
                {
                    chartArea.PrimaryAxis.Header           = iChart.PrimaryValueAxis.Title;
                    chartArea.PrimaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryValueAxis.Font.FontName);
                    chartArea.PrimaryAxis.LabelFontSize    = iChart.PrimaryValueAxis.Font.Size;
                    chartArea.PrimaryAxis.LabelRotateAngle = iChart.PrimaryValueAxis.TextRotationAngle;
                    chartArea.PrimaryAxis.IsAutoSetRange   = false;

                    if (!iChart.PrimaryValueAxis.HasMajorGridLines && !iChart.PrimaryValueAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.PrimaryAxis, false);
                    }

                    if (iChart.PrimaryValueAxis.MinimumValue == 0 && iChart.PrimaryValueAxis.MaximumValue == 0)
                    {
                        chartArea.PrimaryAxis.IsAutoSetRange = false;
                    }
                    else
                    {
                        DoubleRange doubleRange = new DoubleRange(iChart.PrimaryValueAxis.MinimumValue, iChart.PrimaryValueAxis.MaximumValue);
                        chartArea.PrimaryAxis.Range    = doubleRange;
                        chartArea.PrimaryAxis.Interval = iChart.PrimaryValueAxis.MajorUnit;
                    }
                }
                else
                {
                    chartArea.PrimaryAxis.AxisVisibility = Visibility.Hidden;
                }

                //Secondary Axis code for BarChart.
                if (iChart.PrimaryCategoryAxis.Visible)
                {
                    if (!iChart.PrimaryCategoryAxis.HasMajorGridLines && !iChart.PrimaryCategoryAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(chartArea.SecondaryAxis, false);
                    }

                    if (!iChart.PrimaryCategoryAxis.AutoTickLabelSpacing)
                    {
                        chartArea.SecondaryAxis.Header           = iChart.PrimaryCategoryAxis.Title;
                        chartArea.SecondaryAxis.LabelFontFamily  = new FontFamily(iChart.PrimaryCategoryAxis.Font.FontName);
                        chartArea.SecondaryAxis.LabelFontSize    = iChart.PrimaryCategoryAxis.Font.Size;
                        chartArea.SecondaryAxis.LabelRotateAngle = iChart.PrimaryCategoryAxis.TextRotationAngle;

                        if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasDateTime)
                        {
                            chartArea.SecondaryAxis.ValueType        = ChartValueType.DateTime;
                            chartArea.SecondaryAxis.DateTimeInterval = TimeSpan.FromDays(iChart.PrimaryCategoryAxis.TickLabelSpacing);
                            chartArea.SecondaryAxis.LabelFormat      = iChart.PrimaryCategoryAxis.CategoryLabels.NumberFormat;
                        }
                        else if (iChart.PrimaryCategoryAxis.CategoryLabels != null && iChart.PrimaryCategoryAxis.CategoryLabels.HasNumber)
                        {
                            chartArea.SecondaryAxis.ValueType = ChartValueType.Double;
                            chartArea.SecondaryAxis.Interval  = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                        else
                        {
                            chartArea.SecondaryAxis.Interval = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                        }
                    }
                }
                else
                {
                    chartArea.SecondaryAxis.AxisVisibility = Visibility.Hidden;
                }
            }


            #endregion
        }
Beispiel #37
0
        private static void ComputeRange(ChartArea chartArea, IChart iChart, string Axis)
        {
            var    values = from s in chartArea.Series select s.Data;
            double min    = double.MaxValue;
            double max    = double.MinValue;

            foreach (var v in values)
            {
                for (int i = 0; i < v.Count; i++)
                {
                    if (v[i].Y < min)
                    {
                        min = v[i].Y;
                    }

                    if (v[i].Y > max)
                    {
                        max = v[i].Y;
                    }
                }
            }
            #region Range calculation for secondary Axis

            if (Axis == "SecondaryValueAxis")
            {
                if (!iChart.SecondaryValueAxis.IsAutoMajor)
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max + iChart.SecondaryValueAxis.MajorUnit);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min - iChart.SecondaryValueAxis.MajorUnit, max + iChart.SecondaryValueAxis.MajorUnit);
                    }
                }
                else
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min, max);
                    }
                }
            }
            #endregion

            #region Range Calculation for Primary Horizontal Axis
            else if (Axis == "CategoryAxis")
            {
                foreach (var v in values)
                {
                    for (int i = 0; i < v.Count; i++)
                    {
                        if (v[i].X < min)
                        {
                            min = v[i].X;
                        }

                        if (v[i].X > max)
                        {
                            max = v[i].X;
                        }
                    }
                }
                if (!iChart.PrimaryCategoryAxis.IsAutoMajor)
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(0, max + iChart.PrimaryCategoryAxis.MajorUnit);
                    }
                    else
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(min - iChart.PrimaryCategoryAxis.MajorUnit, max + iChart.PrimaryCategoryAxis.MajorUnit);
                    }
                }
                else
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(0, max);
                    }
                    else
                    {
                        chartArea.PrimaryAxis.Range = new DoubleRange(min, max);
                    }
                }
            }
            #endregion

            #region Range Calculation for Primary Vertical Axis
            else
            {
                if (!iChart.PrimaryValueAxis.IsAutoMajor)
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max + iChart.PrimaryValueAxis.MajorUnit);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min - iChart.PrimaryValueAxis.MajorUnit, max + iChart.PrimaryValueAxis.MajorUnit);
                    }
                }
                else
                {
                    if (min < (max * 5 / 6))
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(0, max);
                    }
                    else
                    {
                        chartArea.SecondaryAxis.Range = new DoubleRange(min, max);
                    }
                }
            }

            #endregion
        }
        // создание удаление областей и серий

        /// <summary>
        /// создать чарт. Создаёт первоначальную область и серию для прорисовки свечек
        /// </summary>
        private void CreateChart()
        {
            try
            {
                if (_chart != null && _chart.InvokeRequired)
                {
                    _chart.Invoke(new Action(CreateChart));
                    return;
                }

                _chart = new Chart();

                _chart.Series.Clear();
                _chart.ChartAreas.Clear();
                _chart.BackColor          = _colorKeeper.ColorBackChart;
                _chart.SuppressExceptions = true;

                if (_rectangle != null)
                {
                    _rectangle.Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(_colorKeeper.ColorBackSecond.A,
                                                                                              _colorKeeper.ColorBackSecond.R, _colorKeeper.ColorBackSecond.G, _colorKeeper.ColorBackSecond.B));
                }

                ChartArea prime = new ChartArea("Prime")
                {
                    CursorX = { AxisType = AxisType.Secondary, IsUserSelectionEnabled = false, IsUserEnabled = true, IntervalType = DateTimeIntervalType.Auto, Interval = 0.00001 },
                    CursorY = { AxisType = AxisType.Primary, IsUserEnabled = true, IntervalType = DateTimeIntervalType.Auto, Interval = 0.00001 },
                    //AxisX2 = { IsMarginVisible = false, Enabled = AxisEnabled.False },
                    BorderDashStyle = ChartDashStyle.Solid,
                    BorderWidth     = 2,
                    BackColor       = _colorKeeper.ColorBackChart,
                    BorderColor     = _colorKeeper.ColorBackSecond,
                };

                prime.AxisY.TitleAlignment        = StringAlignment.Near;
                prime.AxisY.TitleForeColor        = _colorKeeper.ColorBackCursor;
                prime.AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;

                prime.AxisY.LabelAutoFitMinFontSize = 12;
                prime.AxisY.LabelAutoFitStyle       = LabelAutoFitStyles.IncreaseFont;
                foreach (var axe in prime.Axes)
                {
                    axe.LabelStyle.ForeColor = _colorKeeper.ColorText;
                }
                prime.CursorY.LineColor = _colorKeeper.ColorBackCursor;
                prime.CursorX.LineColor = _colorKeeper.ColorBackCursor;

                _chart.ChartAreas.Add(prime);

                Series clusterSeries = new Series("SeriesCluster");
                clusterSeries.ChartType       = SeriesChartType.RangeBar;
                clusterSeries.YAxisType       = AxisType.Primary;
                clusterSeries.XAxisType       = AxisType.Secondary;
                clusterSeries.ChartArea       = "Prime";
                clusterSeries.ShadowOffset    = 2;
                clusterSeries.YValuesPerPoint = 2;

                _chart.Series.Add(clusterSeries);
                _chart.MouseMove         += _chart_MouseMove2;
                _chart.ClientSizeChanged += _chart_ClientSizeChanged;
            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }
        }
        /// <summary>
        /// прорисовать все свечки
        /// </summary>
        /// <param name="history">свечи</param>
        private void PaintAllClusters(List <HorizontalVolumeLine> history, decimal maxVolume)
        {
            if (history == null ||
                history.Count == 0)
            {
                return;
            }

            Series candleSeries = new Series("SeriesCluster");

            candleSeries.ChartType       = SeriesChartType.RangeBar;
            candleSeries.YAxisType       = AxisType.Primary;
            candleSeries.XAxisType       = AxisType.Secondary;
            candleSeries.ChartArea       = "Prime";
            candleSeries.ShadowOffset    = 2;
            candleSeries.YValuesPerPoint = 2;

            for (int i = 0; i < history.Count; i++)
            {
                decimal clusterStartY = history[i].NumCluster; // Это точка начала кластера

                decimal linePriceX = history[i].Price;

                decimal lineVolume = history[i].GetVolume(_chartType);
                // 344360
                decimal move = lineVolume / maxVolume;
                if (_chartType == ClusterType.DeltaVolume)
                {
                    move = move * 0.7m;
                }

                candleSeries.Points.AddXY(linePriceX, clusterStartY, clusterStartY + move);

                if (_chartType == ClusterType.DeltaVolume)
                {
                    if (move > 0.35m)
                    {
                        candleSeries.Points[candleSeries.Points.Count - 1].Color              = _colorKeeper.ColorUpBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BorderColor        = _colorKeeper.ColorUpBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BackSecondaryColor =
                            _colorKeeper.ColorUpBodyCandle;
                    }
                    if (move < -0.35m)
                    {
                        candleSeries.Points[candleSeries.Points.Count - 1].Color              = _colorKeeper.ColorUpBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BorderColor        = _colorKeeper.ColorUpBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BackSecondaryColor =
                            _colorKeeper.ColorUpBodyCandle;
                    }
                    else
                    {
                        candleSeries.Points[candleSeries.Points.Count - 1].Color              = _colorKeeper.ColorDownBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BorderColor        = _colorKeeper.ColorDownBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BackSecondaryColor =
                            _colorKeeper.ColorDownBodyCandle;
                    }
                }
                else
                {
                    if (move > 0.5m)
                    {
                        candleSeries.Points[candleSeries.Points.Count - 1].Color       = _colorKeeper.ColorUpBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BorderColor =
                            _colorKeeper.ColorUpBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BackSecondaryColor =
                            _colorKeeper.ColorUpBodyCandle;
                    }
                    else
                    {
                        candleSeries.Points[candleSeries.Points.Count - 1].Color       = _colorKeeper.ColorDownBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BorderColor =
                            _colorKeeper.ColorDownBorderCandle;
                        candleSeries.Points[candleSeries.Points.Count - 1].BackSecondaryColor =
                            _colorKeeper.ColorDownBodyCandle;
                    }
                }

                candleSeries.Points[candleSeries.Points.Count - 1].ToolTip = history[i].ToolTip;
            }

            ChartArea candleArea = FindAreaByNameSafe("Prime");

            // if (candleArea != null && candleArea.AxisY.ScrollBar.IsVisible)
            //если уже выбран какой-то диапазон
            // {
            // сдвигаем представление вправо
            candleArea.AxisY.Maximum = _volume.VolumeClusters.Count + 2;
            candleArea.AxisY.Minimum = -1;
            //}

            if (FindSeriesByNameSafe("Cursor") != null)
            {
                ReMoveSeriesSafe(FindSeriesByNameSafe("Cursor"));
            }

            PaintSeriesSafe(candleSeries);

            //ReloadAreaSizes();
        }
Beispiel #40
0
        /// <summary>
        /// создать новый индикатор. Если уже есть с таким именем, возвращается имеющийся
        /// </summary>
        /// <param name="indicator">индикатор, который нужно интегрировать в чарт</param>
        /// <param name="nameArea">имя области, на которой следует прорисовать индикатор</param>
        /// <returns></returns>
        public IIndicatorCandle CreateIndicator(IIndicatorCandle indicator, string nameArea)
        {
            try
            {
                indicator.NameArea = nameArea;

                if (_indicatorsCandles != null)
                {
                    // проверяем, есть ли такой индикатор в коллекции
                    for (int i = 0; i < _indicatorsCandles.Count; i++)
                    {
                        if (_indicatorsCandles[i].Name == indicator.Name)
                        {
                            return(_indicatorsCandles[i]);
                        }
                    }
                }

                bool inNewArea = true;

                if (ChartCandle.GetChartArea(nameArea) != null)
                {
                    inNewArea = false;
                }

                List <List <decimal> > values = indicator.ValuesToChart;

                for (int i = 0; i < values.Count; i++)
                {
                    if (inNewArea == false)
                    {
                        indicator.NameSeries = ChartCandle.CreateSeries(ChartCandle.GetChartArea(nameArea),
                                                                        indicator.TypeIndicator, indicator.Name + i);
                    }
                    else
                    {
                        ChartArea area = ChartCandle.CreateArea(nameArea, 15);
                        indicator.NameSeries = ChartCandle.CreateSeries(area,
                                                                        indicator.TypeIndicator, indicator.Name + i);
                    }
                }

                if (_indicatorsCandles == null)
                {
                    _indicatorsCandles = new List <IIndicatorCandle>();
                    _indicatorsCandles.Add(indicator);
                }
                else
                {
                    _indicatorsCandles.Add(indicator);
                }

                Save();
                ReloadContext();
                indicator.NeadToReloadEvent += indicator_NeadToReloadEvent;
                indicator_NeadToReloadEvent(indicator);
                return(indicator);
            }
            catch (Exception error)
            {
                SendErrorMessage(error);
                return(null);
            }
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            ResourceManager manager = new ResourceManager(typeof(rptDoanhThu));
            ChartArea       area    = new ChartArea();
            Axis            axis    = new Axis();
            Axis            axis2   = new Axis();
            Axis            axis3   = new Axis();
            Axis            axis4   = new Axis();
            Axis            axis5   = new Axis();
            Legend          legend  = new Legend();
            Title           title   = new Title();
            Title           title2  = new Title();
            Series          series  = new Series();
            Title           title3  = new Title();
            Title           title4  = new Title();

            this.pageHeader    = new PageHeader();
            this.detail        = new Detail();
            this.pageFooter    = new PageFooter();
            this.chartControl1 = new ChartControl();
            this.chartControl1.BeginInit();
            this.BeginInit();
            this.pageHeader.Controls.AddRange(new ARControl[] { this.chartControl1 });
            this.pageHeader.Height                = 2.8125f;
            this.pageHeader.Name                  = "pageHeader";
            this.detail.ColumnSpacing             = 0f;
            this.detail.Height                    = 0.0625f;
            this.detail.Name                      = "detail";
            this.pageFooter.Height                = 0f;
            this.pageFooter.Name                  = "pageFooter";
            this.chartControl1.AutoRefresh        = true;
            this.chartControl1.Backdrop           = new BackdropItem(GradientType.Vertical, Color.White, Color.SteelBlue);
            this.chartControl1.Border.BottomColor = Color.Black;
            this.chartControl1.Border.BottomStyle = BorderLineStyle.None;
            this.chartControl1.Border.LeftColor   = Color.Black;
            this.chartControl1.Border.LeftStyle   = BorderLineStyle.None;
            this.chartControl1.Border.RightColor  = Color.Black;
            this.chartControl1.Border.RightStyle  = BorderLineStyle.None;
            this.chartControl1.Border.TopColor    = Color.Black;
            this.chartControl1.Border.TopStyle    = BorderLineStyle.None;
            area.AntiAliasMode                    = AntiAliasMode.Graphics;
            axis.AxisType       = AxisType.Categorical;
            axis.LabelFont      = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis.MajorTick      = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 1.0, 0f, false);
            axis.MinorTick      = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis.Title          = "Axis X";
            axis.TitleFont      = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis2.LabelFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis2.LabelsGap     = 0;
            axis2.LabelsVisible = false;
            axis2.Line          = new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None);
            axis2.MajorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis2.MinorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis2.Position      = 0.0;
            axis2.TickOffset    = 0.0;
            axis2.TitleFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis2.Visible       = false;
            axis3.LabelFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis3.LabelsVisible = false;
            axis3.MajorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis3.MinorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis3.Position      = 0.0;
            axis3.Title         = "Axis Y";
            axis3.TitleFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f), -90f);
            axis4.LabelFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis4.LabelsVisible = false;
            axis4.Line          = new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None);
            axis4.MajorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis4.MinorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis4.TitleFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis4.Visible       = false;
            axis5.LabelFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis5.LabelsGap     = 0;
            axis5.LabelsVisible = false;
            axis5.Line          = new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None);
            axis5.MajorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis5.MinorTick     = new Tick(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0.0, 0f, false);
            axis5.Position      = 0.0;
            axis5.TickOffset    = 0.0;
            axis5.TitleFont     = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            axis5.Visible       = false;
            area.Axes.AddRange(new AxisBase[] { axis, axis2, axis3, axis4, axis5 });
            area.Backdrop   = new BackdropItem(BackdropStyle.Transparent, Color.White, Color.White, GradientType.Vertical, HatchStyle.DottedGrid, null, PicturePutStyle.Stretched);
            area.Border     = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0, Color.Black);
            area.Light      = new Light(new Point3d(10f, 40f, 20f), LightType.InfiniteDirectional, 0.3f);
            area.Name       = "defaultArea";
            area.Projection = new Projection(ProjectionType.Orthogonal, 0.1f, 0.1f, 0f, 37f);
            this.chartControl1.ChartAreas.AddRange(new ChartArea[] { area });
            this.chartControl1.ChartBorder = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0, Color.Black);
            this.chartControl1.Height      = 2.8125f;
            this.chartControl1.Left        = 0f;
            legend.Alignment  = Alignment.Bottom;
            legend.Backdrop   = new BackdropItem(Color.White, 0x80);
            legend.Border     = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(), 0, Color.Black);
            legend.DockArea   = area;
            title.Backdrop    = new Backdrop(BackdropStyle.Transparent, Color.White, Color.White, GradientType.Vertical, HatchStyle.DottedGrid, null, PicturePutStyle.Stretched);
            title.Border      = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0, Color.Black);
            title.DockArea    = null;
            title.Font        = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            title.Name        = "";
            title.Text        = "";
            title.Visible     = false;
            legend.Footer     = title;
            legend.GridLayout = new GridLayout(2, 4);
            title2.Border     = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.White, 2), 0, Color.Black);
            title2.DockArea   = null;
            title2.Font       = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            title2.Name       = "";
            title2.Text       = "Legend";
            title2.Visible    = false;
            legend.Header     = title2;
            legend.LabelsFont = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            legend.Name       = "defaultLegend";
            this.chartControl1.Legends.AddRange(new Legend[] { legend });
            this.chartControl1.Name = "chartControl1";
            series.AxisX            = axis;
            series.AxisY            = axis3;
            series.ChartArea        = area;
            series.ColorPalette     = ColorPalette.Default;
            series.Legend           = legend;
            series.LegendText       = "";
            series.Name             = "Series1";
            series.Properties       = new CustomProperties(new KeyValuePair[] { new KeyValuePair("HoleSize", 0f), new KeyValuePair("Marker", new Marker(7, MarkerStyle.Triangle, new Backdrop(), new DataDynamics.ActiveReports.Chart.Graphics.Line(), new LabelInfo(new DataDynamics.ActiveReports.Chart.Graphics.Line(), new Backdrop(), new FontInfo(Color.Black, new Font("Arial", 8f)), "{Value}", Alignment.Bottom))), new KeyValuePair("BarType", BarType.Bar) });
            series.Type             = ChartType.Doughnut3D;
            this.chartControl1.Series.AddRange(new Series[] { series });
            title3.Alignment = Alignment.Center;
            title3.Border    = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0, Color.Black);
            title3.DockArea  = null;
            title3.Font      = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            title3.Name      = "header";
            title3.Text      = "Chart title";
            title3.Visible   = false;
            title4.Border    = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics.ActiveReports.Chart.Graphics.Line(Color.Transparent, 0, DataDynamics.ActiveReports.Chart.Graphics.LineStyle.None), 0, Color.Black);
            title4.DockArea  = null;
            title4.Docking   = DockType.Bottom;
            title4.Font      = new FontInfo(Color.Black, new Font("Microsoft Sans Serif", 8f));
            title4.Name      = "footer";
            title4.Text      = "Chart Footer";
            title4.Visible   = false;
            this.chartControl1.Titles.AddRange(new Title[] { title3, title4 });
            this.chartControl1.Top             = 0f;
            this.chartControl1.UIOptions       = UIOptions.ForceHitTesting;
            this.chartControl1.Width           = 3.4375f;
            base.MasterReport                  = false;
            base.PageSettings.DefaultPaperSize = false;
            base.PageSettings.Margins.Bottom   = 0f;
            base.PageSettings.Margins.Left     = 0f;
            base.PageSettings.Margins.Right    = 0f;
            base.PageSettings.Margins.Top      = 0f;
            base.PageSettings.PaperHeight      = 4f;
            base.PageSettings.PaperKind        = PaperKind.Custom;
            base.PageSettings.PaperName        = "Custom paper";
            base.PageSettings.PaperWidth       = 4f;
            base.PrintWidth = 3.4375f;
            base.Sections.Add(this.pageHeader);
            base.Sections.Add(this.detail);
            base.Sections.Add(this.pageFooter);
            base.StyleSheet.Add(new StyleSheetRule("font-family: Arial; font-style: normal; text-decoration: none; font-weight: normal; font-size: 10pt; color: Black; ", "Normal"));
            base.StyleSheet.Add(new StyleSheetRule("font-size: 16pt; font-weight: bold; ", "Heading1", "Normal"));
            base.StyleSheet.Add(new StyleSheetRule("font-family: Times New Roman; font-size: 14pt; font-weight: bold; font-style: italic; ", "Heading2", "Normal"));
            base.StyleSheet.Add(new StyleSheetRule("font-size: 13pt; font-weight: bold; ", "Heading3", "Normal"));
            this.chartControl1.EndInit();
            this.EndInit();
        }
Beispiel #42
0
    private void UpdatePlayerContent()
    {
        int golferID = int.Parse(DropDown_PlayerSelect.SelectedValue);

        if (golferID == 0)
        {
            return;
        }
        string golferName = DatabaseFunctions.GetGolferName(golferID);

        Scoring.LeagueStats LeagueStats = (Scoring.LeagueStats)Session["LeagueStats"];
        List <int>          CourseIDs   = DatabaseFunctions.GetCourseIDs(leagueID);

        //Build Course Statistics
        Table ScoreCardsTable = new Table();

        ScoreCardsTable.CellPadding = 40;
        foreach (int courseID in CourseIDs)
        {
            if (LeagueStats.NumRoundsByGolferAndCourse[courseID][golferID] == 0)
            {
                break;
            }
            CourseInfo courseInfo = DatabaseFunctions.GetCourseInfoFromCourseID(courseID);

            Table scoreCardTable = BuildEmptyScoreCardTable(courseInfo);

            //Title Row
            TableRow  titleRow = new TableRow();
            TableCell cell     = AddCell(titleRow, "Number of Rounds Played : " + LeagueStats.NumRoundsByGolferAndCourse[courseID][golferID]);//DatabaseFunctions.GetGolferName(golferID) +
            cell.ColumnSpan = 11;
            cell.Font.Size  = 18;
            cell.Font.Bold  = true;
            titleRow.Cells.Add(cell);
            scoreCardTable.Rows.AddAt(1, titleRow);

            scoreCardTable.BorderStyle = BorderStyle.Solid;
            scoreCardTable.BorderWidth = 5;

            AddScoreCardRow(scoreCardTable, "Best Score", LeagueStats.BestScoresByHole[courseID][golferID]);
            AddScoreCardRow(scoreCardTable, "Worst Score", LeagueStats.WorstScoresByHole[courseID][golferID]);
            AddScoreCardRow(scoreCardTable, "Average Score", roundDecimalList(LeagueStats.AverageScoresByHole[courseID][golferID]));
            AddScoreCardRow(scoreCardTable, "Skins Won", listOfIntToByte(LeagueStats.SkinsByCourseID[courseID][golferID]));

            TableRow  scoreCardHolderRow  = new TableRow();
            TableCell scoreCardHolderCell = new TableCell();
            scoreCardHolderCell.Controls.Add(scoreCardTable);
            scoreCardHolderRow.Cells.Add(scoreCardHolderCell);
            ScoreCardsTable.Rows.Add(scoreCardHolderRow);
        }
        CourseStats.Controls.Add(ScoreCardsTable);

        //Build Graph for scores and handicaps

        FontFamily fontFamily = new FontFamily("Arial");
        Font       titlefont  = new Font(fontFamily, 16, FontStyle.Bold, GraphicsUnit.Pixel);

        Chart chartScores = new Chart();

        chartScores.Width            = 800;
        chartScores.Height           = 500;
        chartScores.ImageStorageMode = ImageStorageMode.UseImageLocation;
        //chartScores.Legends.Add(new Legend("Default"));
        //chartScores.Legends["Default"].Docking = Docking.Bottom;
        //chartScores.Legends["Default"].Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        chartScores.BorderSkin           = new BorderSkin();
        chartScores.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
        chartScores.BorderSkin.PageColor = Color.Transparent;
        chartScores.Titles.Add(new Title("Scores for " + golferName, Docking.Top, titlefont, Color.Black));
        ChartArea chartArea = new ChartArea();

        chartArea.Name = "ChartArea1";
        chartArea.AxisX.ScaleBreakStyle.Enabled = true;
        chartArea.AxisY.IsStartedFromZero       = false;
        chartScores.ChartAreas.Add(chartArea);


        Chart chartHandicaps = new Chart();

        chartHandicaps.Width            = 800;
        chartHandicaps.Height           = 500;
        chartHandicaps.ImageStorageMode = ImageStorageMode.UseImageLocation;
        //chartHandicaps.Legends.Add(new Legend("Default"));
        //chartHandicaps.Legends["Default"].Docking = Docking.Bottom;
        //chartHandicaps.Legends["Default"].Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        chartHandicaps.BorderSkin           = new BorderSkin();
        chartHandicaps.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
        chartHandicaps.BorderSkin.PageColor = Color.Transparent;
        chartHandicaps.Titles.Add(new Title("Handicap for " + golferName, Docking.Top, titlefont, Color.Black));
        ChartArea chartArea2 = new ChartArea();

        chartArea2.Name = "ChartArea2";
        chartArea2.AxisX.ScaleBreakStyle.Enabled = true;
        chartArea2.AxisX.ScaleBreakStyle.CollapsibleSpaceThreshold = 10;
        chartHandicaps.ChartAreas.Add(chartArea2);

        Series series = new Series("Handicap");

        series.ChartType   = SeriesChartType.Point;
        series.XValueType  = ChartValueType.Date;
        series.MarkerSize  = 20;
        series.MarkerStyle = MarkerStyle.Diamond;
        chartHandicaps.Series.Add(series);

        series             = new Series("Scores");
        series.ChartType   = SeriesChartType.Point;
        series.XValueType  = ChartValueType.Date;
        series.MarkerSize  = 20;
        series.MarkerStyle = MarkerStyle.Star6;
        chartScores.Series.Add(series);

        //List<int> scores = new List<int>();
        //List<int> handicaps = new List<int>();
        //List<DateTime> dates = new List<DateTime>();

        List <IndividualScore>      scores     = new List <IndividualScore>();
        Dictionary <int, EventInfo> eventInfos = DatabaseFunctions.GetEventsWithScores(leagueID);

        foreach (int eventID in LeagueStats.ScoreByEvent[golferID].Keys)
        {
            IndividualScore score = new IndividualScore();
            //DateTime? eventDateTime = DatabaseFunctions.GetEventDate(eventID);
            DateTime  eventDateTime = DateTime.Parse(eventInfos[eventID].Date);
            DataPoint point         = new DataPoint();
            point.SetValueXY(eventDateTime, LeagueStats.ScoreByEvent[golferID][eventID]);
            chartScores.Series["Scores"].Points.Add(point);

            DataPoint point2 = new DataPoint();
            point2.SetValueXY(eventDateTime, LeagueStats.handicaps[golferID][eventID]);
            chartHandicaps.Series["Handicap"].Points.Add(point2);

            score.Handicap   = LeagueStats.handicaps[golferID][eventID];
            score.Score      = LeagueStats.ScoreByEvent[golferID][eventID];
            score.date       = eventDateTime;
            score.CourseName = eventInfos[eventID].CourseName;
            score.SeasonName = eventInfos[eventID].SeasonName;
            score.EventName  = eventInfos[eventID].EventName;

            scores.Add(score);
            //dates.Add((DateTime)eventDateTime);
            //scores.Add(LeagueStats.ScoreByEvent[golferID][eventID]);
            //handicaps.Add(LeagueStats.handicaps[golferID][eventID]);
        }

        Graph.Controls.Add(chartScores);
        Graph.Controls.Add(chartHandicaps);

        //BuildPlayerHandicapTable(scores, handicaps, dates);
        PopulateScoreGrid(scores.OrderBy(x => x.date).ToList());
        lbGridTitle.Text = "Scores for " + golferName;
    }
        private bool ChooseMonPaint(string Mon)
        {
            Dictionary <string, double> dicConsumeDay  = new Dictionary <string, double>();
            Dictionary <string, double> dicConsumeKind = new Dictionary <string, double>();
            DataTable aa = accountNoteData.Query("MainData");

            foreach (DataRow item in aa.Rows)
            {
                if (Mon.Split(new char[] { '月' })[0] == item[4].ToString().Split(new char[] { '月' })[0])
                {
                    if (dicConsumeDay.ContainsKey(item[4].ToString().Split(new char[] { '月' })[1].Split(new char[] { '日' })[0]))
                    {
                        dicConsumeDay[item[4].ToString().Split(new char[] { '月' })[1].Split(new char[] { '日' })[0]] = double.Parse(item[1].ToString()) + dicConsumeDay[item[4].ToString().Split(new char[] { '月' })[1].Split(new char[] { '日' })[0]];
                    }
                    else
                    {
                        dicConsumeDay.Add(item[4].ToString().Split(new char[] { '月' })[1].Split(new char[] { '日' })[0], double.Parse(item[1].ToString()));
                    }
                }
            }

            ChartArea chartArea1 = chart1.ChartAreas["ChartArea1"];

            chartArea1.AxisX.Title = "日期";
            chartArea1.AxisY.Title = "花费:(元)";
            foreach (KeyValuePair <string, double> kv in dicConsumeDay)
            {
                chart1.Series[0].Points.AddXY(Convert.ToDouble(kv.Key), Convert.ToDouble(kv.Value));
            }
            chart1.Series[0].ToolTip = "#VAL(元)";
            chart1.Series[0].Label   = "#VAL(元)";

            Series series2 = chart1.Series["Series2"];

            foreach (DataRow item in aa.Rows)
            {
                if (Mon.Split(new char[] { '月' })[0] == item[4].ToString().Split(new char[] { '月' })[0])
                {
                    if (dicConsumeKind.ContainsKey(item[2].ToString()))
                    {
                        dicConsumeKind[item[2].ToString()] = double.Parse(item[1].ToString()) + dicConsumeKind[item[2].ToString()];
                    }
                    else
                    {
                        dicConsumeKind.Add(item[2].ToString(), double.Parse(item[1].ToString()));
                    }
                }
            }
            chart1.Series[1]["PieLabelStyle"] = "Outside"; //将文字移到外侧
            chart1.Series[1]["PieLineColor"]  = "Black";   //绘制黑色的连线。

            foreach (KeyValuePair <string, double> kv in dicConsumeKind)
            {
                series2.Points.AddXY(kv.Key, kv.Value);
            }
            chart1.Series[1].ToolTip = "#VAL(元)";
            if (dicConsumeDay.Count == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        /// <summary>
        /// перерисовать линии на оси Икс
        /// </summary>
        private void ResizeXAxis()
        {
            if (_chart.InvokeRequired)
            {
                _chart.Invoke(new Action(ResizeXAxis));

                return;
            }
            if (_volume.VolumeClusters == null ||
                _volume.VolumeClusters.Count == 0)
            {
                return;
            }
            ChartArea area = _chart.ChartAreas[0];

            double values = 0;

            int firstPos = 0;

            if (double.IsNaN(_chart.ChartAreas[0].AxisY.ScaleView.Size))
            {
                values = _volume.VolumeClusterLines[_volume.VolumeClusterLines.Count - 1].NumCluster + 1;
            }
            else
            {
                values   = (int)_chart.ChartAreas[0].AxisY.ScaleView.Size;
                firstPos = (int)_chart.ChartAreas[0].AxisY.ScaleView.Position;
            }

            if (firstPos < 0 ||
                firstPos > _volume.VolumeClusters.Count)
            {
                return;
            }

            int labelCount = 4;


            if (_volume.VolumeClusters.Count <= 2)
            {
                labelCount = 2;
            }
            else if (_volume.VolumeClusters.Count == 3)
            {
                labelCount = 3;
            }

            area.AxisY.Interval = values / labelCount;

            while (area.AxisY.CustomLabels.Count < labelCount)
            {
                area.AxisY.CustomLabels.Add(new CustomLabel());
            }
            while (area.AxisY.CustomLabels.Count > labelCount)
            {
                area.AxisY.CustomLabels.RemoveAt(0);
            }

            double value = firstPos + area.AxisY.Interval;

            if (labelCount < 4)
            {
                value = 0;
            }


            for (int i = 0; i < labelCount; i++)
            {
                area.AxisY.CustomLabels[i].FromPosition = value - area.AxisY.Interval * 0.7;
                area.AxisY.CustomLabels[i].ToPosition   = value + area.AxisY.Interval * 0.7;
                int clusterIndex = (int)value;

                if (clusterIndex >= _volume.VolumeClusters.Count)
                {
                    clusterIndex = _volume.VolumeClusters.Count - 1;
                }

                area.AxisY.CustomLabels[i].Text = _volume.VolumeClusters[clusterIndex].Time.ToString();

                value += area.AxisY.Interval;

                if (value >= _myClusters.Count)
                {
                    value = _myClusters.Count - 1;
                }
            }
        }
Beispiel #45
0
        private static void CreateChartSeries(ChartArea chartArea, IChart iChart)
        {
            ChartAxis commonaxis = new ChartAxis()
            {
                Orientation = Orientation.Vertical, OpposedPosition = true
            };

            chartArea.Axes.Add(commonaxis);
            for (int count = 0; count < iChart.Series.Count; count++)
            {
                IChartSerie XlsIOChartSerie = iChart.Series[count];
                ChartSeries UIChartSeries   = new ChartSeries()
                {
                    ShowEmptyPoints = false
                };
                SetSerieType(UIChartSeries, XlsIOChartSerie);
                DataTable ct = new DataTable();
                DataTable vt = new DataTable();
                if (XlsIOChartSerie.CategoryLabels != null)
                {
                    ct = XlsIOChartSerie.CategoryLabels.Worksheet.ExportDataTable(XlsIOChartSerie.CategoryLabels, ExcelExportDataTableOptions.ComputedFormulaValues);
                    vt = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.Values, ExcelExportDataTableOptions.ComputedFormulaValues);
                }
                else if (XlsIOChartSerie.NameRange != null)
                {
                    ct = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.NameRange, ExcelExportDataTableOptions.ComputedFormulaValues);
                    vt = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.Values, ExcelExportDataTableOptions.ComputedFormulaValues);
                }
                else if (iChart.DataRange != null)
                {
                    ct = XlsIOChartSerie.Values.Worksheet.ExportDataTable(iChart.DataRange, ExcelExportDataTableOptions.ComputedFormulaValues);
                    vt = XlsIOChartSerie.Values.Worksheet.ExportDataTable(XlsIOChartSerie.Values, ExcelExportDataTableOptions.ComputedFormulaValues);
                }

                List <ChartDataPoint> data = ConvertDataTableToDataPoints(ct, vt, iChart.IsSeriesInRows);
                UIChartSeries.DataSource    = data;
                UIChartSeries.BindingPathX  = "X";
                UIChartSeries.BindingPathsY = new List <string> {
                    "Y"
                };
                UIChartSeries.Label           = XlsIOChartSerie.Name;
                UIChartSeries.Resolution      = 5;
                UIChartSeries.UseOptimization = true;
                UIChartSeries.ShowSmartLabels = false;

                #region Pie Chart
                if (UIChartSeries.Type == ChartTypes.Pie)
                {
                    System.Drawing.Color serieborder = new System.Drawing.Color();
                    System.Drawing.Color seriecolor  = new System.Drawing.Color();
                    UIChartSeries.ColorEach = true;
                    UIChartSeries.Palette   = ChartColorPalette.Custom;
                    Brush[] brushes = new Brush[iChart.Workbook.Palette.Length];
                    if (iChart.ChartType == ExcelChartType.Pie_3D)
                    {
                        int i = 0;
                        foreach (Syncfusion.XlsIO.IChartDataPoint dataPoint in XlsIOChartSerie.DataPoints)
                        {
                            if (dataPoint.DataFormat.HasInterior && !dataPoint.DataFormat.Interior.UseAutomaticFormat)
                            {
                                seriecolor = dataPoint.DataFormat.Interior.ForegroundColor;
                                brushes[i] = new SolidColorBrush(Color.FromRgb(seriecolor.R, seriecolor.G, seriecolor.B));
                                i++;
                                UIChartSeries.CustomPalette = brushes;
                            }
                        }
                    }
                    else
                    {
                        serieborder = XlsIOChartSerie.SerieFormat.LineProperties.LineColor;
                        if (XlsIOChartSerie.SerieFormat.AreaProperties.UseAutomaticFormat == false)
                        {
                            seriecolor = XlsIOChartSerie.SerieFormat.Fill.ForeColor;
                        }
                        UIChartSeries.Interior = new SolidColorBrush(Color.FromRgb(seriecolor.R, seriecolor.G, seriecolor.B));
                    }
                    if (XlsIOChartSerie.SerieFormat.HasLineProperties)
                    {
                        UIChartSeries.StrokeThickness = GetLineWidth(XlsIOChartSerie.SerieFormat.LineProperties.LineWeight);
                    }
                    else
                    {
                        UIChartSeries.StrokeThickness = 0;
                    }
                }
                #endregion

                #region Line and Scatter Chart
                else if (UIChartSeries.Type == ChartTypes.Line || UIChartSeries.Type == ChartTypes.Scatter || UIChartSeries.Type == ChartTypes.FastScatter)
                {
                    if (UIChartSeries.Type == ChartTypes.Scatter || UIChartSeries.Type == ChartTypes.FastScatter)
                    {
                        UIChartSeries.BindingPathX = "XDouble";
                    }

                    if (XlsIOChartSerie.SerieFormat.IsMarkerSupported)
                    {
                        if (!XlsIOChartSerie.SerieFormat.IsAutoMarker)
                        {
                            System.Drawing.Color markercolor = XlsIOChartSerie.SerieFormat.MarkerBackgroundColor;
                            UIChartSeries.Interior = new SolidColorBrush(Color.FromRgb(markercolor.R, markercolor.G, markercolor.B));
                            UIChartSeries.Stroke   = new SolidColorBrush(Color.FromRgb(markercolor.R, markercolor.G, markercolor.B));
                        }
                    }

                    if (!XlsIOChartSerie.SerieFormat.LineProperties.IsAutoLineColor)
                    {
                        System.Drawing.Color lineColor = XlsIOChartSerie.SerieFormat.LineProperties.LineColor;
                        UIChartSeries.Stroke = new SolidColorBrush(Color.FromRgb(lineColor.R, lineColor.G, lineColor.B));
                    }
                    UIChartSeries.ColorEach       = false;
                    UIChartSeries.LegendIcon      = ChartLegendIcon.HorizontalLine;
                    UIChartSeries.StrokeThickness = GetLineWidth(XlsIOChartSerie.SerieFormat.LineProperties.LineWeight) + 1;
                }
                #endregion

                #region Other Charts
                else
                {
                    UIChartSeries.ColorEach = false;
                    System.Drawing.Color fcolor;
                    if (XlsIOChartSerie.SerieFormat.AreaProperties != null)
                    {
                        if (XlsIOChartSerie.SerieFormat.AreaProperties.UseAutomaticFormat == false)
                        {
                            fcolor = XlsIOChartSerie.SerieFormat.Fill.ForeColor;
                            Color fclr = Color.FromRgb(fcolor.R, fcolor.G, fcolor.B);
                            UIChartSeries.Interior  = new SolidColorBrush(fclr);
                            UIChartSeries.ColorEach = false;
                        }
                    }
                }
                #endregion

                CreateDataLabels(UIChartSeries, XlsIOChartSerie);
                CreateChartSecondaryAxis(UIChartSeries, XlsIOChartSerie, chartArea, iChart);
                chartArea.Series.Add(UIChartSeries);
            }

            System.Drawing.Color areaColor = iChart.ChartArea.Fill.ForeColor;
            chartArea.Background = new SolidColorBrush(Color.FromRgb(areaColor.R, areaColor.G, areaColor.B));
            if (!iChart.PlotArea.Interior.UseAutomaticFormat)
            {
                System.Drawing.Color plotColor = iChart.PlotArea.Fill.ForeColor;
                chartArea.GridBackground = new SolidColorBrush(Color.FromRgb(plotColor.R, plotColor.G, plotColor.B));
            }
            CreateChartTitle(chartArea, iChart);
            CreateChartLegend(chartArea, iChart);
            CreateChartPrimaryAxis(chartArea, iChart);
        }
Beispiel #46
0
        private void Resize()
        {
            if (_chartReport.InvokeRequired)
            {
                _chartReport.Invoke(new Action(Resize));
                return;
            }

            Series profitSeries = _chartReport.Series.FindByName("SeriesProfit");

            ChartArea area = _chartReport.ChartAreas[0];

            if (profitSeries == null ||
                profitSeries.Points == null ||
                profitSeries.Points.Count < 1)
            {
                return;
            }

            int firstX = 0;                         // first candle displayed/первая отображаемая свеча
            int lastX  = profitSeries.Points.Count; // последняя отображаемая свеча

            if (_chartReport.ChartAreas[0].AxisX.ScrollBar.IsVisible)
            {// if you have already selected a range, assign the first and last based on this range/если уже выбран какой-то диапазон, назначаем первую и последнюю исходя из этого диапазона
                firstX = Convert.ToInt32(area.AxisX.ScaleView.Position);
                lastX  = Convert.ToInt32(area.AxisX.ScaleView.Position) +
                         Convert.ToInt32(area.AxisX.ScaleView.Size) + 1;
            }

            if (firstX < 0)
            {
                firstX = 0;
                lastX  = firstX +
                         Convert.ToInt32(area.AxisX.ScaleView.Size) + 1;
            }

            if (firstX == lastX ||
                firstX > lastX ||
                firstX < 0 ||
                lastX <= 0)
            {
                return;
            }

            double max = 0;
            double min = double.MaxValue;

            for (int i = firstX; profitSeries.Points != null && i < profitSeries.Points.Count && i < lastX; i++)
            {
                if (profitSeries.Points[i].YValues.Max() > max)
                {
                    max = profitSeries.Points[i].YValues.Max();
                }
                if (profitSeries.Points[i].YValues.Min() < min && profitSeries.Points[i].YValues.Min() != 0)
                {
                    min = profitSeries.Points[i].YValues.Min();
                }
            }


            if (min == double.MaxValue ||
                max == 0 ||
                max == min ||
                max < min)
            {
                return;
            }

            area.AxisY2.Maximum = max;
            area.AxisY2.Minimum = min;
        }
Beispiel #47
0
        private static void CreateChartSecondaryAxis(ChartSeries UIChartSeries, IChartSerie XlsIOChartSerie, ChartArea chartArea, IChart iChart)
        {
            ///Secondary Axis Implementation
            if (!XlsIOChartSerie.UsePrimaryAxis)
            {
                SecondaryAxisflag = true;
                ///Secondary Horizontal Axis Implementation
                #region  Secondary Horizontal Axis
                if (iChart.SecondaryCategoryAxis.Visible)
                {
                    UIChartSeries.XAxis                  = chartArea.Axes[2];
                    UIChartSeries.XAxis.Header           = iChart.SecondaryCategoryAxis.Title;
                    UIChartSeries.XAxis.LabelFontFamily  = new FontFamily(iChart.SecondaryCategoryAxis.Font.FontName);
                    UIChartSeries.XAxis.LabelFontSize    = iChart.SecondaryCategoryAxis.Font.Size;
                    UIChartSeries.XAxis.LabelRotateAngle = iChart.SecondaryCategoryAxis.TextRotationAngle;

                    if (!iChart.SecondaryCategoryAxis.HasMajorGridLines && !iChart.SecondaryCategoryAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(UIChartSeries.XAxis, false);
                    }

                    if (!iChart.SecondaryCategoryAxis.AutoTickLabelSpacing)
                    {
                        UIChartSeries.XAxis.IsAutoSetRange = false;
                        if (iChart.SecondaryCategoryAxis.CategoryLabels != null && iChart.SecondaryCategoryAxis.CategoryLabels.HasDateTime)
                        {
                            UIChartSeries.XAxis.ValueType        = ChartValueType.DateTime;
                            UIChartSeries.XAxis.DateTimeInterval = TimeSpan.FromDays(iChart.SecondaryCategoryAxis.TickLabelSpacing);
                            string format = iChart.SecondaryCategoryAxis.NumberFormat;
                            format = format.Replace("m", "M");
                            UIChartSeries.XAxis.LabelDateTimeFormat = format;
                            UIChartSeries.XAxis.IsAutoSetRange      = true;
                        }
                        else if (iChart.SecondaryCategoryAxis.CategoryLabels != null && iChart.SecondaryCategoryAxis.CategoryLabels.HasNumber)
                        {
                            UIChartSeries.XAxis.ValueType = ChartValueType.Double;
                            UIChartSeries.XAxis.Interval  = iChart.SecondaryCategoryAxis.TickLabelSpacing;
                            UIChartSeries.XAxis.Range     = new DoubleRange(iChart.SecondaryCategoryAxis.MinimumValue, iChart.SecondaryCategoryAxis.MaximumValue);
                        }
                        else
                        {
                            UIChartSeries.XAxis.Interval = iChart.SecondaryCategoryAxis.TickLabelSpacing;
                        }
                    }
                    else
                    {
                        try
                        {
                            if (iChart.SecondaryCategoryAxis.CategoryLabels != null && iChart.SecondaryCategoryAxis.CategoryLabels.HasNumber)
                            {
                                chartArea.PrimaryAxis.ValueType = ChartValueType.Double;
                                foreach (var ser in chartArea.Series)
                                {
                                    ser.Data.ChartXValueType = ChartValueType.Double;
                                }
                                UIChartSeries.XAxis.Interval = iChart.PrimaryCategoryAxis.TickLabelSpacing;
                            }
                        }
                        catch
                        {
                            UIChartSeries.XAxis.IsAutoSetRange = true;
                        }
                    }
                }
                #endregion

                ///Secondary Vertical axis Implementation
                #region Secondary Vertical axis

                if (iChart.SecondaryValueAxis.Visible)
                {
                    UIChartSeries.YAxis = chartArea.Axes[2];
                    if (!iChart.SecondaryValueAxis.HasMajorGridLines && !iChart.SecondaryValueAxis.HasMinorGridLines)
                    {
                        ChartArea.SetShowGridLines(UIChartSeries.YAxis, false);
                    }
                    try { UIChartSeries.YAxis.Header = iChart.SecondaryValueAxis.Title; }
                    catch { }
                    UIChartSeries.YAxis.LabelFontFamily  = new FontFamily(iChart.SecondaryValueAxis.Font.FontName);
                    UIChartSeries.YAxis.LabelFontSize    = iChart.SecondaryValueAxis.Font.Size;
                    UIChartSeries.YAxis.LabelFontWeight  = iChart.PrimaryValueAxis.Font.Bold ? FontWeights.Bold : FontWeights.Normal;
                    UIChartSeries.YAxis.LabelRotateAngle = iChart.SecondaryValueAxis.TextRotationAngle;


                    if (iChart.SecondaryValueAxis.MinimumValue == 0 && iChart.SecondaryValueAxis.MaximumValue == 0)
                    {
                        ComputeRange(chartArea, iChart, "SecondaryValueAxis");
                    }
                    else
                    {
                        UIChartSeries.YAxis.IsAutoSetRange = false;
                        DoubleRange doubleRange = new DoubleRange(iChart.SecondaryValueAxis.MinimumValue, iChart.SecondaryValueAxis.MaximumValue);
                        UIChartSeries.YAxis.Range    = doubleRange;
                        UIChartSeries.YAxis.Interval = iChart.SecondaryValueAxis.MajorUnit;
                    }
                }
                else
                {
                    UIChartSeries.YAxis.AxisVisibility = Visibility.Hidden;
                }
                #endregion
            }
            else if (chartArea.Axes.Count > 2 && !SecondaryAxisflag)
            {
                chartArea.Axes.RemoveAt(2);
            }
        }
Beispiel #48
0
        /// <summary>
        /// create chart
        /// создать чарт
        /// </summary>
        private void CreateChart()
        {
            if (!HostPortfolio.Dispatcher.CheckAccess())
            {
                HostPortfolio.Dispatcher.Invoke(CreateChart);
                return;
            }

            _chartReport        = new Chart();
            HostPortfolio.Child = _chartReport;
            HostPortfolio.Child.Show();

            _chartReport.Series.Clear();
            _chartReport.ChartAreas.Clear();

            ChartArea areaLineProfit = new ChartArea("ChartAreaProfit");

            areaLineProfit.Position.Height = 70;
            areaLineProfit.Position.Width  = 100;
            areaLineProfit.Position.Y      = 0;
            areaLineProfit.CursorX.IsUserSelectionEnabled = false;
            areaLineProfit.CursorX.IsUserEnabled          = false;
            areaLineProfit.AxisX.Enabled = AxisEnabled.False;

            _chartReport.ChartAreas.Add(areaLineProfit);

            Series profit = new Series("SeriesProfit");

            profit.ChartType    = SeriesChartType.Line;
            profit.Color        = Color.DeepSkyBlue;
            profit.YAxisType    = AxisType.Secondary;
            profit.ChartArea    = "ChartAreaProfit";
            profit.ShadowOffset = 2;
            _chartReport.Series.Add(profit);

            ChartArea areaLineProfitBar = new ChartArea("ChartAreaProfitBar");

            areaLineProfitBar.AlignWithChartArea = "ChartAreaProfit";
            areaLineProfitBar.Position.Height    = 30;
            areaLineProfitBar.Position.Width     = 100;
            areaLineProfitBar.Position.Y         = 70;
            areaLineProfitBar.AxisX.Enabled      = AxisEnabled.False;


            _chartReport.ChartAreas.Add(areaLineProfitBar);

            Series profitBar = new Series("SeriesProfitBar");

            profitBar.ChartType    = SeriesChartType.Column;
            profitBar.YAxisType    = AxisType.Secondary;
            profitBar.ChartArea    = "ChartAreaProfitBar";
            profitBar.ShadowOffset = 2;
            _chartReport.Series.Add(profitBar);

            _chartReport.BackColor = Color.FromArgb(-15395563);

            for (int i = 0; _chartReport.ChartAreas != null && i < _chartReport.ChartAreas.Count; i++)
            {
                _chartReport.ChartAreas[i].BackColor            = Color.FromArgb(-15395563);
                _chartReport.ChartAreas[i].BorderColor          = Color.FromArgb(-16701360);
                _chartReport.ChartAreas[i].CursorY.LineColor    = Color.DimGray;
                _chartReport.ChartAreas[i].CursorX.LineColor    = Color.DimGray;
                _chartReport.ChartAreas[i].AxisX.TitleForeColor = Color.DimGray;

                foreach (var axe in _chartReport.ChartAreas[i].Axes)
                {
                    axe.LabelStyle.ForeColor = Color.DimGray;
                }
            }
        }
Beispiel #49
0
        private static void CreateChartLegend(ChartArea chartArea, IChart iChart)
        {
            if (iChart.HasLegend)
            {
                ChartLegend cl = new ChartLegend();

                if (iChart.Series[0].SerieType == ExcelChartType.Pie || iChart.Series[0].SerieType == ExcelChartType.Pie_3D || iChart.Series[0].SerieType == ExcelChartType.Doughnut || iChart.Series[0].SerieType == ExcelChartType.Doughnut_Exploded)
                {
                    cl.ItemTemplate = pielegendtemplate;
                }

                if (iChart.Legend.TextArea != null)
                {
                    cl.FontFamily = new System.Windows.Media.FontFamily(iChart.Legend.TextArea.FontName);
                    cl.FontSize   = iChart.Legend.TextArea.Size;
                    cl.FontStyle  = iChart.Legend.TextArea.Italic ? FontStyles.Italic : FontStyles.Normal;
                    cl.FontWeight = iChart.Legend.TextArea.Bold ? FontWeights.Bold : FontWeights.Normal;

                    if (iChart.Legend.FrameFormat.HasLineProperties && !iChart.Legend.FrameFormat.Border.AutoFormat && iChart.Legend.FrameFormat.Border.LinePattern != ExcelChartLinePattern.None)
                    {
                        cl.BorderThickness = new Thickness(GetLineWidth(iChart.Legend.FrameFormat.LineProperties.LineWeight));
                    }
                    else
                    {
                        cl.BorderThickness = new Thickness(0);
                    }

                    System.Drawing.Color lineColor = iChart.Legend.FrameFormat.Border.LineColor;
                    Color borderColor = Color.FromRgb(lineColor.R, lineColor.G, lineColor.B);

                    if (iChart.Legend.FrameFormat.Border.Transparency != 1.0)
                    {
                        cl.BorderBrush = new SolidColorBrush(borderColor);
                    }
                    else
                    {
                        cl.BorderBrush = null;
                    }

                    if (iChart.Legend.TextArea.BackgroundMode != ExcelChartBackgroundMode.Transparent)
                    {
                        System.Drawing.Color xlBackColor = iChart.Legend.TextArea.FrameFormat.Fill.BackColor;
                        Color backColor = Color.FromArgb(xlBackColor.A, xlBackColor.R, xlBackColor.G, xlBackColor.B);
                        cl.Background = new SolidColorBrush(backColor);
                    }
                    else
                    {
                        cl.Background = Brushes.Transparent;
                    }

                    System.Drawing.Color xlForeColor = iChart.Legend.TextArea.RGBColor;
                    Color foreColor = Color.FromRgb(xlForeColor.R, xlForeColor.G, xlForeColor.B);
                    cl.Foreground = new SolidColorBrush(foreColor);
                }

                chartArea.Legend = cl;
                switch (iChart.Legend.Position)
                {
                case ExcelLegendPosition.Bottom:
                    Chart.SetDock(cl, ChartDock.Bottom);
                    break;

                case ExcelLegendPosition.Corner:
                    Chart.SetDock(cl, ChartDock.Floating);
                    break;

                case ExcelLegendPosition.Left:
                    Chart.SetDock(cl, ChartDock.Left);
                    break;

                case ExcelLegendPosition.NotDocked:
                    Chart.SetDock(cl, ChartDock.Floating);
                    break;

                case ExcelLegendPosition.Right:
                    Chart.SetDock(cl, ChartDock.Right);
                    break;

                case ExcelLegendPosition.Top:
                    Chart.SetDock(cl, ChartDock.Top);
                    break;

                default:
                    Chart.SetDock(cl, ChartDock.Right);
                    break;
                }
            }
        }
        private void Display()
        {
            timetimer.Stop();       // redisplay, stop the time timer and lose the timeie.
            timeie = null;

            pictureBox.ClearImageList();
            Controls.RemoveByKey("chart");

            if (curlist != null)
            {
                var found = ReadHistory(out int prospectorsused, out int collectorsused, out int asteroidscracked, out int prospected, out int[] content);

                Font    displayfont = discoveryform.theme.GetFont;
                Color   textcolour  = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color   backcolour  = IsTransparent ? Color.Transparent : this.BackColor;
                Color   GridC       = discoveryform.theme.GridBorderLines;
                Color   TextC       = discoveryform.theme.GridCellText;
                Color   BackC       = discoveryform.theme.GridCellBack;
                Color[] LineC       = new Color[] { discoveryform.theme.KnownSystemColor, discoveryform.theme.TextBlockHighlightColor,
                                                    Color.Blue, Color.Yellow, Color.Green, Color.Gray, Color.HotPink, Color.Teal };

                using (StringFormat frmt = new StringFormat())
                {
                    frmt.FormatFlags = StringFormatFlags.NoWrap;

                    int vpos         = 5;
                    int colwidth     = (int)BaseUtils.BitMapHelpers.MeasureStringInBitmap("0000", displayfont, frmt).Width;
                    int percentwidth = (int)BaseUtils.BitMapHelpers.MeasureStringInBitmap("00000.0", displayfont, frmt).Width;
                    int hmlwidth     = percentwidth * 2;

                    int[] colsw = new int[] { colwidth * 4, colwidth, colwidth, colwidth, percentwidth, percentwidth, percentwidth, percentwidth, percentwidth, percentwidth, hmlwidth, colwidth };
                    int[] hpos  = new int[colsw.Length];
                    hpos[0] = 4;
                    for (int i = 1; i < hpos.Length; i++)
                    {
                        hpos[i] = hpos[i - 1] + colsw[i - 1];
                    }

                    int limpetscolpos = 0;
                    if (curlist.Count() > 0)
                    {
                        lastrefined = found.Sum(x => x.amountrefined);      // for use by timer

                        string timetext = TimeText(true);
                        if (timetext.HasChars())
                        {
                            timeie        = pictureBox.AddTextAutoSize(new Point(hpos[0], vpos), new Size(colsw[0], this.Height), timetext, displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                            limpetscolpos = 1;
                        }
                    }
                    else
                    {
                        lastrefined = 0;
                    }

                    {
                        string text = string.Format("Limpets left {0}, Cargo left {1}".T(EDTx.UserControlMiningOverlay_Limcargo), limpetsleftdisplay, cargoleftdisplay);
                        if (collectorsused > 0 || prospectorsused > 0 || asteroidscracked > 0)
                        {
                            text += string.Format(", Prospectors Fired {0}, Collectors Deployed {1}, Cracked {2}".T(EDTx.UserControlMiningOverlay_Proscoll), prospectorsused, collectorsused, asteroidscracked);
                        }

                        var ieprosp = pictureBox.AddTextAutoSize(new Point(hpos[limpetscolpos], vpos), new Size(this.Width - hpos[limpetscolpos] - 20, this.Height),
                                                                 text, displayfont, textcolour, backcolour, 1.0F, frmt: frmt);

                        vpos = ieprosp.Location.Bottom + displayfont.ScalePixels(2);
                    }

                    bool displaytable = found.Count > 0 && (extCheckBoxZeroRefined.Checked ? lastrefined > 0 : true);

                    if (displaytable)
                    {
                        var ieheader = pictureBox.AddTextAutoSize(new Point(hpos[1], vpos), new Size(colsw[1], this.Height), "Ref.".T(EDTx.UserControlMiningOverlay_ref), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[2], vpos), new Size(colsw[2], this.Height), "Coll.".T(EDTx.UserControlMiningOverlay_coll), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[3], vpos), new Size(colsw[3], this.Height), "Prosp.".T(EDTx.UserControlMiningOverlay_pros), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);

                        pictureBox.AddTextAutoSize(new Point(hpos[4], vpos), new Size(colsw[4], this.Height), "Ratio%".T(EDTx.UserControlMiningOverlay_ratio), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[5], vpos), new Size(colsw[5], this.Height), "Avg%".T(EDTx.UserControlMiningOverlay_avg), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[6], vpos), new Size(colsw[6], this.Height), "Min%".T(EDTx.UserControlMiningOverlay_min), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[7], vpos), new Size(colsw[7], this.Height), "Max%".T(EDTx.UserControlMiningOverlay_max), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[8], vpos), new Size(colsw[8], this.Height), "M.Lode".T(EDTx.UserControlMiningOverlay_mload), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[9], vpos), new Size(colsw[9], this.Height), "HML Ct.".T(EDTx.UserControlMiningOverlay_hml), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        pictureBox.AddTextAutoSize(new Point(hpos[10], vpos), new Size(colsw[10], this.Height), "Discv".T(EDTx.UserControlMiningOverlay_discv), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        vpos = ieheader.Location.Bottom + displayfont.ScalePixels(2);

                        if (prospected > 0)
                        {
                            var ie = pictureBox.AddTextAutoSize(new Point(hpos[0], vpos), new Size(colsw[0], this.Height), "Asteroids Pros.".T(EDTx.UserControlMiningOverlay_astpros), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                            pictureBox.AddTextAutoSize(new Point(hpos[3], vpos), new Size(colsw[3], this.Height), prospected.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                            pictureBox.AddTextAutoSize(new Point(hpos[9], vpos), new Size(colsw[9], this.Height), content[0].ToString("N0") + "/" + content[1].ToString("N0") + "/" + content[2].ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                            vpos = ie.Location.Bottom + displayfont.ScalePixels(2);
                        }

                        foreach (var m in found)
                        {
                            if (!extCheckBoxZeroRefined.Checked || m.amountrefined > 0)
                            {
                                var ie1 = pictureBox.AddTextAutoSize(new Point(hpos[0], vpos), new Size(colsw[0], this.Height), m.friendlyname, displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                pictureBox.AddTextAutoSize(new Point(hpos[1], vpos), new Size(colsw[1], this.Height), m.amountrefined.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                pictureBox.AddTextAutoSize(new Point(hpos[2], vpos), new Size(colsw[2], this.Height), (m.amountcollected - m.amountdiscarded).ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                if (m.prospectednoasteroids > 0)
                                {
                                    pictureBox.AddTextAutoSize(new Point(hpos[3], vpos), new Size(colsw[3], this.Height), m.prospectednoasteroids.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);

                                    pictureBox.AddTextAutoSize(new Point(hpos[4], vpos), new Size(colsw[4], this.Height), (100.0 * (double)m.prospectednoasteroids / prospected).ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                    pictureBox.AddTextAutoSize(new Point(hpos[5], vpos), new Size(colsw[5], this.Height), m.prospectedamounts.Average().ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                    pictureBox.AddTextAutoSize(new Point(hpos[6], vpos), new Size(colsw[6], this.Height), m.prospectedamounts.Min().ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                    pictureBox.AddTextAutoSize(new Point(hpos[7], vpos), new Size(colsw[7], this.Height), m.prospectedamounts.Max().ToString("N1"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                    pictureBox.AddTextAutoSize(new Point(hpos[9], vpos), new Size(colsw[9], this.Height), m.content[0].ToString("N0") + "/" + m.content[1].ToString("N0") + "/" + m.content[2].ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                }

                                if (m.motherloadasteroids > 0)
                                {
                                    pictureBox.AddTextAutoSize(new Point(hpos[8], vpos), new Size(colsw[8], this.Height), m.motherloadasteroids.ToString("N0"), displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                }

                                if (m.discovered)
                                {
                                    pictureBox.AddTextAutoSize(new Point(hpos[10], vpos), new Size(colsw[10], this.Height), " *", displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                                }

                                vpos = ie1.Location.Bottom + displayfont.ScalePixels(2);
                            }
                        }
                    }

                    pictureBox.Render(true, new Size(0, vpos + displayfont.ScalePixels(8)));       // control is resized with a min height

                    var prospectedlist = found.Where(m => m.prospectednoasteroids > 0).ToList();

                    UpdateComboBox(prospectedlist.Select(m => m.friendlyname).ToList());

                    int?seli = selectedchart as int?;
                    int?selm = selectedchart is string?prospectedlist.FindIndex(x => x.friendlyname == selectedchart as string) : default(int?);

                    if (prospectedlist.Count > 0 && ((seli.HasValue && seli > 0) || selm.HasValue))
                    {
                        List <MaterialsFound> matdata = new List <MaterialsFound>();
                        if (seli.HasValue)
                        {
                            if (seli == chartfixeditems.Length - 1)
                            {
                                seli = LineC.Length;
                            }

                            for (int i = 0; i < seli.Value && i < prospectedlist.Count; i++)
                            {
                                matdata.Add(prospectedlist[i]);
                            }
                        }
                        else
                        {
                            matdata.Add(prospectedlist[selm.Value]);
                        }

                        try
                        {
                            Chart chart = new Chart();
                            chart.Name            = "chart";    // important for remove by key above
                            chart.Dock            = DockStyle.Fill;
                            chart.BorderlineColor = GridC;      // around the whole thing.
                            chart.BackColor       = backcolour; // the whole chart background

                            chart.BeginInit();
                            chart.BorderlineDashStyle = ChartDashStyle.Solid;

                            ChartArea chartarea = new ChartArea();
                            chartarea.BorderColor     = GridC;      // gives the top/right colours for this type of chart
                            chartarea.BorderDashStyle = ChartDashStyle.Solid;
                            chartarea.BorderWidth     = 1;
                            chartarea.BackColor       = BackC;            // chart area is coloured slightly

                            chartarea.AxisX.LabelStyle.ForeColor = TextC; // label on axis colour
                            chartarea.AxisX.LabelStyle.Font      = displayfont;
                            chartarea.AxisX.MajorGrid.LineColor  = GridC; // major grid colour
                            chartarea.AxisX.LineColor            = GridC; // axis (0 value) colour
                            chartarea.AxisX.Title          = "Content %".T(EDTx.UserControlMiningOverlay_content);
                            chartarea.AxisX.TitleFont      = displayfont;
                            chartarea.AxisX.TitleForeColor = TextC;
                            chartarea.AxisX.Interval       = 10;
                            chartarea.AxisX.Minimum        = 0;

                            chartarea.AxisY.LabelStyle.ForeColor = TextC;
                            chartarea.AxisY.LabelStyle.Font      = displayfont;
                            chartarea.AxisY.MajorGrid.LineColor  = GridC;
                            chartarea.AxisY.LineColor            = GridC; // axis (0 value) colour
                            chartarea.AxisY.Title          = "% Above".T(EDTx.UserControlMiningOverlay_above);
                            chartarea.AxisY.TitleFont      = displayfont;
                            chartarea.AxisY.TitleForeColor = TextC;
                            chartarea.AxisY.Interval       = 10;
                            chartarea.AxisY.Maximum        = 101;

                            chart.ChartAreas.Add(chartarea);

                            chart.Titles.Clear();
                            var title = new Title((matdata.Count == 1 ? (matdata[0].friendlyname + " ") : "") + "Distribution".T(EDTx.UserControlMiningOverlay_dist), Docking.Top, displayfont, TextC);
                            chart.Titles.Add(title);

                            Legend legend = null;

                            if (matdata.Count > 1)      // one legend, series are attached to it via name field
                            {
                                legend             = new Legend();
                                legend.Name        = "Legend1";
                                legend.LegendStyle = LegendStyle.Column;
                                legend.Docking     = Docking.Right;
                                legend.BackColor   = backcolour;
                                legend.ForeColor   = TextC;
                                chart.Legends.Add(legend);
                            }

                            int mi = 0;
                            foreach (var m in matdata)
                            {
                                Series series = new Series();
                                series.Name      = m.friendlyname;
                                series.ChartArea = "ChartArea1";
                                series.ChartType = SeriesChartType.Line;
                                series.Color     = LineC[mi];
                                series.Legend    = "Legend1";

                                int i = 0;
                                for (i = 0; i < CFDbMax; i++)        // 0 - fixed
                                {
                                    int numberabove = m.prospectedamounts.Count(x => x >= i);
                                    series.Points.Add(new DataPoint(i, (double)numberabove / m.prospectednoasteroids * 100.0));
                                    series.Points[i].AxisLabel = i.ToString();
                                }

                                chart.Series.Add(series);
                                mi++;
                            }

                            chart.EndInit();

                            Controls.Add(chart);
                            Controls.SetChildIndex(chart, 0);
                        }
                        catch (NotImplementedException)
                        {
                            // Charting not implemented in mono System.Windows.Forms
                        }
                    }
                }

                buttonExtExcel.Enabled = found.Count != 0;
            }
            else
            {
                pictureBox.Render();
                buttonExtExcel.Enabled = false;
            }

            Update();
        }
Beispiel #51
0
        private void SelectedArea_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (
                SelectedSeries.SelectedItem == null ||
                SelectedArea.SelectedItem == null
                )
            {
                return;
            }

            // Create references to chart areas.
            ChartArea [] areas = new ChartArea[3];
            areas[0] = Chart1.ChartAreas["Default"];
            areas[1] = Chart1.ChartAreas["Chart Area 2"];
            areas[2] = Chart1.ChartAreas["Chart Area 3"];

            // Remove all chart areas from the collection
            Chart1.ChartAreas.Clear();

            // Create references to series
            Series [] series = new Series[6];
            series[0] = Chart1.Series["Series1"];
            series[1] = Chart1.Series["Series2"];
            series[2] = Chart1.Series["Series3"];
            series[3] = Chart1.Series["Series4"];
            series[4] = Chart1.Series["Series5"];
            series[5] = Chart1.Series["Series6"];

            // Remove all series from the collection
            Chart1.Series.Clear();

            // Selected item from check box
            switch (SelectedArea.SelectedIndex)
            {
            case 0:
                // Add chart areas to the collection in selected order
                Chart1.ChartAreas.Add(areas[0]);
                Chart1.ChartAreas.Add(areas[1]);
                Chart1.ChartAreas.Add(areas[2]);
                break;

            case 1:
                Chart1.ChartAreas.Add(areas[0]);
                Chart1.ChartAreas.Add(areas[2]);
                Chart1.ChartAreas.Add(areas[1]);
                break;

            case 2:
                Chart1.ChartAreas.Add(areas[1]);
                Chart1.ChartAreas.Add(areas[0]);
                Chart1.ChartAreas.Add(areas[2]);
                break;

            case 3:
                Chart1.ChartAreas.Add(areas[1]);
                Chart1.ChartAreas.Add(areas[2]);
                Chart1.ChartAreas.Add(areas[0]);
                break;

            case 4:
                Chart1.ChartAreas.Add(areas[2]);
                Chart1.ChartAreas.Add(areas[0]);
                Chart1.ChartAreas.Add(areas[1]);
                break;

            case 5:
                Chart1.ChartAreas.Add(areas[2]);
                Chart1.ChartAreas.Add(areas[1]);
                Chart1.ChartAreas.Add(areas[0]);
                break;
            }

            // Add series to the collection in selected order
            if (SelectedSeries.SelectedIndex == 0)
            {
                Chart1.Series.Add(series[0]);
                Chart1.Series.Add(series[1]);
                Chart1.Series.Add(series[2]);
                Chart1.Series.Add(series[3]);
                Chart1.Series.Add(series[4]);
                Chart1.Series.Add(series[5]);
            }
            else
            {
                Chart1.Series.Add(series[1]);
                Chart1.Series.Add(series[0]);
                Chart1.Series.Add(series[3]);
                Chart1.Series.Add(series[2]);
                Chart1.Series.Add(series[5]);
                Chart1.Series.Add(series[4]);
            }
        }
        private void BuildLineChart()
        {
            var ca = new ChartArea {
                Name = "Historical Trend"
            };

            ca.AxisX.MajorGrid.Enabled = false;
            //ca.AxisX.Interval = 1;
            ca.AxisX.IntervalType = HourlySeries ? DateTimeIntervalType.Hours : DateTimeIntervalType.Days;

            //ca.AxisX.LabelStyle.Enabled = true;
            //ca.AxisX.IsLabelAutoFit = true;
            //ca.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;

            ca.AxisY.MajorGrid.Enabled   = true;
            ca.AxisY.MajorGrid.LineColor = Color.LightGray;

            ca.AxisX.MajorGrid.Enabled   = true;
            ca.AxisX.MajorGrid.LineColor = Color.LightGray;
            ca.AxisX.MajorGrid.LineWidth = 1;


            var percentageValueSelected = (PercentageDivisorType)Enum.Parse(typeof(PercentageDivisorType), hfPercentageValues.Value);


            chrtHistoricalTrend.ChartAreas.Add(ca);
            chrtHistoricalTrend.ChartAreas[0].AxisX.LabelStyle.Angle  = -45;
            chrtHistoricalTrend.ChartAreas[0].AxisX.LabelStyle.Format = HourlySeries ? "HH:mm:00" : "dd/MM/yyyy";
            chrtHistoricalTrend.ChartAreas[0].AxisY.LabelStyle.Format =
                percentageValueSelected == PercentageDivisorType.Values ? "#,0" : "P";


            foreach (var cd in GraphInformation.SeriesData)
            {
                var cs = new Series(cd.SeriesName)
                {
                    ChartType           = SeriesChartType.Line,
                    Color               = cd.GraphColour,
                    BorderWidth         = 2,
                    XValueType          = ChartValueType.DateTime,
                    IsValueShownAsLabel = GraphInformation.ShowLabelSeriesNames.Contains(cd.SeriesName),
                    ToolTip             = "#SERIESNAME - #VALX{dd/MM/yyyy" + (HourlySeries ? " HH:mm:00" : string.Empty) +
                                          "} - #VALY{" + (percentageValueSelected == PercentageDivisorType.Values ? "#,0" : "P") + "}",
                    LabelFormat = percentageValueSelected == PercentageDivisorType.Values ? "#,0" : "P"
                };

                for (var i = 0; i < cd.Xvalue.Count; i++)
                {
                    cs.Points.AddXY(cd.Xvalue[i], cd.Yvalue[i]);
                }



                chrtHistoricalTrend.Series.Add(cs);


                var imageLocation = cd.Displayed ? Checkedboximagelocation : Uncheckedboximagelocation;

                var legendItem = new LegendItem {
                    Name = "Legend Item"
                };
                var legendCell = new LegendCell
                {
                    CellType = LegendCellType.Image,
                    Image    = imageLocation,
                    Name     = "Cell1",
                    Margins  =
                    {
                        Left  = 15,
                        Right = 15
                    },
                    PostBackValue = "LegendClick/" + cd.SeriesName
                };

                var seriesHidden = GraphInformation.HiddenSeriesNames.Contains(cd.SeriesName);

                var legendCell2Colour = seriesHidden ? MarsColours.ChartLegendValuesHidden : cd.GraphColour;

                legendItem.Cells.Add(legendCell);
                legendCell = new LegendCell
                {
                    Name      = "Cell2",
                    Text      = cd.SeriesName,
                    ForeColor = legendCell2Colour,
                    Alignment = ContentAlignment.MiddleLeft
                };
                legendItem.Cells.Add(legendCell);


                legendCell = new LegendCell
                {
                    Name          = "Cell3",
                    Text          = "Values",
                    ForeColor     = legendCell2Colour,
                    Font          = new Font("Tahoma", 9),
                    Alignment     = ContentAlignment.MiddleRight,
                    PostBackValue = "LegendShowLabels/" + cd.SeriesName
                };
                legendItem.Cells.Add(legendCell);

                chrtHistoricalTrend.Legends["RightLegend"].CustomItems.Add(legendItem);
                //


                if (cd.Displayed == false)
                {
                    cs.IsVisibleInLegend = false;
                    cs.Enabled           = false;
                }
            }

            var slideLegendItem = new LegendItem {
                Name = "SlideButton"
            };
            var slideLegendCell = new LegendCell
            {
                Name          = "Cell4",
                Alignment     = ContentAlignment.TopRight,
                PostBackValue = ShowLegend ? "HideLegend" : "ShowLegend",
                CellType      = LegendCellType.Image,
                Image         = ShowLegend ? "~/App.Images/hideRightIcon.gif" : "~/App.Images/hideLeftIcon.gif",
            };

            slideLegendItem.Cells.Add(slideLegendCell);
            chrtHistoricalTrend.Legends["SlideLegend"].CustomItems.Add(slideLegendItem);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="showGraph">show a graph interactively</param>
        /// <param name="GraphsAsFilePrefix">Create graphs as files and test attachments. Null means none</param>
        /// <returns></returns>
        public async Task <List <LeakAnalysisResult> > CalculateLeaksAsync(bool showGraph, string GraphsAsFilePrefix)
        {
            var lstResults = new List <LeakAnalysisResult>();

            this.stressUtilOptions.SetPerfCounterOverrideSettings();
            foreach (var ctr in LstPerfCounterData.Where(pctr => pctr.IsEnabledForMeasurement))
            {
                var leakAnalysis = new LeakAnalysisResult(measurements[ctr.perfCounterType])
                {
                    perfCounterData     = ctr,
                    sensitivity         = stressUtilOptions.Sensitivity,
                    pctOutliersToIgnore = stressUtilOptions.pctOutliersToIgnore,
                    RSquaredThreshold   = stressUtilOptions.RSquaredThreshold
                };
                leakAnalysis.FindLinearLeastSquaresFit();

                lstResults.Add(leakAnalysis);
            }
            if (showGraph)
            {
                var tcs = new TaskCompletionSource <int>();
                // if we're running in testhost process, then we want a timeout
                var timeoutEnabled = this.testContext != null;
                var timeout        = TimeSpan.FromSeconds(60);
                Logger.LogMessage($"Showing graph  timeoutenabled ={timeoutEnabled} {timeout.TotalSeconds:n0} secs");
                var thr = new Thread((oparam) =>
                {
                    try
                    {
                        var graphWin = new GraphWin(this);
                        if (timeoutEnabled)
                        {
                            var timer = new DispatcherTimer()
                            {
                                Interval = timeout
                            };
                            timer.Tick += (o, e) =>
                            {
                                Logger.LogMessage($"Timedout showing graph");
                                timer.Stop();
                                graphWin.Close();
                            };
                            timer.Start();
                        }
                        graphWin.AddGraph(lstResults);
                        if (timeoutEnabled)
                        {
                            graphWin.Title += $" timeout {timeout.TotalSeconds:n0}";
                        }
                        graphWin.ShowDialog();
                        Logger.LogMessage($"finished showing graph");
                    }
                    catch (Exception ex)
                    {
                        Logger.LogMessage($"graph {ex}");
                    }
                    tcs.SetResult(0);
                });
                thr.SetApartmentState(ApartmentState.STA);
                thr.Start();
                await tcs.Task;
                //if (await Task.WhenAny(tcs.Task, Task.Delay(timeout)) != tcs.Task)
                //{
                //    Logger.LogMessage($"Timedout showing graph");
                //}
            }
            // Create graphs as files. do this after showgraph else hang
            if (!string.IsNullOrEmpty(GraphsAsFilePrefix))
            {
                foreach (var item in lstResults)
                {
                    using (var chart = new Chart())
                    {
                        chart.Titles.Add($"{TestName} {item}");
                        chart.Size = new System.Drawing.Size(1200, 800);
                        chart.Series.Clear();
                        chart.ChartAreas.Clear();
                        ChartArea chartArea = new ChartArea("ChartArea");
                        chartArea.AxisY.LabelStyle.Format = "{0:n0}";
                        chartArea.AxisY.Title             = item.perfCounterData.PerfCounterName;
                        chartArea.AxisX.Title             = "Iteration";
                        chartArea.AxisY.LabelStyle.Font   = new System.Drawing.Font("Consolas", 12);
                        chart.ChartAreas.Add(chartArea);
                        chartArea.AxisY.IsStartedFromZero = false;
                        var series = new Series
                        {
                            ChartType = SeriesChartType.Line,
                            Name      = item.perfCounterData.PerfCounterName
                        };
                        series.MarkerSize  = 10;
                        series.MarkerStyle = MarkerStyle.Circle;
                        chart.Series.Add(series);
                        for (int i = 0; i < item.NumSamplesToUse; i++)
                        {
                            var dp = new DataPoint(i + 1, item.lstData[i].point.Y); // measurements taken at end of iteration
                            if (item.lstData[i].IsOutlier)
                            {
                                dp.MarkerColor = System.Drawing.Color.Red;
                                dp.MarkerStyle = MarkerStyle.Cross;
                            }
                            series.Points.Add(dp);
                        }
                        // now show trend line
                        var seriesTrendLine = new Series()
                        {
                            ChartType = SeriesChartType.Line,
                            Name      = "Trend Line"
                        };
                        chart.Series.Add(seriesTrendLine);
                        var dp0 = new DataPoint(1, item.yintercept + item.slope);
                        seriesTrendLine.Points.Add(dp0);
                        var dp1 = new DataPoint(item.NumSamplesToUse, item.NumSamplesToUse * item.slope + item.yintercept);
                        seriesTrendLine.Points.Add(dp1);

                        chart.Legends.Add(new Legend());
                        chart.Legends[0].CustomItems.Add(new LegendItem()
                        {
                            Name              = "IsOutlier",
                            ImageStyle        = LegendImageStyle.Marker,
                            MarkerColor       = System.Drawing.Color.Red,
                            MarkerStyle       = MarkerStyle.Cross,
                            MarkerBorderWidth = 0,
                            MarkerSize        = 10
                        });

                        var fname = Path.Combine(ResultsFolder, $"{GraphsAsFilePrefix} {item.perfCounterData.PerfCounterName}.png");
                        chart.SaveImage(fname, ChartImageFormat.Png);
                        lstFileResults.Add(new FileResultsData()
                        {
                            filename = fname, description = $"{GraphsAsFilePrefix} {item.perfCounterData}"
                        });
                    }
                }
            }
            return(lstResults);
        }
Beispiel #54
0
        private void drawChart()
        {
            chart1.Size = new Size(this.Width - 30, this.Height - 105);
            chart1.ChartAreas.Clear();
            chart1.Titles.Clear();
            chart1.Legends.Clear();
            chart1.Series.Clear();
            chart1.Annotations.Clear();
            logScaleAvailable = true;
            chart1.Invalidate();

            if (loadedFile)
            {
                var chartArea = new ChartArea();

                chartArea.AxisY.MinorGrid.LineColor = Color.LightGray;
                chartArea.AxisX.MinorGrid.LineColor = Color.LightGray;
                chartArea.AxisY.MinorGrid.Enabled   = true;
                chartArea.AxisX.MinorGrid.Enabled   = true;
                chartArea.AxisX.Title              = chartName;
                chartArea.AxisY.Title              = "DEPTH";
                chartArea.AxisY.IsReversed         = true;
                chartArea.AxisY.Minimum            = lasFile.startValue;
                chartArea.AxisX.ScaleView.Zoomable = true;
                chartArea.AxisY.ScaleView.Zoomable = true;

                var series = new Series();
                series.ChartType   = SeriesChartType.Line;
                series.BorderWidth = 1;

                var y = lasFile.chartsData.First().Value.ToList();
                var x = chart.ToArray().ToList();

                for (var i = 0; i < x.Count; i++)
                {
                    if (Math.Abs(lasFile.nullValue - x[i]) < 0.001)
                    {
                        y.RemoveAt(i);
                        x.RemoveAt(i);
                        i--;
                    }

                    else
                    {
                        series.Points.AddXY(x[i], y[i]);
                        if (x[i] < 0.001)
                        {
                            logScaleAvailable = false;
                        }
                    }
                }

                checkBox1.Enabled = logScaleAvailable;

                if (useLogScale)
                {
                    chartArea.AxisX.IsLogarithmic = true;
                }

                chart1.ChartAreas.Add(chartArea);
                chart1.Series.Add(series);
            }
        }
        private void ProcessChartType3D(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, bool labels, Series seriesToDraw)
        {
            if (labels && !selection)
            {
                return;
            }
            ArrayList arrayList = null;

            arrayList = area.GetClusterSeriesNames(seriesToDraw.Name);
            common.DataManager.GetNumberOfPoints((string[])arrayList.ToArray(typeof(string)));
            ArrayList dataPointDrawingOrder = area.GetDataPointDrawingOrder(arrayList, this, selection, COPCoordinates.X | COPCoordinates.Y, null, 0, false);
            bool      flag = false;

            foreach (object item in dataPointDrawingOrder)
            {
                DataPoint3D dataPoint3D = (DataPoint3D)item;
                DataPoint   dataPoint   = dataPoint3D.dataPoint;
                Series      series      = dataPoint.series;
                this.currentStackGroup = StackedColumnChart.GetSeriesStackGroupName(series);
                dataPoint.positionRel  = new PointF(float.NaN, float.NaN);
                Axis            axis            = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
                Axis            axis2           = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName);
                BarDrawingStyle barDrawingStyle = ChartGraphics.GetBarDrawingStyle(dataPoint);
                float           num             = 0.5f;
                float           num2            = 0.5f;
                bool            flag2           = true;
                bool            flag3           = false;
                for (int i = 0; i < arrayList.Count; i++)
                {
                    Series series2 = common.DataManager.Series[i];
                    if (flag2 && dataPoint3D.index <= series2.Points.Count && series2.Points[dataPoint3D.index - 1].YValues[0] != 0.0)
                    {
                        flag2 = false;
                        if (series2.Name == series.Name)
                        {
                            num2 = 0f;
                        }
                    }
                    if (series2.Name == series.Name)
                    {
                        flag3 = true;
                    }
                    else if (dataPoint3D.index <= series2.Points.Count && series2.Points[dataPoint3D.index - 1].YValues[0] != 0.0)
                    {
                        flag3 = false;
                    }
                }
                if (flag3)
                {
                    num = 0f;
                }
                if (area.stackGroupNames != null && area.stackGroupNames.Count > 1 && area.Area3DStyle.Clustered)
                {
                    string seriesStackGroupName = StackedColumnChart.GetSeriesStackGroupName(series);
                    bool   flag4 = true;
                    bool   flag5 = false;
                    foreach (string item2 in arrayList)
                    {
                        Series series3 = common.DataManager.Series[item2];
                        if (StackedColumnChart.GetSeriesStackGroupName(series3) == seriesStackGroupName)
                        {
                            if (flag4 && dataPoint3D.index < series3.Points.Count && series3.Points[dataPoint3D.index - 1].YValues[0] != 0.0)
                            {
                                flag4 = false;
                                if (item2 == series.Name)
                                {
                                    num2 = 0f;
                                }
                            }
                            if (item2 == series.Name)
                            {
                                flag5 = true;
                            }
                            else if (dataPoint3D.index < series3.Points.Count && series3.Points[dataPoint3D.index - 1].YValues[0] != 0.0)
                            {
                                flag5 = false;
                            }
                        }
                    }
                    if (flag5)
                    {
                        num = 0f;
                    }
                }
                double yValue  = this.GetYValue(common, area, series, dataPoint3D.dataPoint, dataPoint3D.index - 1, 0);
                double yValue2 = yValue - this.GetYValue(common, area, series, dataPoint3D.dataPoint, dataPoint3D.index - 1, -1);
                yValue  = axis.GetLogValue(yValue);
                yValue2 = axis.GetLogValue(yValue2);
                if (yValue2 > axis.GetViewMaximum())
                {
                    num     = 0.5f;
                    yValue2 = axis.GetViewMaximum();
                }
                else if (yValue2 < axis.GetViewMinimum())
                {
                    num2    = 0.5f;
                    yValue2 = axis.GetViewMinimum();
                }
                if (yValue > axis.GetViewMaximum())
                {
                    num    = 0.5f;
                    yValue = axis.GetViewMaximum();
                }
                else if (yValue < axis.GetViewMinimum())
                {
                    num2   = 0.5f;
                    yValue = axis.GetViewMinimum();
                }
                double     linearPosition  = axis.GetLinearPosition(yValue);
                double     linearPosition2 = axis.GetLinearPosition(yValue2);
                RectangleF empty           = RectangleF.Empty;
                try
                {
                    empty.X     = (float)(dataPoint3D.xPosition - dataPoint3D.width / 2.0);
                    empty.Width = (float)dataPoint3D.width;
                    if (linearPosition2 < linearPosition)
                    {
                        float num3 = num2;
                        num2         = num;
                        num          = num3;
                        empty.Y      = (float)linearPosition2;
                        empty.Height = (float)linearPosition - empty.Y;
                    }
                    else
                    {
                        empty.Y      = (float)linearPosition;
                        empty.Height = (float)linearPosition2 - empty.Y;
                    }
                }
                catch (Exception)
                {
                    continue;
                }
                dataPoint.positionRel = new PointF((float)dataPoint3D.xPosition, empty.Top);
                if (!dataPoint.Empty)
                {
                    double yValue3 = dataPoint3D.indexedSeries ? ((double)dataPoint3D.index) : dataPoint.XValue;
                    yValue3 = axis2.GetLogValue(yValue3);
                    if (!(yValue3 < axis2.GetViewMinimum()) && !(yValue3 > axis2.GetViewMaximum()) && (!(yValue < axis.GetViewMinimum()) || !(yValue2 < axis.GetViewMinimum())) && (!(yValue > axis.GetViewMaximum()) || !(yValue2 > axis.GetViewMaximum())))
                    {
                        bool flag6 = false;
                        if (!(empty.Right <= area.PlotAreaPosition.X) && !(empty.X >= area.PlotAreaPosition.Right()))
                        {
                            if (empty.X < area.PlotAreaPosition.X)
                            {
                                empty.Width -= area.PlotAreaPosition.X - empty.X;
                                empty.X      = area.PlotAreaPosition.X;
                            }
                            if (empty.Right > area.PlotAreaPosition.Right())
                            {
                                empty.Width -= empty.Right - area.PlotAreaPosition.Right();
                            }
                            if (empty.Width < 0.0)
                            {
                                empty.Width = 0f;
                            }
                            if (empty.Height != 0.0 && empty.Width != 0.0)
                            {
                                DrawingOperationTypes drawingOperationTypes = DrawingOperationTypes.DrawElement;
                                if (common.ProcessModeRegions)
                                {
                                    drawingOperationTypes |= DrawingOperationTypes.CalcElementPath;
                                }
                                graph.StartHotRegion(dataPoint);
                                GraphicsPath path = graph.Fill3DRectangle(empty, dataPoint3D.zPosition, dataPoint3D.depth, area.matrix3D, area.Area3DStyle.Light, dataPoint.Color, num, num2, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, dataPoint.BackGradientEndColor, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, PenAlignment.Inset, barDrawingStyle, true, drawingOperationTypes);
                                graph.StopAnimation();
                                graph.EndHotRegion();
                                if (flag6)
                                {
                                    graph.ResetClip();
                                }
                                if (common.ProcessModeRegions && !labels)
                                {
                                    common.HotRegionsList.AddHotRegion(path, false, graph, dataPoint, series.Name, dataPoint3D.index - 1);
                                }
                                if (dataPoint.ShowLabelAsValue || dataPoint.Label.Length > 0)
                                {
                                    flag = true;
                                }
                            }
                        }
                    }
                }
            }
            if (flag)
            {
                foreach (object item3 in dataPointDrawingOrder)
                {
                    DataPoint3D dataPoint3D2 = (DataPoint3D)item3;
                    DataPoint   dataPoint2   = dataPoint3D2.dataPoint;
                    Series      series4      = dataPoint2.series;
                    Axis        axis3        = area.GetAxis(AxisName.Y, series4.YAxisType, series4.YSubAxisName);
                    Axis        axis4        = area.GetAxis(AxisName.X, series4.XAxisType, series4.XSubAxisName);
                    double      num4         = this.GetYValue(common, area, series4, dataPoint3D2.dataPoint, dataPoint3D2.index - 1, 0);
                    if (num4 > axis3.GetViewMaximum())
                    {
                        num4 = axis3.GetViewMaximum();
                    }
                    if (num4 < axis3.GetViewMinimum())
                    {
                        num4 = axis3.GetViewMinimum();
                    }
                    num4 = axis3.GetLogValue(num4);
                    double     yPosition = dataPoint3D2.yPosition;
                    double     num5      = num4 - axis3.GetLogValue(this.GetYValue(common, area, series4, dataPoint3D2.dataPoint, dataPoint3D2.index - 1, -1));
                    double     height    = dataPoint3D2.height;
                    RectangleF empty2    = RectangleF.Empty;
                    try
                    {
                        empty2.X     = (float)(dataPoint3D2.xPosition - dataPoint3D2.width / 2.0);
                        empty2.Width = (float)dataPoint3D2.width;
                        if (height < yPosition)
                        {
                            empty2.Y      = (float)height;
                            empty2.Height = (float)yPosition - empty2.Y;
                        }
                        else
                        {
                            empty2.Y      = (float)yPosition;
                            empty2.Height = (float)height - empty2.Y;
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    if (!dataPoint2.Empty && !selection)
                    {
                        double yValue4 = dataPoint3D2.indexedSeries ? ((double)dataPoint3D2.index) : dataPoint2.XValue;
                        yValue4 = axis4.GetLogValue(yValue4);
                        if (!(yValue4 < axis4.GetViewMinimum()) && !(yValue4 > axis4.GetViewMaximum()) && (!(num4 < axis3.GetViewMinimum()) || !(num5 < axis3.GetViewMinimum())) && (!(num4 > axis3.GetViewMaximum()) || !(num5 > axis3.GetViewMaximum())))
                        {
                            graph.StartAnimation();
                            this.DrawLabels3D(common, graph, area, dataPoint3D2, dataPoint3D2.index - 1, series4, empty2);
                            graph.StopAnimation();
                        }
                    }
                }
            }
        }
Beispiel #56
0
        public static void addChart()
        {
            object oMissing  = System.Reflection.Missing.Value;
            object oEndOfDoc = "\\endofdoc";

            Word.Application oWord = new Word.Application();
            Word.Document    oDoc  = oWord.Documents.Add(ref oMissing, ref oMissing,
                                                         ref oMissing, ref oMissing);
            oWord.Visible = true;
            Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;


            Chart chart = new Chart();

            chart.Width  = (Unit)400;
            chart.Height = (Unit)300;

            ChartArea area = new ChartArea("");

            area.AxisX.LineColor = System.Drawing.Color.FromArgb(0, 104, 188);
            area.AxisY.LineColor = System.Drawing.Color.FromArgb(0, 104, 188);
            area.AxisX.LineWidth = 2;
            area.AxisY.LineWidth = 2;
            //area.AxisY.Title = "%";
            area.AxisX.MajorGrid.LineWidth = 0;
            area.AxisX.MajorGrid.LineColor = System.Drawing.Color.FromArgb(214, 214, 214);
            area.AxisY.MajorGrid.LineColor = System.Drawing.Color.FromArgb(214, 214, 214);

            area.AxisY.Maximum  = 5;
            area.AxisY.Interval = 1;
            area.AxisX.Interval = 1;
            //area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles..LabelsAngleStep90;
            area.AxisX.LabelStyle.Angle = -70;
            area.AxisX.IsLabelAutoFit   = false;

            chart.ChartAreas.Add(area);

            Series series0 = new Series();

            series0.ChartType           = SeriesChartType.Column;
            series0.ChartArea           = area.Name;
            series0.BorderWidth         = 2;                                      //线条宽度
            series0.ShadowOffset        = 1;                                      //阴影宽度
            series0.IsVisibleInLegend   = true;                                   //是否显示数据说明
            series0.IsValueShownAsLabel = false;
            series0.MarkerStyle         = MarkerStyle.None;
            series0.MarkerSize          = 8;

            series0.Color = System.Drawing.Color.FromArgb(0, 176, 80);
            //series0.Label = "#PERCENT";
            series0.LegendText = "自评得分";

            //Series series1 = new Series();
            //series1.ChartType = SeriesChartType.Column;
            //series1.ChartArea = area.Name;
            //series1.BorderWidth = 2;                                  //线条宽度
            //series1.ShadowOffset = 1;                                 //阴影宽度
            //series1.IsVisibleInLegend = true;                         //是否显示数据说明
            //series1.IsValueShownAsLabel = false;
            //series1.MarkerStyle = MarkerStyle.None;
            //series1.MarkerSize = 8;
            //series1.Color = System.Drawing.Color.FromArgb(255, 217, 102);
            ////series0.Label = "#PERCENT";
            //series1.LegendText = "他评得分";


            Dictionary <string, int> data = new Dictionary <string, int>();

            data.Add("a", 1);
            data.Add("b", 2);
            data.Add("c", 3);
            data.Add("d", 4);
            data.Add("e", 3);

            foreach (var e in data)
            {
                series0.Points.AddXY(e.Key, e.Value);
            }

            //foreach (DictionaryEntry de in subDimension)
            //{
            //    series0.Points.AddXY(de.Key,
            //        decimal.Parse((((int)de.Value + 12) / 4.8).ToString()));
            //    series1.Points.AddXY(de.Key,
            //        decimal.Parse(((int)htSubDimension2[de.Key.ToString().Trim()] / 4.0).ToString()));
            //    //ht3.Add(de.Key.ToString().Trim(), Math.Abs((int)htSubDimension2[de.Key.ToString().Trim()] - (int)de.Value));

            //}



            chart.Series.Add(series0);
            //chart.Series.Add(series1);
            Legend legend = new Legend();

            legend.Docking = Docking.Bottom;
            chart.Legends.Add(legend);

            //string jpgName3 = HttpContext.Current.Server.MapPath("~/Temp/" + Guid.NewGuid().ToString() + ".jpg");
            string jpg = "E:\\chart.jps";

            chart.SaveImage(jpg);

            wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

            object anchor           = oWord.Selection.Range;
            object LinkToFile       = false;
            object SaveWithDocument = true;

            oDoc.InlineShapes.AddPicture(jpg, ref LinkToFile, ref SaveWithDocument, ref anchor);
        }
        private void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, bool shadow, bool labels, Series seriesToDraw)
        {
            bool     flag      = false;
            AxisType axisType  = AxisType.Primary;
            AxisType axisType2 = AxisType.Primary;
            string   a         = string.Empty;
            string   a2        = string.Empty;

            for (int i = 0; i < common.DataManager.Series.Count; i++)
            {
                Series series = common.DataManager.Series[i];
                if (string.Compare(series.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series.ChartArea != area.Name) && series.IsVisible())
                {
                    if (i != 0)
                    {
                        if (axisType == series.XAxisType && axisType2 == series.YAxisType && !(a != series.XSubAxisName) && !(a2 != series.YSubAxisName))
                        {
                            continue;
                        }
                        flag = true;
                        break;
                    }
                    axisType  = series.XAxisType;
                    axisType2 = series.YAxisType;
                    a         = series.XSubAxisName;
                    a2        = series.YSubAxisName;
                }
            }
            if (flag)
            {
                for (int j = 0; j < common.DataManager.Series.Count; j++)
                {
                    Series series2 = common.DataManager.Series[j];
                    if (string.Compare(series2.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series2.ChartArea != area.Name) && series2.IsVisible())
                    {
                        string   seriesStackGroupName = StackedColumnChart.GetSeriesStackGroupName(series2);
                        string[] values = new string[7]
                        {
                            "_X_",
                            series2.XAxisType.ToString(),
                            series2.XSubAxisName,
                            "_Y_",
                            series2.YAxisType.ToString(),
                            series2.YSubAxisName,
                            "__"
                        };
                        seriesStackGroupName = (((DataPointAttributes)series2)["StackedGroupName"] = string.Concat(values));
                    }
                }
            }
            this.stackGroupNames = new ArrayList();
            foreach (Series item in common.DataManager.Series)
            {
                if (string.Compare(item.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item.ChartArea != area.Name) && item.IsVisible())
                {
                    string seriesStackGroupName2 = StackedColumnChart.GetSeriesStackGroupName(item);
                    if (!this.stackGroupNames.Contains(seriesStackGroupName2))
                    {
                        this.stackGroupNames.Add(seriesStackGroupName2);
                    }
                }
            }
            if (area.Area3DStyle.Enable3D)
            {
                if (!shadow)
                {
                    this.ProcessChartType3D(selection, graph, common, area, labels, seriesToDraw);
                }
            }
            else
            {
                string[] series4        = (string[])area.GetSeriesFromChartType(this.Name).ToArray(typeof(string));
                int      numberOfPoints = common.DataManager.GetNumberOfPoints(series4);
                bool     flag2          = area.IndexedSeries(series4);
                for (int k = 0; k < numberOfPoints; k++)
                {
                    for (int l = 0; l < this.stackGroupNames.Count; l++)
                    {
                        this.currentStackGroup = (string)this.stackGroupNames[l];
                        int    num  = 0;
                        double num2 = 0.0;
                        double num3 = 0.0;
                        foreach (Series item2 in common.DataManager.Series)
                        {
                            if (string.Compare(item2.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(item2.ChartArea != area.Name) && item2.IsVisible() && k < item2.Points.Count)
                            {
                                string seriesStackGroupName3 = StackedColumnChart.GetSeriesStackGroupName(item2);
                                if (!(seriesStackGroupName3 != this.currentStackGroup))
                                {
                                    DataPoint dataPoint = item2.Points[k];
                                    dataPoint.positionRel = new PointF(float.NaN, float.NaN);
                                    Axis   axis     = area.GetAxis(AxisName.Y, item2.YAxisType, item2.YSubAxisName);
                                    Axis   axis2    = area.GetAxis(AxisName.X, item2.XAxisType, item2.XSubAxisName);
                                    bool   flag3    = false;
                                    double interval = 1.0;
                                    if (!flag2)
                                    {
                                        if (item2.Points.Count == 1 && (item2.XValueType == ChartValueTypes.Date || item2.XValueType == ChartValueTypes.DateTime || item2.XValueType == ChartValueTypes.Time || item2.XValueType == ChartValueTypes.DateTimeOffset))
                                        {
                                            ArrayList seriesFromChartType = area.GetSeriesFromChartType(this.Name);
                                            ((ChartAreaAxes)area).GetPointsInterval(seriesFromChartType, axis2.Logarithmic, axis2.logarithmBase, true, out flag3);
                                            interval = ((double.IsNaN(axis2.majorGrid.Interval) || axis2.majorGrid.IntervalType == DateTimeIntervalType.NotSet) ? axis2.GetIntervalSize(axis2.minimum, axis2.Interval, axis2.IntervalType) : axis2.GetIntervalSize(axis2.minimum, axis2.majorGrid.Interval, axis2.majorGrid.IntervalType));
                                        }
                                        else
                                        {
                                            interval = area.GetPointsInterval(axis2.Logarithmic, axis2.logarithmBase);
                                        }
                                    }
                                    double pointWidth = item2.GetPointWidth(graph, axis2, interval, 0.8);
                                    pointWidth /= (double)this.stackGroupNames.Count;
                                    if (!selection)
                                    {
                                        common.EventsManager.OnBackPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                                    }
                                    double num4 = this.GetYValue(common, area, item2, dataPoint, k, 0);
                                    if (num != 0)
                                    {
                                        num4 = ((!(num4 >= 0.0)) ? (num4 + num3) : (num4 + num2));
                                    }
                                    bool   flag4 = false;
                                    double num5  = num4;
                                    num4 = axis.GetLogValue(num4);
                                    if (!flag4 || !labels)
                                    {
                                        if (num4 > axis.GetViewMaximum())
                                        {
                                            num4 = axis.GetViewMaximum();
                                        }
                                        if (num4 < axis.GetViewMinimum())
                                        {
                                            num4 = axis.GetViewMinimum();
                                        }
                                    }
                                    double linearPosition = axis.GetLinearPosition(num4);
                                    double num6           = 0.0;
                                    num6 = ((num != 0) ? ((!(this.GetYValue(common, area, item2, dataPoint, k, 0) >= 0.0)) ? num3 : num2) : ((!flag4 || !labels) ? axis.Crossing : 0.0));
                                    double position = axis.GetPosition(num6);
                                    double num7     = dataPoint.XValue;
                                    if (flag2)
                                    {
                                        num7 = (double)k + 1.0;
                                    }
                                    double num8 = axis2.GetPosition(num7);
                                    if (this.stackGroupNames.Count > 1)
                                    {
                                        num8 = num8 - pointWidth * (double)this.stackGroupNames.Count / 2.0 + pointWidth / 2.0 + (double)l * pointWidth;
                                    }
                                    num7 = axis2.GetLogValue(num7);
                                    RectangleF empty = RectangleF.Empty;
                                    try
                                    {
                                        empty.X     = (float)(num8 - pointWidth / 2.0);
                                        empty.Width = (float)pointWidth;
                                        if (position < linearPosition)
                                        {
                                            empty.Y      = (float)position;
                                            empty.Height = (float)linearPosition - empty.Y;
                                        }
                                        else
                                        {
                                            empty.Y      = (float)linearPosition;
                                            empty.Height = (float)position - empty.Y;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        num++;
                                        continue;
                                    }
                                    dataPoint.positionRel = new PointF((float)num8, empty.Top);
                                    if (dataPoint.Empty)
                                    {
                                        num++;
                                    }
                                    else
                                    {
                                        if (common.ProcessModePaint)
                                        {
                                            bool flag5 = false;
                                            if (num7 < axis2.GetViewMinimum() || num7 > axis2.GetViewMaximum() || (num4 < axis.GetViewMinimum() && num6 < axis.GetViewMinimum()) || (num4 > axis.GetViewMaximum() && num6 > axis.GetViewMaximum()))
                                            {
                                                flag5 = true;
                                            }
                                            if (!flag5)
                                            {
                                                int num9 = 0;
                                                if (shadow)
                                                {
                                                    num9 = item2.ShadowOffset;
                                                }
                                                if (!labels)
                                                {
                                                    bool flag6 = false;
                                                    if (empty.X < area.PlotAreaPosition.X || empty.Right > area.PlotAreaPosition.Right() || empty.Y < area.PlotAreaPosition.Y || empty.Bottom > area.PlotAreaPosition.Bottom())
                                                    {
                                                        graph.SetClip(area.PlotAreaPosition.ToRectangleF());
                                                        flag6 = true;
                                                    }
                                                    graph.StartHotRegion(dataPoint);
                                                    graph.StartAnimation();
                                                    if (!shadow || num9 != 0)
                                                    {
                                                        graph.FillRectangleRel(empty, (!shadow) ? dataPoint.Color : Color.Transparent, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, (!shadow) ? dataPoint.BackGradientEndColor : Color.Transparent, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, item2.ShadowColor, num9, PenAlignment.Inset, (!shadow) ? ChartGraphics.GetBarDrawingStyle(dataPoint) : BarDrawingStyle.Default, true);
                                                    }
                                                    graph.StopAnimation();
                                                    graph.EndHotRegion();
                                                    if (flag6)
                                                    {
                                                        graph.ResetClip();
                                                    }
                                                }
                                                else
                                                {
                                                    graph.StartAnimation();
                                                    this.DrawLabels(common, graph, area, dataPoint, k, item2, empty);
                                                    graph.StopAnimation();
                                                }
                                            }
                                        }
                                        if (common.ProcessModeRegions && !shadow && !labels)
                                        {
                                            common.HotRegionsList.AddHotRegion(graph, empty, dataPoint, item2.Name, k);
                                        }
                                        if (!selection)
                                        {
                                            common.EventsManager.OnPaint(item2, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                                        }
                                        if (axis.Logarithmic)
                                        {
                                            num4 = Math.Pow(axis.logarithmBase, num4);
                                        }
                                        num++;
                                        if (this.GetYValue(common, area, item2, dataPoint, k, 0) >= 0.0)
                                        {
                                            num2 = num5;
                                        }
                                        else
                                        {
                                            num3 = num5;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (flag)
                {
                    for (int m = 0; m < common.DataManager.Series.Count; m++)
                    {
                        Series series6 = common.DataManager.Series[m];
                        if (string.Compare(series6.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0 && !(series6.ChartArea != area.Name) && series6.IsVisible())
                        {
                            string text2 = StackedColumnChart.GetSeriesStackGroupName(series6);
                            int    num10 = text2.IndexOf("__", StringComparison.Ordinal);
                            if (num10 >= 0)
                            {
                                text2 = text2.Substring(num10 + 2);
                            }
                            if (text2.Length > 0)
                            {
                                ((DataPointAttributes)series6)["StackedGroupName"] = text2;
                            }
                            else
                            {
                                series6.DeleteAttribute("StackedGroupName");
                            }
                        }
                    }
                }
            }
        }
Beispiel #58
0
        private void InitChart()
        {
            //定义图表区
            chart1.ChartAreas.Clear();
            ChartArea chartArea1 = new ChartArea("C1");

            chart1.ChartAreas.Add(chartArea1);

            //定义存储和显示点的容器
            chart1.Series.Clear();
            Series series1 = new Series("锭速");//Series[0]

            chart1.Series.Add(series1);


            Series series2 = new Series("前罗拉转速");//Series[1]

            chart1.Series.Add(series2);

            //坐标轴标题
            //this.chart1.ChartAreas[0].AxisX.Title = "时间";
            //this.chart1.ChartAreas[0].AxisX.TitleAlignment = StringAlignment.Far;
            //this.chart1.ChartAreas[0].AxisY.Title = "r/min";
            //this.chart1.ChartAreas[0].AxisY.TitleAlignment = StringAlignment.Far;
            //this.chart1.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated270;

            //Series series3 = new Series("中罗拉转速");//Series[2]
            //chart1.Series.Add(series3);

            //Series series4 = new Series("后罗拉转速");//Series[3]
            //chart1.Series.Add(series4);

            //Series series5 = new Series("S5");//Series[4]
            //chart1.Series.Add(series5);

            //Series series6 = new Series("S6");//Series[5]
            //chart1.Series.Add(series6);
            //chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
            //设置图表的样式
            chart1.ChartAreas[0].AxisX.Enabled = AxisEnabled.True;//显示横纵坐标轴
            //chart1.ChartAreas[0].AxisX.Minimum = 0;
            //chart1.ChartAreas[0].AxisX.Minimum = 24;
            //chart1.ChartAreas[0].AxisX.Interval = 1;//Y轴间隔

            chart1.ChartAreas[0].AxisY.Enabled  = AxisEnabled.True;
            chart1.ChartAreas[0].AxisY.Minimum  = 0;   //Y轴范围
            chart1.ChartAreas[0].AxisY.Maximum  = 12000;
            chart1.ChartAreas[0].AxisY.Interval = 800; //Y轴间隔
            this.chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = System.Drawing.Color.Red;
            //第二个轴
            chart1.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;
            series2.YAxisType = AxisType.Secondary;
            chart1.ChartAreas[0].AxisY2.Minimum  = 0;
            chart1.ChartAreas[0].AxisY2.Maximum  = 300;
            chart1.ChartAreas[0].AxisY2.Interval = 20;
            this.chart1.ChartAreas[0].AxisY2.LabelStyle.ForeColor = System.Drawing.Color.Blue;

            chart1.ChartAreas[0].AxisX.ScaleView.Scroll(ScrollType.Last); //水平滚动条始终居于最右边


            //chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.Silver;//网络线
            //chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.Silver;


            //设置图标
            chart1.Titles.Clear();
            chart1.Titles.Add("S01");
            chart1.Titles[0].Text           = "速率显示";
            this.chart1.Titles[0].ForeColor = Color.RoyalBlue;
            this.chart1.Titles[0].Font      = new System.Drawing.Font("Microsoft Sans Serif", 12F);

            //设置图表样式
            chart1.Series[0].Color       = Color.Red;
            chart1.Series[0].MarkerStyle = MarkerStyle.Circle;   //圆形点
            chart1.Series[0].ChartType   = SeriesChartType.Line; //折线图
            chart1.Series[0].MarkerSize  = 3;
            chart1.Series[0].Points.Clear();

            chart1.Series[1].Color       = Color.Blue;
            chart1.Series[1].MarkerStyle = MarkerStyle.Circle;   //圆形点
            chart1.Series[1].ChartType   = SeriesChartType.Line; //折线图
            chart1.Series[1].MarkerSize  = 3;
            chart1.Series[1].Points.Clear();

            //chart1.Series[2].Color = Color.Yellow;
            //chart1.Series[2].MarkerStyle = MarkerStyle.Circle;//圆形点
            //chart1.Series[2].ChartType = SeriesChartType.Line;//折线图
            //chart1.Series[2].Points.Clear();

            //chart1.Series[3].Color = Color.Green;
            //chart1.Series[3].MarkerStyle = MarkerStyle.Circle;//圆形点
            //chart1.Series[3].ChartType = SeriesChartType.Line;//折线图
            //chart1.Series[3].Points.Clear();

            //chart1.Series[4].Color = Color.Blue;
            //chart1.Series[4].MarkerStyle = MarkerStyle.Circle;//圆形点
            //chart1.Series[4].ChartType = SeriesChartType.Line;//折线图
            //chart1.Series[4].Points.Clear();

            //chart1.Series[5].Color = Color.Cyan;
            //chart1.Series[5].MarkerStyle = MarkerStyle.Circle;//圆形点
            //chart1.Series[5].ChartType = SeriesChartType.Line;//折线图
            //chart1.Series[5].Points.Clear();

            // Zoom into the X axis
            //chart1.ChartAreas[0].AxisX.ScaleView.Zoom(2, 3);
// Enable range selection and zooming end user interface

            chart1.ChartAreas[0].CursorX.IsUserEnabled          = true;
            chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            chart1.ChartAreas[0].AxisX.ScaleView.Zoomable       = true;

            //将滚动内嵌到坐标轴中
            chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            // 设置滚动条的大小
            chart1.ChartAreas[0].AxisX.ScrollBar.Size = 15;

            // 设置滚动条的按钮的风格,下面代码是将所有滚动条上的按钮都显示出来
            chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;

            // 设置自动放大与缩小的最小量
            chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollSize    = double.NaN;
            chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSize = 2;

            //chart1.ChartAreas[0].CursorX.Interval = 0;
        }
 public void AddSmartLabelMarkerPositions(CommonElements common, ChartArea area, Series series, ArrayList list)
 {
 }
 public double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex)
 {
     return(point.YValues[yValueIndex]);
 }