如何在CombinedChart中突出显示一个BarDataSet条目?

时间:2016-09-26 18:59:57

标签: java android mpandroidchart

我正在使用MPAndroidChart。我有一个由一个条形图和一个折线图组成的组合图表。当我打开图表活动时,我想在x位置3.0f处输入,只有条形图突出显示。当我调用mCombinedChart.highlight(3.0f, int dataSetIndex, false)时,无论我有int作为数据集索引,它都会给我一个空指针异常。我怎样才能实现目标?

1 个答案:

答案 0 :(得分:1)

  1. 创建突出显示对象:[0] 10:03:47 AM - File change detected. Starting incremental compilation... [0] 10:03:49 AM - Compilation complete. Watching for file changes. [1] [BS] Reloading Browsers... [1] [BS] Reloading Browsers... [1] [1] FAILURE: Build failed with an exception. [1] [1] * What went wrong: [1] Execution failed for task ':mergeDebugAssets'. [1] > Error: java.io.FileNotFoundException: C:\Users\wfrancis\WebstormProjects\S ampleCordovaAngular2Application\platforms\android\assets\www\node_modules\lite-s erver\node_modules\browser-sync\node_modules\bs-recipes\recipes\grunt.html.injec tion\app\browser-sync-start.html (The system cannot find the file specified) [1] [1] * Try: [1] Run with --stacktrace option to get the stack trace. Run with --info or --de bug option to get more log output. [1] [1] Error: java.io.FileNotFoundException: C:\Users\wfrancis\WebstormProjects\Sam pleCordovaAngular2Application\platforms\android\assets\www\node_modules\lite-ser ver\node_modules\browser-sync\node_modules\bs-recipes\recipes\grunt.html.injecti on\app\browser-sync-start.html (The system cannot find the file specified) [1] :mergeDebugAssets FAILED [1] [1] BUILD FAILED [1] [1] Total time: 3 mins 12.839 secs [1] [1] * What went wrong: [1] Execution failed for task ':mergeDebugAssets'. [1] > Error: java.io.FileNotFoundException: C:\Users\wfrancis\WebstormProjects\S ampleCordovaAngular2Application\platforms\android\assets\www\node_modules\lite-s erver\node_modules\browser-sync\node_modules\bs-recipes\recipes\grunt.html.injec tion\app\browser-sync-start.html (The system cannot find the file specified) [1] [1] * Try: [1] Run with --stacktrace option to get the stack trace. Run with --info or --de bug option to get more log output. [1]

  2. 调用设置数据索引方法: Highlight high = new Highlight(float x, int dataSetIndex);

  3. high.setDataIndex(int dataIndex);

  4. 使用setDataIndex方法选择要使用的组合图表的数据对象,并使用dataSetIndex值作为所选数据对象的数据集的索引。