Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/21/10 14:45:44 (14 years ago)
Author:
epitzer
Message:

More improvements to EnhancedChart (#1237)

  • Fixed panning (now snaps to selected cursor interval)
  • Changed chart type in DataTableView to EnhancedChart
  • Added static method CustomizeChartArea()
  • Changed CustomizeChartAreas() to CustomizeAllChartAreas()
  • Disabled cursor cross hair
  • Smaller title font
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/EnhancedChart.cs

    r4635 r4636  
    2020#endregion
    2121
     22using System;
    2223using System.ComponentModel;
    2324using System.Drawing;
     
    3132      EnableDoubleClickResetsZoom = true;
    3233      EnableMiddleClickPanning = true;
    33       CustomizeChartAreas();
     34      CustomizeAllChartAreas();
    3435    }
    3536
     
    3940    public bool EnableMiddleClickPanning { get; set; }
    4041
    41     public void CustomizeChartAreas() {
     42    public static void CustomizeChartArea(ChartArea chartArea) {
     43      foreach (Axis axis in chartArea.Axes) {
     44        axis.MajorGrid.LineColor = SystemColors.GradientInactiveCaption;
     45        axis.MajorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis;
     46        axis.ScrollBar.BackColor = Color.Transparent;
     47        axis.ScrollBar.LineColor = Color.Transparent;
     48        axis.ScrollBar.ButtonColor = SystemColors.GradientInactiveCaption;
     49        axis.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
     50        axis.ScrollBar.Size = 12;
     51        axis.TitleFont = new Font(axis.TitleFont.FontFamily, 10);
     52      }
     53      chartArea.CursorX.Interval = 0;
     54      chartArea.CursorY.Interval = 0;
     55      chartArea.CursorX.IsUserSelectionEnabled = true;
     56      chartArea.CursorY.IsUserSelectionEnabled = true;
     57      chartArea.CursorX.IsUserEnabled = false;
     58      chartArea.CursorY.IsUserEnabled = false;
     59      chartArea.CursorX.SelectionColor = SystemColors.GradientActiveCaption;
     60      chartArea.CursorY.SelectionColor = SystemColors.GradientActiveCaption;
     61    }
     62
     63    public void CustomizeAllChartAreas() {
    4264      foreach (ChartArea chartArea in ChartAreas) {
    43         foreach (Axis axis in chartArea.Axes) {
    44           axis.MajorGrid.LineColor = SystemColors.GradientInactiveCaption;
    45           axis.MajorTickMark.TickMarkStyle = TickMarkStyle.AcrossAxis;
    46           axis.ScrollBar.BackColor = Color.Transparent;
    47           axis.ScrollBar.LineColor = Color.Transparent;
    48           axis.ScrollBar.ButtonColor = SystemColors.GradientInactiveCaption;
    49           axis.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
    50           axis.ScrollBar.Size = 12;
    51           axis.TitleFont = new Font(axis.TitleFont.FontFamily, 12);
    52         }
    53 
    54         chartArea.CursorX.Interval = 0;
    55         chartArea.CursorY.Interval = 0;
    56         chartArea.CursorX.IsUserSelectionEnabled = true;
    57         chartArea.CursorY.IsUserSelectionEnabled = true;
    58         chartArea.CursorX.SelectionColor = SystemColors.GradientActiveCaption;
    59         chartArea.CursorY.SelectionColor = SystemColors.GradientActiveCaption;
     65        CustomizeChartArea(chartArea);
    6066      }
    6167    }
     
    122128    protected override void OnMouseMove(MouseEventArgs e) {
    123129      if (panning != null) {
    124         panning.ChartArea.AxisX.ScaleView.Scroll(panning.ChartX(e.Location.X));
    125         panning.ChartArea.AxisY.ScaleView.Scroll(panning.ChartY(e.Location.Y));
     130        double x = panning.ChartX(e.Location.X);
     131        double y = panning.ChartY(e.Location.Y);
     132        if (panning.ChartArea.CursorX.Interval > 0) {
     133          x = Math.Round(x * panning.ChartArea.CursorX.Interval) / panning.ChartArea.CursorX.Interval;
     134          y = Math.Round(y * panning.ChartArea.CursorY.Interval) / panning.ChartArea.CursorY.Interval;
     135        }
     136        panning.ChartArea.AxisX.ScaleView.Scroll(x);
     137        panning.ChartArea.AxisY.ScaleView.Scroll(y);
    126138      }
    127139      base.OnMouseMove(e);
Note: See TracChangeset for help on using the changeset viewer.