Menu

Hidden online chart gets overflowed

Aliya
2012-12-19
2013-01-09
  • Aliya

    Aliya - 2012-12-19

    Hi,
    We are using Highcharts for displaying multiple online charts that update with a new point every second.
    Once the charts reach their points limit we use the "shift" flag in the addPoint function to override old points.
    The problem is that the shift flag doesn't affect the hidden charts and their list of points get overflowed.

    Relevant code from Series.java:
    public Series addPoint(Point point, boolean redraw, boolean shift, Animation animation) {
    if (!isRendered() || chart.isPersistent()) {
    // If we haven't been rendered, then just store the point in ourselves for now.
    points.add(point);
    } ...

     
  • Shawn Quinn

    Shawn Quinn - 2013-01-09

    Agreed that this is a bug, thanks for reporting! The fix for this will be included in the next release, but for those that may need the fix in the meantime - below is the updated version of the Series.addPoint method:

        public Series addPoint(Point point, boolean redraw, boolean shift, Animation animation) {
    
            // If we haven't been rendered, then just store the point in ourselves for now. Or,
            // if persistence is enabled than we need to store the point locally as well (so we have it if
            // the chart is dynamically moved to another panel).
            if (!isRendered() || chart.isPersistent()) {
    
                // Need to manually shift the item off the list if we haven't been rendered 
                // yet (after we're rendered Highcharts handles the shift on its own)
                if(shift && points.size() > 0) {
                    points.remove(0);
                }
    
                // If we haven't been rendered, then just store the point in ourselves for now.
                points.add(point);
    
            }
    
            if (isRendered()) {
                // We'll store the point directly in the DOM if we've already been rendered
                final JavaScriptObject nativeSeries = chart.get(this.id);
                if (nativeSeries != null) {
                    if (animation == null || animation.getOptions() == null) {
                        final boolean animationFlag = animation != null;
                        if(point == null || (point.isSingleValue() && point.getY() == null)) {
                            nativeAddPoint(nativeSeries, null, redraw, shift, animationFlag);
                        } else if (point.isSingleValue() && !chart.isPersistent() && !point.hasNativeProperties()) {
                            nativeAddPoint(nativeSeries, point.getY().doubleValue(), redraw, shift, animationFlag);
                        } else {
                            nativeAddPoint(nativeSeries, convertPointToJavaScriptObject(point), redraw, shift, animationFlag);
                        }
                    } else {
                        final JavaScriptObject animationOptions = animation.getOptions().getJavaScriptObject();
                        if(point == null || (point.isSingleValue() && point.getY() == null)) {
                            nativeAddPoint(nativeSeries, null, redraw, shift, animationOptions);
                        } else if (point.isSingleValue() && !chart.isPersistent() && !point.hasNativeProperties()) {
                            nativeAddPoint(nativeSeries, point.getY().doubleValue(), redraw, shift, animationOptions);
                        } else {
                            nativeAddPoint(nativeSeries, convertPointToJavaScriptObject(point), redraw, shift, animationOptions);
                        }
                    }
                }
            }
            return this;
        }
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.