I have a legend that is populated dynamically during run time. Due to length restrictions I am truncating the legend length to 30 chars and then to have a tooltip which when mouse pointer is brought upon will give out the entire text of the legend.
this is my initChart method
Code: Select all
private void initTChart(String title, cop_TimePeriod timePeriod) {
d_tChart = new TChart();
d_tChart.setText(title);
// ThemesList.applyTheme(d_tChart.getChart(), 1);
d_tChart.getPanel().getGradient().setVisible(true);
d_tChart.getWalls().setVisible(true);
d_tChart.getAspect().setView3D(false);
d_tChart.getAxes().getBottom().getLabels().setDateTimeFormat("HH:mm");
d_tChart.getLegend().setCheckBoxes(true);
d_tChart.getAxes().getLeft().getTitle().setCaption("Cost");
d_tChart.getAxes().getBottom().getTitle().setCaption("Time");
d_tChart.getAxes().getBottom().setMinMax(timePeriod.getStart().getTime(), timePeriod.getEnd().getTime());
d_tChart.getAxes().getBottom().scroll(3, false);
d_tChart.getAspect().setView3D(false);
d_tChart.getAspect().setSmoothingMode(true);
d_tChart.getHeader().setVisible(true);
d_tChart.getHeader().getFont().setColor(com.steema.teechart.drawing.Color.NAVY);
// d_tChart.setText("FastLine: null points support");
d_tChart.getPanel().getGradient().setEndColor(com.steema.teechart.drawing.Color.fromArgb(254,21,60,89));
//chart1.getPanel().getGradient().setMiddleColor(Color.fromArgb(254,255,255,255));
d_tChart.getPanel().getGradient().setStartColor(com.steema.teechart.drawing.Color.fromArgb(254,255,255,255));
d_tChart.getPanel().getGradient().setUseMiddle(false);
d_tChart.getPanel().getGradient().setVisible(true);
d_tChart.getWalls().getBack().setTransparent(false);
d_tChart.getWalls().getBack().getGradient().setVisible(true);
d_tChart.getWalls().getBack().getGradient().setUseMiddle(false);
d_tChart.getWalls().getBack().getGradient().setStartColor(com.steema.teechart.drawing.Color.fromArgb(234, 234, 234));
d_tChart.getWalls().getBack().getGradient().setEndColor(com.steema.teechart.drawing.Color.WHITE);
editButton = new JButton("Edit...");
}
Code: Select all
markstip1 = new com.steema.teechart.tools.MarksTip(d_tChart.getChart());
d_tChart.addChartPaintListener(new ChartPaintListener() {
public void axesPainting(ChartDrawEvent arg0) {}
public void chartPainted(ChartDrawEvent arg0) {
markstip1.chart.getToolTip().setText(text);
}
public void chartPainting(ChartDrawEvent arg0) {}
public void seriesPainting(ChartDrawEvent arg0) {}
public void seriesPainted(ChartDrawEvent arg0) {}
});
d_tChart.addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {}
public void mouseMoved(MouseEvent e) {
int clickedIndex = d_tChart.getLegend().clicked(e.getX(),e.getY());
if (clickedIndex > -1)
{
text = d_tChart.getSeries(clickedIndex).titleOrName();
d_tChart.repaint();
}
}
});
d_tChart.getLegend().setAlignment(LegendAlignment.BOTTOM);
d_tChart.repaint();