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 39b4e0f commit 6dada9e
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

7 comments on commit 6dada9e

@danielgindi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a chance you missed the change in getMarkerPosition?
BarLineChartViewBase.swift in https://github.com/danielgindi/ios-charts/pull/248/files

@danielgindi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or the changes in BarChartView.swift

@danielgindi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe you had a reason for that? Something went wrong? I need to know before I merge in his fix :-)

@PhilJay
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I missed that thank you! Now fixed 4bb9076

@danielgindi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He had some changes made to the marker position in this regard, but I'm not sure if anyone has tested them throughly

@liuxuan30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PhilJay, I have another change in calcMinMax in BarChartView, but I don't see a similar change in android? I simply change maxEntry to barData.xValCount. I explained it in https://github.com/danielgindi/ios-charts/pull/248/files#r35759740

@liuxuan30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielgindi my peer QA engnieer will start to test my project soon(late this week, actually today I guess) after I finish the migration from my old chart code to yours. If I found issues I would report ASAP. You can wait a while if unsure. BTW, it seems working right now in my bar charts library.

Please sign in to comment.