Is there a way to clear a chart area?

5 posts, 1 answers
  1. Reghardt
    Reghardt avatar
    6 posts
    Member since:
    May 2015

    Posted 11 Sep 2015 Link to this post

    Hi, 

     

    I have 2 questions, one of which is I am trying to update a graph. Each time I update the graph I am using the documented code to do this and no fault has been spotted. The only problem occurs once I have already data included in this It add an axis and changes the colour of the graph as shown in the picture. Ive had a look around to see if there is a way I would be able to clear the chart area, axis and chart, before I update this. Looking at the available functions there doesn't seem to be a clear or remove for the chart. I am currently using ScatterLineSeries. 

     

    My Next question is to do with trackball and tooltip. I tried using the Trackball function and this doesn't seem to be supported in the ScatterLineSeries (Unless I'm Doing something wrong - Most likely outcome). I would like to use the Trackball as this would show the data for each graph instead of the Tooltip which is for a specific graph, is this know to be working on Scatter Line Series? When I was using the Tooltip the values I am using are doubles is there a way I would be able to convert this to 2 decimal places. It also only show X and Y instead of my axis names is there a way I could change this to the set axis names? 

     

    If any more information is required just let me know. 

  2. Reghardt
    Reghardt avatar
    6 posts
    Member since:
    May 2015

    Posted 14 Sep 2015 Link to this post

    Ive attached the files as these didn't upload last time. 
  3. DevCraft banner
  4. Answer
    Victor
    Admin
    Victor avatar
    1351 posts

    Posted 16 Sep 2015 Link to this post

    Hi Reghardt,

    Thanks for writing.
    I can't see any images on the second post as well. Anyway...

    To clear the chart area you have two options. You can either clear the chart series collection by calling
    chart.getSeries().clear(); or you can iterate over the series collection and call series.setData(null); on each series.

    Currently the trackball does not work well with the scatter series because on the scatter chart the points rarely have the exact same value. Even if they differ by 0.00001 the trackball will think the points are different and will not show them at all. When you move your finger around, the finger position rarely matches a point due to this exact matching. Even if it looks like a point is in the path of the trackball it won't be shown because of a tiny difference in values.

    We have plans to extend ChartTrackBallBehavior to search for points in a range of values instead of exact matching but it is not implemented yet.

    Finally, to show custom labels and to customize the tooltip in general, you need to create a tooltip content adapter. Please take a look at this sample implementation and continue from there:

    public class CustomContentAdapter extends ChartTooltipContentAdapter {
        public CustomContentAdapter(Context context) {
            super(context);
        }
        @Override
        protected View getScatterContent(ScatterDataPoint scatterPoint) {
            View result = this.scatterContent();
            TextView textView = Util.getLayoutPart(result, com.telerik.widget.chart.R.id.xText, TextView.class);
            textView.setText("Custom X String: " + extractValue(scatterPoint.getXValue()));
            textView = Util.getLayoutPart(result, com.telerik.widget.chart.R.id.yText, TextView.class);
            textView.setText("Custom Y String: " + extractValue(scatterPoint.getYValue()));
            return result;
        }
    }

    And you use it like so:
    tooltipBehavior.setContentAdapter(new CustomContentAdapter(this));

    Write again if you need further assistance.

    Regards,
    Victor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Reghardt
    Reghardt avatar
    6 posts
    Member since:
    May 2015

    Posted 08 Oct 2015 Link to this post

    Thanks for the Help the above worked. 

    With the toolTip it doesn't work too well with the results towards the end of the graphs the tooltip pop out to blank space of the map so you wouldn't know which points you click on. 

    If I made sure all the X values are identical would this mean that the trackball will work? If this is true this will most likely be the easiest solution or does this not work at all on the Scatter Line Series?  

     

    Regards

  6. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 09 Oct 2015 Link to this post

    Hello Reghardt,

    Currently the trackball does not support the scatter series. It needs to be extended so that it has a value band instead of a single line. The line does not detect scatter points because if the points differ even by 0.00000001 the line will consider them unequal and will only display one point.

    At the moment the trackball will not display anything for the scatter series because they are not supported.
    We will try to add this functionality for the Q1 2016 release.

    Can you please explain in more detail the issue about the tooltip? A screenshot would be quite useful.

    Regards,
    Victor
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner