Page 1 of 1

Setting chart colors using script

Posted: Wed Sep 05, 2007 1:08 am
by 7665556
Is it possible to set font colors on the applet via javascript?

e.g. For the header
tChart1.getChart().getHeader().setColor ?

Posted: Wed Sep 05, 2007 8:34 am
by narcis
Hi shoey,

Yes, you can try this:

Code: Select all

                tChart.getHeader().getFont().setColor(Color.BLUE);
                tChart.getHeader().setTransparent(false);
                tChart.getHeader().setColor(Color.RED);

Posted: Thu Sep 06, 2007 12:50 am
by 7665556
Hi Narcis,

Does the applet have a function to create a color? If I try to run this from a web page I can not use Color.Red. I would first need a function to create the color. Something like this perhaps:

tChart.getHeader().setColor( tChart1.createColor(255, 0, 0));

Thanks

Posted: Sun Sep 09, 2007 9:22 pm
by Tom
Sorry, I think we misunderstand your questions, how would you like to use our component with JavaScript? Can you provide us an example of an html page which shows us the functionality you need?

In an applet you would use something like this:

Code: Select all

import com.steema.teechart.TChart;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class TChartApplet extends JApplet {
    
    TChart chart;
    JButton colorButton;
    
    public void init() {        
        Container content = getContentPane();
        content.setBackground(Color.white);
        content.setLayout(new BorderLayout());         
        chart = new TChart();
        content.add(chart, BorderLayout.CENTER);        
        colorButton = new JButton("Color");
        colorButton.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                chart.setBackColor(Color.RED);
                //or chart.setBackColor(new Color(255,0,0));
            }
        });
        content.add(colorButton, BorderLayout.NORTH);
    }
}
But from your questions on the forum, I'm guessing this is not the kind of information you need.

Regards,
tom