Page 1 of 1
custom tooltip
Posted: Tue Nov 22, 2011 9:40 am
by 17060329
I'm using a line series graph with pointer.
How to create custom tooltip when i click on pointer ?
Thanks a lot for your answer.
Re: custom tooltip
Posted: Tue Nov 22, 2011 11:00 am
by 17060329
I also want to custom the display of label to add an icon to represent a level for each y value
Re: custom tooltip
Posted: Tue Nov 22, 2011 11:01 am
by narcis
Hi Mulderone,
You should use a MarksTip tool as in the Tools -> Mark Tips examples at TeeChart.Features.jar demo.
Hope this helps!
Re: custom tooltip
Posted: Tue Nov 22, 2011 12:25 pm
by 17060329
i look at the code and test it but it's not precise when you touch the screen.
It's possible to add a listener on the SeriePoint or get the nearest SeriePointer for an X,Y coordinate ?
I understand that the android version share the same code as Java library but using mouse on PC is most precise, which is not the case on Android device.
I just want to touch a single point on the line series and draw a custom toast nearest the point.
Is it possible or not ?
Re: custom tooltip
Posted: Tue Nov 22, 2011 12:40 pm
by narcis
Hi Mulderone,
Yes, you could use series' click event, its clicked method in chart mouse events or the NearestPoint tool.
Re: custom tooltip
Posted: Tue Nov 22, 2011 1:26 pm
by 17060329
Could you be more precise ?
the series accept only 2 listeners, i'm using the the serieMouseListener but i 'have a nullPointer exception when i touch the graph and i can't find the nearestPoint method
Could you help me ?
Code: Select all
final Series series = Series.createNewSeries(this.getChart(), Line.class,
null);
series.getXValues().setDateTime(true);
/**
* Configuration graphique des points de la série
*/
final SeriesPointer seriesPointer = ((CustomPoint) series).getPointer();
seriesPointer.setVisible(true);
seriesPointer.setVertSize(6);
seriesPointer.setHorizSize(6);
seriesPointer.setColor(series.getColor());
seriesPointer.getPen().setColor(Color.WHITE);
seriesPointer.getPen().setVisible(true);
seriesPointer.getPen().setWidth(3);
seriesPointer.setStyle(PointerStyle.CIRCLE);
/**
* Configuration graphique des tooltips de chaque point
*/
final MarksTip marksTip = new MarksTip(
this.getChart());
series.addSeriesMouseListener(new SeriesMouseAdapter() {
public void seriesClicked(SeriesMouseEvent e) {
marksTip.setMouseDelay(0);
marksTip.setSeries(series);
Toast t;
t = Toast.makeText(activity, marksTip.getSeries()
.getValueMarkText(e.getValueIndex()),
Toast.LENGTH_SHORT);
t.show();
};
});
the NullPointerException stackTrace
11-22 14:26:13.745: E/AndroidRuntime(2049): java.lang.NullPointerException
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.styles.Custom.checkPointInLine(Custom.java:425)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.styles.Custom.clicked(Custom.java:510)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.styles.Series.clicked(Series.java:3130)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.tools.MarksTip.mouseEvent(MarksTip.java:222)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.Chart.broadcastMouseEvent(Chart.java:938)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.Chart.broadcastMouseEvent(Chart.java:928)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.Chart.mouseMoved(Chart.java:1313)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.TChart.processMouseMotionEvent(TChart.java:971)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.steema.teechart.TChart.onTouch(TChart.java:1137)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.View.dispatchTouchEvent(View.java:3762)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1716)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1114)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1700)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1716)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1114)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1700)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.os.Looper.loop(Looper.java:123)
11-22 14:26:13.745: E/AndroidRuntime(2049): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-22 14:26:13.745: E/AndroidRuntime(2049): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 14:26:13.745: E/AndroidRuntime(2049): at java.lang.reflect.Method.invoke(Method.java:521)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 14:26:13.745: E/AndroidRuntime(2049): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 14:26:13.745: E/AndroidRuntime(2049): at dalvik.system.NativeStart.main(Native Method)
Re: custom tooltip
Posted: Thu Nov 24, 2011 3:03 pm
by yeray
Hello Mulderone,
I'm not getting the error you are with that code but I see the MarksTip has an strange response. It has to be revised.
In the meanwhile, the following code seems to work better, could you please give it a try?
Code: Select all
private static com.steema.teechart.tools.Annotation annot1;
com.steema.teechart.styles.Line lineSeries;
private void initializeChart() {
tChart1.getAspect().setView3D(false);
tChart1.getLegend().setVisible(false);
lineSeries = new com.steema.teechart.styles.Line(tChart1.getChart());
lineSeries.getPointer().setVisible(true);
lineSeries.fillSampleValues(10);
annot1 = new com.steema.teechart.tools.Annotation(tChart1.getChart());
annot1.setActive(false);
lineSeries.addSeriesMouseListener(new SeriesMouseListener() {
@Override
public void seriesExited(SeriesMouseEvent e) {}
@Override
public void seriesEntered(SeriesMouseEvent e) {}
@Override
public void seriesClicked(SeriesMouseEvent e) {
annot1.setActive(false);
for (int valueIndex=0; valueIndex<lineSeries.getCount(); valueIndex++) {
if (lineSeries.clickedPointer(lineSeries.calcXPos(valueIndex), lineSeries.calcYPos(valueIndex), e.getPoint().x, e.getPoint().y)) {
annot1.setText(String.valueOf(lineSeries.getYValues().getValue(valueIndex)));
annot1.getShape().setCustomPosition(true);
annot1.setLeft(e.getPoint().x);
annot1.setTop(e.getPoint().y - 20);
annot1.setActive(true);
}
}
}
});
Re: custom tooltip
Posted: Mon Nov 28, 2011 3:33 pm
by 17060329
thanks for your help.
I've found a solution : a SerieMouseListener and i'm using a Toast object with a custom inner view.
I don't pop-up the toast near the point but the look&feel is ok