Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4638 for trunk


Ignore:
Timestamp:
10/21/10 17:35:49 (14 years ago)
Author:
epitzer
Message:

Fixed panning (#1237)

File:
1 edited

Legend:

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

    r4637 r4638  
    8484      private Point PixelStartPosition;
    8585      private PointF ChartStartPosition;
    86       private SizeF Pixel2ChartScale;
    8786
    8887      public PanningSupport(Point pixelStartPos, ChartArea chartArea, Size size) {
     
    9291          (float)chartArea.AxisX.ScaleView.Position,
    9392          (float)chartArea.AxisY.ScaleView.Position);
    94         Pixel2ChartScale = new SizeF(
    95           (float)chartArea.AxisX.ScaleView.Size /
    96             (size.Width * chartArea.Position.Width * chartArea.InnerPlotPosition.Width / 100 / 100),
    97           (float)chartArea.AxisY.ScaleView.Size /
    98             (size.Height * chartArea.Position.Height * chartArea.InnerPlotPosition.Height / 100 / 100));
    9993      }
    10094
    101       public double ChartX(double pixelX) {
    102         return ChartStartPosition.X - (pixelX - PixelStartPosition.X) * Pixel2ChartScale.Width;
     95      public double ChartX(double pixelX, int width) {
     96        return ChartStartPosition.X - (pixelX - PixelStartPosition.X) *
     97          (ChartArea.AxisX.ScaleView.ViewMaximum - ChartArea.AxisX.ScaleView.ViewMinimum) /
     98            (width * ChartArea.Position.Width * ChartArea.InnerPlotPosition.Width / 100 / 100);
    10399      }
    104       public double ChartY(double pixelY) {
    105         return ChartStartPosition.Y + (pixelY - PixelStartPosition.Y) * Pixel2ChartScale.Height;
     100      public double ChartY(double pixelY, int height) {
     101        return ChartStartPosition.Y + (pixelY - PixelStartPosition.Y) *
     102          (ChartArea.AxisY.ScaleView.ViewMaximum - ChartArea.AxisY.ScaleView.ViewMinimum) /
     103            (height * ChartArea.Position.Height * ChartArea.InnerPlotPosition.Height / 100 / 100);
    106104      }
    107105    }
     
    126124    protected override void OnMouseMove(MouseEventArgs e) {
    127125      if (panning != null) {
    128         double x = panning.ChartX(e.Location.X);
    129         double y = panning.ChartY(e.Location.Y);
     126        double x = panning.ChartX(e.Location.X, Width);
     127        double y = panning.ChartY(e.Location.Y, Height);
    130128        if (panning.ChartArea.CursorX.Interval > 0) {
    131129          x = Math.Round(x * panning.ChartArea.CursorX.Interval) / panning.ChartArea.CursorX.Interval;
Note: See TracChangeset for help on using the changeset viewer.