예제 #1
0
        private void AdjustLabelsAndTicks(RadChartBase chart, ChartBase dataContext)
        {
            if (_axis == null)
                _axis = chart.Find(x => x.Name == "horizontalLinearAxis") as LinearAxis;

            if (_axis != null)
            {
                var labelInterval = CalculateLabelInterval(dataContext);
                _axis.LabelInterval = labelInterval;

                if (_tickParent == null)
                {
                    var ticks = chart.FindAll(x => x.Tag != null && x.Tag.ToString() == "Tick");
                    if (ticks != null && ticks.Any())
                        _tickParent = ticks[0].Parent as Canvas;
                }

                if (_tickParent != null)
                {
                    var ticks = _tickParent.Children.Where(x => x is Rectangle && ((Rectangle)x).Tag.Equals("Tick"));

                    var cn = 0;
                    foreach (FrameworkElement element in ticks)
                    {
                        var styleModified = element.Style.Clone();

                        if (cn % labelInterval == 0)
                        {
                            styleModified.Setters.Add(new Setter(Rectangle.FillProperty, new SolidColorBrush(Color.FromArgb(0xFF, 0x33, 0x33, 0x33))));
                            styleModified.Setters.RemoveAt(1);
                        }
                        else
                        {
                            styleModified.Setters.Add(new Setter(Rectangle.FillProperty, new SolidColorBrush(Colors.Transparent)));
                            styleModified.Setters.RemoveAt(1);
                        }

                        element.Style = styleModified;
                        cn++;
                    }

                    _oldNumberOfTicks = ticks.Count();
                }           
            }
        }