【问题标题】:HiChart click event 1st time it's working but when I update the data then click event is not workingHighChart 点击事件第一次起作用,但是当我更新数据时,点击事件不起作用
【发布时间】:2019-04-15 06:19:15
【问题描述】:

我在我的 android 应用程序中使用 hichart 折线图。 我正在设置数据并单击事件,它第一次工作是例外,但是当数据更改并且我更新图表时,图表会正确显示,但单击事件不起作用。

设置数据后,我正在调用 reload 方法,但问题仍然存在。

我是如何设置数据的:

// 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();

如果我遗漏了什么,请告诉我。

【问题讨论】:

    标签: android highcharts dotnethighcharts


    【解决方案1】:

    根据文档,chartView.reload(); 已弃用,如果您想更新图表数据,您只需设置 setter 方法即可。

    去掉reload()方法试试看!

    【讨论】:

    • 你的意思是调用chartView.setOptions(options); ?如果不能,请告诉正确的代码。
    【解决方案2】:

    首先,reload() 方法一直是deprecated 所以避免使用它。

    如果我没记错的话,在创建 HIPlotOptions 之后您是否需要这样做: options.setPlotOptions(plotoptions);

    您可以查看示例here

    【讨论】:

    • 是的,我正在这样做。我只是检查它的复制粘贴错误。我正在更新问题。你知道另一种解决方法吗?
    • 我应该用什么代替 reload()
    • 对于reload() 替代品,请查看此link
    猜你喜欢
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    • 2013-09-15
    • 2018-06-15
    • 2017-08-22
    • 2012-11-07
    • 2018-03-06
    相关资源
    最近更新 更多