Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1979


Ignore:
Timestamp:
05/31/09 20:12:04 (15 years ago)
Author:
mstoeger
Message:

added bitmap-snapshot function.
fixed auto-zoom bug that caused a "zoom level too high" error when a data row contained only one value. #498

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/LineChart.cs

    r1977 r1979  
    7272      UpdateLayout();
    7373      ZoomToFullView();
     74    }
     75
     76    public Bitmap Snapshot() {
     77      UpdateLayout();
     78      Bitmap bmp = new Bitmap(Width, Height);
     79      using (Graphics g = Graphics.FromImage(bmp)) {
     80        canvas.Draw(g);
     81      }
     82      return bmp;
    7483    }
    7584
     
    392401
    393402      foreach (RowEntry rowEntry in rowEntries) {
    394         YAxisDescriptor yAxisDescriptor = rowEntry.DataRow.YAxis;
    395 
    396         SetClipY(rowEntry,
    397                  yAxisDescriptor.MinValue - ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05),
    398                  yAxisDescriptor.MaxValue + ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05));
     403        YAxisDescriptor yAxis = rowEntry.DataRow.YAxis;
     404
     405        double padding = (yAxis.MaxValue - yAxis.MinValue)*0.05;
     406
     407        double ymin = yAxis.MinValue - padding;
     408        double ymax = yAxis.MaxValue + padding;
     409
     410        if (Math.Abs(ymin-ymax) < double.Epsilon*5) {
     411          ymin -= 0.1;
     412          ymax += 0.1;
     413        }
     414
     415        SetClipY(rowEntry, ymin, ymax);
    399416      }
    400417
Note: See TracChangeset for help on using the changeset viewer.