wxFreeChart
numberaxis.h
1 // Name: numberaxis.h
3 // Purpose: Number axis declaration.
4 // Author: Moskvichev Andrey V.
5 // Created: 2008/11/07
6 // Copyright: (c) 2008-2010 Moskvichev Andrey V.
7 // Licence: wxWidgets licence
9 
10 #ifndef NUMBERAXIS_H_
11 #define NUMBERAXIS_H_
12 
13 #include <wx/axis/labelaxis.h>
14 
18 class WXDLLIMPEXP_FREECHART NumberAxis : public LabelAxis
19 {
20  DECLARE_CLASS(NumberAxis)
21 public:
22  NumberAxis(AXIS_LOCATION location);
23  virtual ~NumberAxis();
24 
25  virtual bool UpdateBounds();
26 
31  void SetTickFormat(const wxString &tickFormat)
32  {
33  m_tickFormat = tickFormat;
34  }
35 
36  wxDEPRECATED_MSG("Do not use this function, instead use SetMajorInterval.")
37  void SetLabelCount(size_t labelCount) {}
38 
43  void IntegerValues(bool intValues = true)
44  {
45  if (m_intValues != intValues)
46  {
47  m_intValues = intValues;
48  // TODO recalc tick steps
49  }
50  }
51 
58  void ZeroOrigin(bool zeroOrigin = true)
59  {
60  if (m_zeroOrigin != zeroOrigin)
61  m_zeroOrigin = zeroOrigin;
62  }
63 
71  void ForceExtraMajorInterval(bool force = true)
72  {
73  if (m_extraMajorInterval != force)
74  m_extraMajorInterval = force;
75  }
76 
81  double GetMultiplier() const;
82 
87  void SetMultiplier(double multiplier);
88 
94  void SetFixedBounds(double minValue, double maxValue);
95 
101  virtual void GetDataBounds(double &minValue, double &maxValue) const;
102 
107  size_t GetLabelCount() const;
108 
109 protected:
110  virtual bool AcceptDataset(Dataset *dataset);
111 
119  double CalcNiceInterval(double value, bool round = false);
120 
121  void UpdateMajorIntervalValues();
122 
123  //
124  // LabelAxis
125  //
126  virtual double GetValue(size_t step);
127 
128  virtual void GetLabel(size_t step, wxString &label);
129 
130  virtual bool IsEnd(size_t step);
131 
132  virtual bool HasLabels();
133 
134  virtual wxSize GetLongestLabelExtent(wxDC &dc);
135 
136  // Protected members.
137  bool m_fixedBounds;
138  bool m_hasLabels;
139  double m_minValue;
140  double m_maxValue;
141  double m_labelInterval;
142  size_t m_labelCount;
143 
144 private:
145  // Private members.
146  wxString m_tickFormat;
147  bool m_intValues;
148  bool m_zeroOrigin;
149  bool m_extraMajorInterval;
150  double m_multiplier;
151 };
152 
153 #endif /*NUMBERAXIS_H_*/
wxDEPRECATED_MSG("Use SetMinorIntervalCount instead.") void SetMajorLabelSteps(size_t step)
Sets major label steps.
Definition: labelaxis.h:181
void ForceExtraMajorInterval(bool force=true)
Forces an extra tick to be drawn at the top of vertical axis if the maximum value is the same as the ...
Definition: numberaxis.h:71
Base class for axes for displaying data labels.
Definition: labelaxis.h:29
void SetTickFormat(const wxString &tickFormat)
Sets format for tick marks.
Definition: numberaxis.h:31
virtual void GetDataBounds(double &minValue, double &maxValue) const =0
Returns data bounds.
virtual void GetLabel(size_t step, wxString &label)=0
Returns label on step.
virtual bool UpdateBounds()=0
Performs axis bounds update after dataset/s change.
void IntegerValues(bool intValues=true)
Set whether to use integer values instead of doubles.
Definition: numberaxis.h:43
virtual bool IsEnd(size_t step)=0
Check whether step is last.
Base class for all datasets (XYDatasets, XYZDatasets, CategoryDatasets, OHLCDatasets, etc).
Definition: dataset.h:39
An axis for displaying and scaling numerical data.
Definition: numberaxis.h:18
void ZeroOrigin(bool zeroOrigin=true)
Set whether the axis origin starts at zero.
Definition: numberaxis.h:58
virtual bool AcceptDataset(Dataset *dataset)=0
Checks whether dataset can be accepted by this axis.
virtual double GetValue(size_t step)=0
Returns value on step.