mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ScatterDraw: Included etacked plots
git-svn-id: svn://ultimatepp.org/upp/trunk@11642 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ac4a2bdd20
commit
3287848d57
3 changed files with 84 additions and 80 deletions
|
|
@ -212,7 +212,7 @@ public:
|
|||
};
|
||||
|
||||
class DataAppend : public DataSource {
|
||||
private:
|
||||
protected:
|
||||
DataSource *data1, *data2;
|
||||
|
||||
public:
|
||||
|
|
@ -238,6 +238,83 @@ public:
|
|||
virtual int64 GetCount() {return data1->GetCount() + data2->GetCount();}
|
||||
};
|
||||
|
||||
class DataRange : public DataAppend {
|
||||
public:
|
||||
DataRange() : DataAppend() {}
|
||||
DataRange(DataSource &data1, DataSource &data2) {Init(data1, data2);}
|
||||
void Init(DataSource &data1, DataSource &data2) {
|
||||
ASSERT(!data1.IsExplicit() && !data1.IsParam() && !data2.IsExplicit() && !data2.IsParam());
|
||||
this->data1 = &data1;
|
||||
rev.Init(data2);
|
||||
this->data2 = &rev;
|
||||
}
|
||||
private:
|
||||
DataReverse rev;
|
||||
};
|
||||
|
||||
class DataStackedY {
|
||||
public:
|
||||
DataStackedY() : is100(false) {}
|
||||
void Set100(bool is100) {this->is100 = is100;}
|
||||
DataStackedY &Add(DataSource &data) {
|
||||
EachDataStackedY &each = eachData.Add();
|
||||
each.Init(data, eachData.GetCount() -1, this);
|
||||
return *this;
|
||||
}
|
||||
double Get100Y(int index, int64 id) {
|
||||
double acc = 0;
|
||||
for (int i = 0; i < eachData.GetCount(); ++i)
|
||||
acc += eachData[i].RealY(id);
|
||||
if (acc == 0)
|
||||
return 0;
|
||||
else
|
||||
return 100*eachData[index].RealY(id)/acc;
|
||||
}
|
||||
double GetY(int index, int64 id) {
|
||||
double res = 0;
|
||||
for (int i = 0; i <= index; ++i) {
|
||||
if (is100)
|
||||
res += Get100Y(i, id);
|
||||
else
|
||||
res += eachData[i].RealY(id);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
class EachDataStackedY : public DataSource {
|
||||
public:
|
||||
EachDataStackedY() : data(0), index(-1), parent(0) {}
|
||||
void Init(DataSource &data, int index, DataStackedY *parent) {
|
||||
ASSERT(!data.IsExplicit() && !data.IsParam());
|
||||
this->data = &data;
|
||||
this->index = index;
|
||||
this->parent = parent;
|
||||
}
|
||||
virtual inline double y(int64 id) {
|
||||
return parent->GetY(index, id);
|
||||
}
|
||||
double RealY(int64 id) {
|
||||
return data->y(id);
|
||||
}
|
||||
virtual inline double x(int64 id) {
|
||||
return data->x(id);
|
||||
}
|
||||
virtual int64 GetCount() {
|
||||
return data->GetCount();
|
||||
}
|
||||
private:
|
||||
DataSource *data;
|
||||
int index;
|
||||
DataStackedY *parent;
|
||||
};
|
||||
|
||||
EachDataStackedY &Get(int id) {return eachData[id];}
|
||||
|
||||
protected:
|
||||
Array<EachDataStackedY> eachData;
|
||||
bool is100;
|
||||
};
|
||||
|
||||
class CArray : public DataSource {
|
||||
private:
|
||||
double *yData, *xData, *zData;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ static void DrawPie(Draw& w, double c_x, double c_y, double r, int start, int al
|
|||
double dxy = (x-ix)*(x-ix) + (y-iy)*(y-iy);
|
||||
if(dxy < 0.1 || i == 0 || i == n)
|
||||
vP << Point(ix,iy);
|
||||
if(w.IsGui())
|
||||
if(w.IsGui() && !IsNull(background))
|
||||
w.DrawRect(ix, iy, 1, 1, Blend(fill, background, 150));
|
||||
}
|
||||
vP << centre;
|
||||
|
|
@ -80,7 +80,8 @@ Color PieDraw::GetCatColor(const int& index) const {
|
|||
void PieDraw::PaintPie(Draw& w, int scale) {
|
||||
Size sz = scale*GetSize();
|
||||
|
||||
w.DrawRect(sz, backColor);
|
||||
if (!IsNull(backColor))
|
||||
w.DrawRect(sz, backColor);
|
||||
|
||||
Size textsize;
|
||||
textsize.cx = 0;
|
||||
|
|
@ -92,7 +93,7 @@ void PieDraw::PaintPie(Draw& w, int scale) {
|
|||
FontTitle6.Width(scale*titleFont.GetWidth());
|
||||
textsize = GetTextSize(title, FontTitle6);
|
||||
if(titlePos == TOP)
|
||||
w.DrawText((scale*GetSize().cx - textsize.cx)/2, scale*titleGap, title, FontTitle6,titleColor);
|
||||
w.DrawText((scale*GetSize().cx - textsize.cx)/2, scale*titleGap, title, FontTitle6, titleColor);
|
||||
else
|
||||
w.DrawText((scale*GetSize().cx - textsize.cx)/2, scale*(GetSize().cy - titleFont.GetHeight() - titleGap),
|
||||
title, FontTitle6,titleColor);
|
||||
|
|
@ -130,15 +131,9 @@ void PieDraw::PaintPie(Draw& w, int scale) {
|
|||
circ_y *= scale;
|
||||
circ_r *= scale;
|
||||
|
||||
Color bc;
|
||||
if (IsNull(backColor))
|
||||
bc = LtGray;
|
||||
else
|
||||
bc = backColor;
|
||||
|
||||
for(int i = 0; i < vValues.GetCount(); i++) {
|
||||
DrawPie(w, circ_x*scale, circ_y*scale, circ_r*scale, alfa0, fround(3600.0*vValues.At(i)/sum),
|
||||
1*scale, vColors.At(i), vColors.At(i), 0, bc);
|
||||
1*scale, vColors.At(i), vColors.At(i), 0, backColor);
|
||||
alfa0 += fround(3600.0*vValues[i]/sum);
|
||||
}
|
||||
if(showPercent) {
|
||||
|
|
|
|||
|
|
@ -368,11 +368,6 @@ ScatterDraw &ScatterDraw::SetXYMin(double xmin, double ymin, double ymin2) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
/*void ScatterDraw::FitToData(bool vertical, double factor) {
|
||||
ZoomToFit(true, vertical, factor);
|
||||
}*/
|
||||
|
||||
void ScatterDraw::ZoomToFit(bool horizontal, bool vertical, double factor) {
|
||||
if (linkedMaster) {
|
||||
linkedMaster->ZoomToFit(horizontal, vertical);
|
||||
|
|
@ -384,70 +379,7 @@ void ScatterDraw::ZoomToFit(bool horizontal, bool vertical, double factor) {
|
|||
linkedCtrls[i]->DoFitToData(horizontal, vertical, factor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
double ScatterDraw::GetXMin() {
|
||||
double minx = -DOUBLE_NULL;
|
||||
|
||||
for (int j = 0; j < series.GetCount(); j++) {
|
||||
if (series[j].opacity == 0 || series[j].PointsData()->IsExplicit())
|
||||
continue;
|
||||
double smin = series[j].PointsData()->MinX();
|
||||
if (!IsNull(smin) && smin < minx)
|
||||
minx = smin;
|
||||
}
|
||||
if (minx == -DOUBLE_NULL)
|
||||
return Null;
|
||||
return minx;
|
||||
}
|
||||
|
||||
double ScatterDraw::GetXMax() {
|
||||
double maxx = DOUBLE_NULL;
|
||||
|
||||
for (int j = 0; j < series.GetCount(); j++) {
|
||||
if (series[j].opacity == 0 || series[j].PointsData()->IsExplicit())
|
||||
continue;
|
||||
double smax = series[j].PointsData()->MaxX();
|
||||
if (!IsNull(smax) && smax > maxx)
|
||||
maxx = smax;
|
||||
}
|
||||
if (maxx == DOUBLE_NULL)
|
||||
return Null;
|
||||
return maxx;
|
||||
}
|
||||
|
||||
double ScatterDraw::GetYMin() {
|
||||
double miny = -DOUBLE_NULL;
|
||||
|
||||
for (int j = 0; j < series.GetCount(); j++) {
|
||||
if (series[j].opacity == 0 || series[j].PointsData()->IsExplicit())
|
||||
continue;
|
||||
double smin = series[j].PointsData()->MinY();
|
||||
if (!IsNull(smin) && smin < miny)
|
||||
miny = smin;
|
||||
}
|
||||
if (miny == -DOUBLE_NULL)
|
||||
return Null;
|
||||
return miny;
|
||||
}
|
||||
|
||||
double ScatterDraw::GetYMax() {
|
||||
double maxy = DOUBLE_NULL;
|
||||
|
||||
for (int j = 0; j < series.GetCount(); j++) {
|
||||
if (series[j].opacity == 0 || series[j].PointsData()->IsExplicit())
|
||||
continue;
|
||||
double smax = series[j].PointsData()->MaxY();
|
||||
if (!IsNull(smax) && smax > maxy)
|
||||
maxy = smax;
|
||||
}
|
||||
if (maxy == DOUBLE_NULL)
|
||||
return Null;
|
||||
return maxy;
|
||||
}
|
||||
*/
|
||||
|
||||
void ScatterDraw::DoFitToData(bool horizontal, bool vertical, double factor) {
|
||||
double minx, maxx, miny, miny2, maxy, maxy2;
|
||||
minx = miny = miny2 = -DOUBLE_NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue