use of com.db.chart.model.Bar in project WilliamChart by diogobernardino.
the class XRendererTest method setUp.
@Before
public void setUp() {
mXRndr = new XRenderer();
BarSet set = new BarSet();
for (int i = 0; i < 2; i++) set.addBar(new Bar(Integer.toString(i), (float) i));
mData = new ArrayList<>();
mData.add(set);
mXRndr.init(mData, mStyleMock);
}
use of com.db.chart.model.Bar in project WilliamChart by diogobernardino.
the class YRendererTest method setUp.
@Before
public void setUp() {
mYRndr = new YRenderer();
BarSet set = new BarSet();
for (int i = 0; i < 2; i++) set.addBar(new Bar(Integer.toString(i), (float) i));
mData = new ArrayList<>();
mData.add(set);
}
use of com.db.chart.model.Bar in project WilliamChart by diogobernardino.
the class ChartViewTest method addData_LesserEntriesSize_ThrowIllegalArgumentException.
@Test(expected = IllegalArgumentException.class)
public void addData_LesserEntriesSize_ThrowIllegalArgumentException() {
mChartView.addData(mData);
BarSet set1 = new BarSet();
set1.addBar(new Bar("3", 1.f));
mChartView.addData(set1);
}
use of com.db.chart.model.Bar in project WilliamChart by diogobernardino.
the class ChartViewTest method setUp.
@Before
public void setUp() {
when(mMockContext.getResources()).thenReturn(mMockResources);
when(mMockResources.getDimension(0)).thenReturn(6.f);
mChartView = new LineChartView(mMockContext);
BarSet set = new BarSet();
for (int i = 0; i < 2; i++) set.addBar(new Bar(Integer.toString(i), (float) i));
mData = new ArrayList<>();
mData.add(set);
}
use of com.db.chart.model.Bar in project WilliamChart by diogobernardino.
the class BaseStackBarChartView method calculateMaxStackBarValue.
/**
* This method will calculate what needs to be the max axis value that fits all the sets
* aggregated, one on top of the other.
*/
private void calculateMaxStackBarValue() {
float positiveStackValue;
float negativeStackValue;
BarSet barSet;
Bar bar;
int maxStackValue = 0;
int minStackValue = 0;
int dataSize = data.size();
int setSize = data.get(0).size();
for (int i = 0; i < setSize; i++) {
positiveStackValue = 0;
negativeStackValue = 0;
for (int j = 0; j < dataSize; j++) {
barSet = (BarSet) data.get(j);
bar = (Bar) barSet.getEntry(i);
if (bar.getValue() >= 0)
positiveStackValue += bar.getValue();
else
negativeStackValue += bar.getValue();
}
if (maxStackValue < (int) Math.ceil(positiveStackValue))
maxStackValue = (int) Math.ceil(positiveStackValue);
if (minStackValue > (int) Math.ceil(negativeStackValue * -1) * -1)
minStackValue = (int) Math.ceil(negativeStackValue * -1) * -1;
}
while (maxStackValue % this.getStep() != 0) maxStackValue += 1;
while (minStackValue % this.getStep() != 0) minStackValue -= 1;
super.setAxisBorderValues(minStackValue, maxStackValue, this.getStep());
}
Aggregations