Search in sources :

Example 11 with Bar

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);
}
Also used : Bar(com.db.chart.model.Bar) BarSet(com.db.chart.model.BarSet) Paint(android.graphics.Paint) Before(org.junit.Before)

Example 12 with Bar

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);
}
Also used : Bar(com.db.chart.model.Bar) BarSet(com.db.chart.model.BarSet) Paint(android.graphics.Paint) Before(org.junit.Before)

Example 13 with Bar

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);
}
Also used : Bar(com.db.chart.model.Bar) BarSet(com.db.chart.model.BarSet) MediumTest(android.test.suitebuilder.annotation.MediumTest) Test(org.junit.Test)

Example 14 with Bar

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);
}
Also used : Bar(com.db.chart.model.Bar) BarSet(com.db.chart.model.BarSet) Before(org.junit.Before)

Example 15 with Bar

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());
}
Also used : Bar(com.db.chart.model.Bar) BarSet(com.db.chart.model.BarSet)

Aggregations

Bar (com.db.chart.model.Bar)16 BarSet (com.db.chart.model.BarSet)16 Before (org.junit.Before)4 Rect (android.graphics.Rect)3 LinearGradient (android.graphics.LinearGradient)2 Paint (android.graphics.Paint)2 MediumTest (android.test.suitebuilder.annotation.MediumTest)2 Test (org.junit.Test)2 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 TextView (android.widget.TextView)1 Animation (com.db.chart.animation.Animation)1 OnEntryClickListener (com.db.chart.listener.OnEntryClickListener)1 Tooltip (com.db.chart.tooltip.Tooltip)1 HorizontalBarChartView (com.db.chart.view.HorizontalBarChartView)1