3

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.

Harsh Shah
  • 2,162
  • 2
  • 19
  • 39
  • chartView.reload() is working fine for me, but it is deprecated. What is the alternative for it. I want to change the xAxis and series both and reload in same chartView. How can i achieve this without using reload() ? – K Pradeep Kumar Reddy Jun 22 '22 at 11:13

2 Answers2

0

First of all, the reload() method has been deprecated so avoid using it.

And if I'm not wrong, shouldn't you need to do this after creating HIPlotOptions: options.setPlotOptions(plotoptions);

You can check out the examples here.

bhavya_karia
  • 760
  • 1
  • 6
  • 12
  • yes, I am doing it. I just check it's copy paste error. I am updating the question. Do you know another workaround? – Harsh Shah Apr 15 '19 at 07:43
  • what should I use instead of reload() – Harsh Shah Apr 15 '19 at 07:47
  • For `reload()` substitute, checkout this [link](https://github.com/highcharts/highcharts-android/issues/57). – bhavya_karia Apr 15 '19 at 08:21
  • @bhavya_karia I could not understand from the link that you provided. Can you please help ? chartView.reload() is working fine for me, but it is deprecated. What is the alternative for it. I want to change the xAxis and series both and reload in same chartView. How can i achieve this without using reload() ? – K Pradeep Kumar Reddy Jun 22 '22 at 11:11
0

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!

Sandesh Dumbre
  • 226
  • 2
  • 9
  • Do you mean to call chartView.setOptions(options); ? If not could you please tell the correct code. – Pooja Rajendran C Nov 18 '20 at 06:07
  • chartView.reload() is working fine for me, but it is deprecated. What is the alternative for it. I want to change the xAxis and series both and reload in same chartView. How can i achieve this without using reload() ? – K Pradeep Kumar Reddy Jun 22 '22 at 11:10