OpenFlashChart的使用(一)

1、AbstractChart

public abstract class AbstractChart {
	public static String[] colors = {"#d01f3c", "#356aa0", "#C79810", "#006400", "#7CFC00", "#1E90FF", "#A0522D", "#FFA500", "#00CED1", "#00FF7F", "#4B0082", "#2F4F4F", "#00FF00", "#FFD700", "#FF8C00"};

	protected Graph g = new Graph();
	private String title; //标题
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String render(){
		g.title(title, "{font-size:20px;}");
		g.set_bg_colour("#F0F8FF");
		
		setProperty();
		
		return g.render();
	}
	
	protected abstract void setProperty();
	
}

 

2、LineChart

public class LineChart extends AbstractChart{
	private String xLegend; //x轴图例
	private int yMax; //y轴最大值
	private int yLabelSteps; //y轴标签个数
	
	public String getXLegend() {
		return xLegend;
	}

	public void setXLegend(String legend) {
		xLegend = legend;
	}

	public int getYMax() {
		return yMax;
	}

	public void setYMax(int max) {
		yMax = max;
	}

	public int getYLabelSteps() {
		return yLabelSteps;
	}

	public void setYLabelSteps(int labelSteps) {
		yLabelSteps = labelSteps;
	}

	public void set_data(List<String> datas){
		g.set_data(datas);
	}
	
	public void set_links(List<String> datas){
		g.set_links(datas);
	}
	
	public void line(int width, String colour, String text, int size, int circles){
		g.line(width, colour, text, size, circles);
	}
	
	public void line_hollow(String width, String dot_size, String colour, String text, String font_size){
		g.line_hollow(width, dot_size, colour, text, font_size);
	}
	
	public void set_x_labels(List<String> datas){
		g.set_x_labels(datas);
	}

	@Override
	protected void setProperty() {
		g.set_x_label_style("12", "#000000", 0, 1, "");
		if(xLegend!=null) g.set_x_legend(xLegend, 12, "#000000");
		
		g.set_y_max(yMax);
		g.y_label_steps(yLabelSteps);
	}
	
}
 

3、PieChart

public class PieChart extends AbstractChart{
	private String toolTip; //提示标签
	
	public String getToolTip() {
		return toolTip;
	}

	public void setToolTip(String toolTip) {
		this.toolTip = toolTip;
	}

	public void pie_values(List<String> values, List<String> labels, List<String> links){
		g.pie_values(values, labels, links);
		
		//颜色
		int len = (values.size() <= colors.length) ? values.size() : colors.length;
		List<String> colours = new ArrayList<String>();
		for(int i=0;i<len;i++){
			colours.add(colors[i]);
		}
		g.pie_slice_colours(colours); 
	}
	
	@Override
	protected void setProperty() {
		g.set_tool_tip(toolTip);
		g.pie(40, "#505050", "{font-size: 12px; color: #404040;}");
	}
	
}

 

4、BarChart

public class BarChart extends AbstractChart{
	private int yMax; //y轴最大值
	private int yLabelSteps; //y轴标签个数
	
	public int getYMax() {
		return yMax;
	}

	public void setYMax(int max) {
		yMax = max;
	}

	public int getYLabelSteps() {
		return yLabelSteps;
	}

	public void setYLabelSteps(int labelSteps) {
		yLabelSteps = labelSteps;
	}

	public void set_data(List<String> datas){
		g.set_data(datas);
	}
	
	public void set_links(List<String> datas){
		g.set_links(datas);
	}
	
	public void addBar(Data_set bar){
		g.getData_sets().add(bar);
		g.bar("0");
	}
	
	public void set_x_labels(List<String> datas){
		g.set_x_labels(datas);
	}

	@Override
	protected void setProperty() {
		g.set_x_label_style("12", "#000000", 0, 2, "");
		g.set_x_tick_size(3);
		
		g.set_y_max(yMax);
		g.y_label_steps(yLabelSteps);
	}
	
}

 

5、Bar3DChart

public class Bar3DChart extends AbstractChart{
	private int yMax; //y轴最大值
	private int yLabelSteps; //y轴标签个数

	public int getYMax() {
		return yMax;
	}

	public void setYMax(int max) {
		yMax = max;
	}

	public int getYLabelSteps() {
		return yLabelSteps;
	}

	public void setYLabelSteps(int labelSteps) {
		yLabelSteps = labelSteps;
	}

	public void set_data(List<String> datas){
		g.set_data(datas);
	}
	
	public void set_links(List<String> datas){
		g.set_links(datas);
	}
	
	public void addBar(Data_set bar){
		g.getData_sets().add(bar);
		g.bar_3D("50", "#D54C78", "", 8);
	}
	
	public void set_x_labels(List<String> datas){
		g.set_x_labels(datas);
	}

	@Override
	protected void setProperty() {
		g.set_x_label_style("12", "#000000", 0, 2, "");
		g.x_axis_colour("#909090", "#ADB5C7");
		g.set_x_axis_3d(3);
		
		g.set_y_max(yMax);
		g.y_label_steps(yLabelSteps);
	}
	
}

 

OpenFlashChart的使用(一)

 

OpenFlashChart的使用(一)

 

OpenFlashChart的使用(一)

 

OpenFlashChart的使用(一)

 

 

你可能感兴趣的:(Flash)