Achart engine Onclick pie chart slice not working sometimes a bug?

拥有回忆 提交于 2020-01-04 02:41:27

问题


i am working on a pie chart and i am using AchartEngine.

i have the pie chart like this:

Image of a Pie Chart

i have added the onclick to the slices but sometimes only the green slice onlick will not work.

this is my code:

mChartView = ChartFactory.getPieChartView(this, adc.buildCategoryDataset("Project budget", values), renderer);
        mChartView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();
              if (seriesSelection == null) {
                  Toast
                      .makeText(GeneratedChartDemo.this, "No chart element was clicked", Toast.LENGTH_SHORT)
                      .show();
                } else {
                  Toast.makeText(
                          GeneratedChartDemo.this,
                      "Chart element data point index " + seriesSelection.getPointIndex()
                          + " was clicked" + " point value=" + seriesSelection.getValue(),
                      Toast.LENGTH_SHORT).show();
                }
            }
          });

where am i going wrong have i missed something?

EDIT

Thanks to Dan who helped me in solving the problem.


回答1:


Did you add a selectable buffer?

mRenderer.setClickEnabled(true);
mRenderer.setSelectableBuffer(10);

Update: there was a bug that I fixed. You can download a version including this fix here.



来源:https://stackoverflow.com/questions/14499523/achart-engine-onclick-pie-chart-slice-not-working-sometimes-a-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!