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));
}
}