This is a migrated thread and some comments may be shown as answers.

Is there a way to clear a chart area?

4 Answers 240 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Reghardt
Top achievements
Rank 1
Reghardt asked on 11 Sep 2015, 12:21 PM

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. 

4 Answers, 1 is accepted

Sort by
0
Reghardt
Top achievements
Rank 1
answered on 14 Sep 2015, 03:54 PM
Ive attached the files as these didn't upload last time. 
0
Accepted
Victor
Telerik team
answered on 16 Sep 2015, 11:18 AM
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
0
Reghardt
Top achievements
Rank 1
answered on 08 Oct 2015, 12:23 PM

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

0
Victor
Telerik team
answered on 09 Oct 2015, 10:42 AM
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
Tags
Chart
Asked by
Reghardt
Top achievements
Rank 1
Answers by
Reghardt
Top achievements
Rank 1
Victor
Telerik team
Share this question
or