https://imgur.com/a/nyZMSUb
先来一张示意图
请问MPAndroid Chart要如何做到像图片中
按文字就可以有click的事件
但按各别的横条图或其它空白地方是不会有任何
OnChartValueSelectedListener的事件发生。
以下是我的TextRender的实作
protected void drawText(Canvas c, IBarDataSet dataSet, int index) {
BarBuffer buffer = mBarBuffers[index];
float left; //avoid allocation inside loop
float right;
float top;
float bottom;
for (int j = 0; j < buffer.buffer.length * mAnimator.getPhaseX(); j += 4) {
int i = j/4; //index
left = buffer.buffer[j];
right = buffer.buffer[j + 2];
top = buffer.buffer[j + 1];
bottom = buffer.buffer[j + 3];
BarEntry entry = dataSet.getEntryForIndex(j / 4);
applyValueTextStyle(dataSet);
drawValue(c, dataSet.getValueFormatter(), 0,
entry, i, left, top, dataSet.getValueTextColor(j / 4));
}
}