mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ScatterCtrl_Demo: Modified log example
git-svn-id: svn://ultimatepp.org/upp/trunk@13552 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b1afd0d8ae
commit
dfa9c40707
2 changed files with 28 additions and 1 deletions
|
|
@ -104,6 +104,8 @@ public:
|
|||
|
||||
void Init();
|
||||
void FormatX(String& s, int i, double d);
|
||||
void FormatXGridUnits(String& s, int i, double d);
|
||||
void SetGridLinesX(Vector<double>& unitsX);
|
||||
virtual ScatterCtrl &Scatter() {return scatter;};
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -9,15 +9,40 @@ void Tab6_Logarithmic::Init()
|
|||
scatter.SetRange(6,100);
|
||||
scatter.SetMajorUnits(1,20);
|
||||
scatter.ShowInfo();
|
||||
scatter.SetMouseHandling(false, false);
|
||||
|
||||
s1 <<Pointf(log10(10.0),14)<<Pointf(log10(1e2),25)<<Pointf(log10(1e3),39)<<Pointf(log10(1e4),44)<<Pointf(log10(1e5),76);
|
||||
scatter.AddSeries(s1).Legend("series1");
|
||||
scatter.cbModifFormatX = THISBACK(FormatX);
|
||||
scatter.cbModifFormatXGridUnits = THISBACK(FormatXGridUnits);
|
||||
scatter.SetGridLinesX = THISBACK(SetGridLinesX);
|
||||
}
|
||||
|
||||
void Tab6_Logarithmic::FormatX(String& s, int i, double d)
|
||||
{
|
||||
s = FormatDouble(pow(10., d), 0);
|
||||
double val = pow(10, d);
|
||||
if (val >= 1 && val <= 1e5)
|
||||
s = FormatDoubleExp(val, 0);
|
||||
}
|
||||
|
||||
void Tab6_Logarithmic::FormatXGridUnits(String& s, int i, double d)
|
||||
{
|
||||
double val = pow(10, d);
|
||||
int valint = fround(val);
|
||||
if (abs(val - double(valint)) < 0.0001) {
|
||||
while (valint < -9 || valint > 9)
|
||||
valint /= 10;
|
||||
if (valint == 1)
|
||||
s = FormatDoubleExp(pow(10, d), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Tab6_Logarithmic::SetGridLinesX(Vector<double>& unitsX)
|
||||
{
|
||||
for(int i = 0; scatter.GetXMinUnit() + i*scatter.GetMajorUnitsX() <= scatter.GetXRange(); i++) {
|
||||
for (int ii = 0; ii < 9; ++ii)
|
||||
unitsX << scatter.GetXMinUnit() + i*scatter.GetMajorUnitsX() + (log10((ii+1)*10)-1)*scatter.GetMajorUnitsX();
|
||||
}
|
||||
}
|
||||
|
||||
ScatterDemo *Construct6()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue