Search code examples
androidhighchartsdotnethighcharts

HiChart click event 1st time it's working but when I update the data then click event is not working


I am using hichart line graph in my android application. I am setting the data and click event it's working 1st time as excepted but when data changed and I update the graph is displayed properly but click event is not working.

After setting data I am calling reload method but still, the problem persists.

How I am setting the data:

// Click event 
        HIPlotOptions plotoptions = new HIPlotOptions();
                        plotoptions.setSeries(new HISeries());
                        HISeries series = plotoptions.getSeries();

                        plotoptions.getSeries().setLabel(new HILabel());
                        plotoptions.getSeries().getLabel().setConnectorAllowed(false);
                        plotoptions.getSeries().setPoint(new HIPoint());
                        plotoptions.getSeries().getPoint().setEvents(new HIEvents());

                        plotoptions.getSeries().getPoint().getEvents().setClick(new HIFunction(
                                f -> {
                                    setValue(f.getProperty("x"), f.getProperty("y"));
                                }, new String[]{"x", "y"}
                        ));
    options.setPlotOptions(plotoptions);

    // Setting data 

    HISeries line2 = new HISeries();
                        line2.setName(reportDto.getDates().get(0).getMaxBaselineDisplayName());
                        line2.setData(new ArrayList<>(list2));
                        line2.setColor(HIColor.initWithHexValue(chartOneColor));

                        options.setSeries(new ArrayList<>(Arrays.asList(line2)));

                        chartView.setOptions(options);
                        chartView.reload();

Let me know if I am missing something.


Solution

  • As per the documentation chartView.reload(); is deprecated and if you want to update the chart data you just need to set setter method only.

    Remove the reload() method and give it a try!