Skip to content

Commit

Permalink
Fixed issue concerning grouped-barchart (issue ChartsOrg/Charts#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilJay committed Jul 27, 2015
1 parent 8b79de7 commit c93dc08
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,15 @@ public void onStopTrackingTouch(SeekBar seekBar) {

private void setData(int count, float range) {

ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add(mMonths[i % 12]);
}

ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
ArrayList<String> xVals = new ArrayList<String>();

for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(val, i));
xVals.add(mMonths[i % 12]);
yVals1.add(new BarEntry((float) (Math.random() * range), i));
}

BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setBarSpacePercent(35f);
BarDataSet set1 = new BarDataSet(yVals1, "DataSet 1");

ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
dataSets.add(set1);
Expand All @@ -261,7 +255,6 @@ private void setData(int count, float range) {
data.setValueTextSize(10f);
data.setValueTypeface(tf);

mChart.setDrawValueAboveBar(false);
mChart.setData(data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void feed(List<BarEntry> entries) {
BarEntry e = entries.get(i);

// calculate the x-position, depending on datasetcount
float x = e.getXIndex() + i * dataSetOffset + mDataSetIndex
+ mGroupSpace * i + groupSpaceHalf;
float x = e.getXIndex() + e.getXIndex() * dataSetOffset + mDataSetIndex
+ mGroupSpace * e.getXIndex() + groupSpaceHalf;
float y = e.getVal();
float [] vals = e.getVals();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public void feed(List<BarEntry> entries) {
BarEntry e = entries.get(i);

// calculate the x-position, depending on datasetcount
float x = e.getXIndex() + i * dataSetOffset + mDataSetIndex
+ mGroupSpace * i + groupSpaceHalf;
float x = e.getXIndex() + e.getXIndex() * dataSetOffset + mDataSetIndex
+ mGroupSpace * e.getXIndex() + groupSpaceHalf;
float y = e.getVal();
float[] vals = e.getVals();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,10 @@ public float[] generateTransformedValuesBarChart(List<? extends Entry> entries,
for (int j = 0; j < valuePoints.length; j += 2) {

Entry e = entries.get(j / 2);
int i = e.getXIndex();

// calculate the x-position, depending on datasetcount
float x = e.getXIndex() + (j / 2 * (setCount - 1)) + dataSet + space * (j / 2)
float x = e.getXIndex() + i * (setCount - 1) + dataSet + space * i
+ space / 2f;
float y = e.getVal();

Expand Down Expand Up @@ -258,9 +259,10 @@ public float[] generateTransformedValuesHorizontalBarChart(List<? extends Entry>
for (int j = 0; j < valuePoints.length; j += 2) {

Entry e = entries.get(j / 2);
int i = e.getXIndex();

// calculate the x-position, depending on datasetcount
float x = e.getXIndex() + (j / 2 * (setCount - 1)) + dataSet + space * (j / 2)
float x = e.getXIndex() + i * (setCount - 1) + dataSet + space * i
+ space / 2f ;
float y = e.getVal();

Expand Down

0 comments on commit c93dc08

Please sign in to comment.