Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ public boolean isDrawBarShadowEnabled() {
return mDrawBarShadow;
}

@Override
public void setDrawBarShadowEnabled(boolean value) {
mDrawBarShadow = value;

}

@Override
public void setDrawValueAboveBarEnabled(boolean value) {
mDrawValueAboveBar = value;
}

/**
* Set this to true to make the highlight operation full-bar oriented, false to make it highlight single values (relevant
* only for stacked). If enabled, highlighting operations will highlight the whole bar, even if only a single stack entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ public boolean isDrawValueAboveBarEnabled() {
return mDrawValueAboveBar;
}

@Override
public void setDrawBarShadowEnabled(boolean value) {
mDrawBarShadow = value;
}

@Override
public void setDrawValueAboveBarEnabled(boolean value) {
mDrawValueAboveBar = value;
}

/**
* If set to true, all values are drawn above their bars, instead of below
* their top.
Expand All @@ -186,8 +196,8 @@ public void setDrawValueAboveBar(boolean enabled) {
* If set to true, a grey area is drawn behind each bar that indicates the
* maximum value. Enabling his will reduce performance by about 50%.
*/
public void setDrawBarShadow(boolean enabled) {
mDrawBarShadow = enabled;
public void setDrawBarShadow(boolean value) {
mDrawBarShadow = value;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public Highlight getStackedHighlight(Highlight high, IBarDataSet set, float xVal

/**
* Returns the index of the closest value inside the values array / ranges (stacked barchart) to the value
* given as
* a parameter.
* given as a parameter.
*/
protected int getClosestStackIndex(Range[] ranges, float value) {

Expand All @@ -109,40 +108,6 @@ protected int getClosestStackIndex(Range[] ranges, float value) {
return (value > ranges[length].to) ? length : 0;
}

// /**
// * Splits up the stack-values of the given bar-entry into Range objects.
// *
// * @param entry
// * @return
// */
// protected Range[] getRanges(BarEntry entry) {
//
// float[] values = entry.getYVals();
//
// if (values == null || values.length == 0)
// return new Range[0];
//
// Range[] ranges = new Range[values.length];
//
// float negRemain = -entry.getNegativeSum();
// float posRemain = 0f;
//
// for (int i = 0; i < ranges.length; i++) {
//
// float value = values[i];
//
// if (value < 0) {
// ranges[i] = new Range(negRemain, negRemain + Math.abs(value));
// negRemain += Math.abs(value);
// } else {
// ranges[i] = new Range(posRemain, posRemain + value);
// posRemain += value;
// }
// }
//
// return ranges;
// }

@Override
protected float getDistance(float x1, float y1, float x2, float y2) {
return Math.abs(x1 - x2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,81 +13,61 @@
/**
* Created by Philipp Jahoda on 12/09/15.
*/
public class CombinedHighlighter extends ChartHighlighter<CombinedDataProvider> implements IHighlighter
{

/**
* bar highlighter for supporting stacked highlighting
*/
protected BarHighlighter barHighlighter;

public CombinedHighlighter(CombinedDataProvider chart, BarDataProvider barChart) {
super(chart);

// if there is BarData, create a BarHighlighter
barHighlighter = barChart.getBarData() == null ? null : new BarHighlighter(barChart);
}

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {

mHighlightBuffer.clear();

List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();

for (int i = 0; i < dataObjects.size(); i++) {

ChartData dataObject = dataObjects.get(i);

// in case of BarData, let the BarHighlighter take over
if (barHighlighter != null && dataObject instanceof BarData) {
Highlight high = barHighlighter.getHighlight(x, y);

if (high != null) {
high.setDataIndex(i);
mHighlightBuffer.add(high);
}
} else {

for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {

IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);

// don't include datasets that cannot be highlighted
if (!dataSet.isHighlightEnabled())
continue;

List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
for (Highlight high : highs)
{
high.setDataIndex(i);
mHighlightBuffer.add(high);
}
}
}
}

return mHighlightBuffer;
}

// protected Highlight getClosest(float x, float y, Highlight... highs) {
//
// Highlight closest = null;
// float minDistance = Float.MAX_VALUE;
//
// for (Highlight high : highs) {
//
// if (high == null)
// continue;
//
// float tempDistance = getDistance(x, y, high.getXPx(), high.getYPx());
//
// if (tempDistance < minDistance) {
// minDistance = tempDistance;
// closest = high;
// }
// }
//
// return closest;
// }
public class CombinedHighlighter extends ChartHighlighter<CombinedDataProvider> implements IHighlighter {

/**
* bar highlighter for supporting stacked highlighting
*/
protected BarHighlighter barHighlighter;

public CombinedHighlighter(CombinedDataProvider chart, BarDataProvider barChart) {
super(chart);

// if there is BarData, create a BarHighlighter
barChart.getBarData();
barHighlighter = new BarHighlighter(barChart);
}

@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {

mHighlightBuffer.clear();

List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();

for (int i = 0; i < dataObjects.size(); i++) {

ChartData dataObject = dataObjects.get(i);

// in case of BarData, let the BarHighlighter take over
if (barHighlighter != null && dataObject instanceof BarData) {
Highlight high = barHighlighter.getHighlight(x, y);

if (high != null) {
high.setDataIndex(i);
mHighlightBuffer.add(high);
}
} else {

for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {

IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);

// don't include datasets that cannot be highlighted
if (!dataSet.isHighlightEnabled()) {
continue;
}

List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
for (Highlight high : highs) {
high.setDataIndex(i);
mHighlightBuffer.add(high);
}
}
}
}

return mHighlightBuffer;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.github.mikephil.charting.interfaces.dataprovider

import com.github.mikephil.charting.data.BarData

interface BarDataProvider : BarLineScatterCandleBubbleDataProvider {
val barData: BarData
var isDrawBarShadowEnabled: Boolean
var isDrawValueAboveBarEnabled: Boolean
var isHighlightFullBarEnabled: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ open class BarChartRenderer(
val barData = chart.barData

for (i in 0..<barData.dataSetCount) {
val set = barData.getDataSetByIndex(i)
val dataSet = barData.getDataSetByIndex(i)

if (set.isVisible) {
drawDataSet(canvas, set, i)
if (dataSet.isVisible) {
drawDataSet(canvas, dataSet, i)
}
}
}
Expand Down
Loading