zoukankan      html  css  js  c++  java
  • XCL-Charts绘画面积图(AreaChart) 例1

         样本区域地图,发现区域图的时候把做向上注视位置图更具优势的管理。在改变。 区域图网格和轴是不一样的处理与其它图,

    它是用来表示其影响范围的覆盖范围,车桥无段伸出。

    在这里下处理。



       代码:

    /**
     * Copyright 2014  XCL-Charts
     * 
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     * 
     *     http://www.apache.org/licenses/LICENSE-2.0
     * 
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     * 	
     * @Project XCL-Charts 
     * @Description Android图表基类库
     * @author XiongChuanLiang<br/>(xcl_168@aliyun.com)
     * @Copyright Copyright (c) 2014 XCL-Charts (www.xclcharts.com)
     * @license http://www.apache.org/licenses/  Apache v2 License
     * @version v0.1
     */
    package com.demo.xclcharts.view;
    
    import java.util.LinkedList;
    import java.util.List;
    
    import org.xclcharts.chart.AreaChart;
    import org.xclcharts.chart.AreaData;
    import org.xclcharts.renderer.XEnum;
    
    import android.content.Context;
    import android.graphics.Color;
    import android.util.Log;
    
    
    /**
     * @ClassName AreaChart01View
     * @Description  面积图样例
     * @author XiongChuanLiang<br/>(xcl_168@aliyun.com)
     */
    
    public class AreaChart01View extends GraphicalView {
    	
    	//标签集合
    	private LinkedList<String> mChartLabels = new LinkedList<String>();
    	//数据集合
    	private LinkedList<AreaData> mChartDataSet = new LinkedList<AreaData>();
    			
    
    	public AreaChart01View(Context context) {
    		super(context);
    		// TODO Auto-generated constructor stub
    				
    		chartLabels();
    		chartDataSet();
    		chartRender();
    	}
    	
    	
    	private void chartRender()
    	{
    		try{				
    				AreaChart chart = new AreaChart();
    				 
    				//柱形图所占范围大小
    				chart.setChartRange(0.0f, 0.0f,getScreenWidth(),getScreenHeight());
    				chart.setCanvas(this.mCacheCanvas);
    				chart.setPadding(15, 30, 10, 5);
    											
    				//轴数据源						
    				//标签轴
    				chart.setLabels(mChartLabels);
    				//数据轴
    				chart.setDataSource(mChartDataSet);
    							
    				//数据轴最大值
    				chart.getDataAxis().setAxisMax(100);
    				//数据轴刻度间隔
    				chart.getDataAxis().setAxisSteps(10);
    				
    				//背景网格
    				chart.getPlotGrid().setEvenRowsFillVisible(true);
    				chart.getPlotGrid().setOddRowsFillVisible(true);
    				
    				//标题
    				chart.setChartTitle("区域图(Area Chart)");
    				chart.setChartSubTitle("(XCL-Charts Demo)");	
    				//图例
    				chart.getLegend().setLowerLegend("(年份)");
    				
    				//透明度
    				//chart.setAreaAlpha(200);
    				//显示键值
    				chart.setPlotKeyVisible(true);
    			
    				//绘制
    				chart.render();
    		} catch (Exception e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    			Log.e("ERROR-AreaChart01View", e.toString());
    		}
    	}
    	
    	private void chartDataSet()
    	{
    		//将标签与相应的数据集分别绑定
    		//标签相应的数据集
    		List<Double> dataSeries1= new LinkedList<Double>();	
    		dataSeries1.add((double)55); 
    		dataSeries1.add((double)60); 
    		dataSeries1.add((double)71); 
    		dataSeries1.add((double)40);
    		dataSeries1.add((double)35);
    		
    		List<Double> dataSeries2 = new LinkedList<Double>();			
    		dataSeries2.add((double)10); 
    		dataSeries2.add((double)22); 
    		dataSeries2.add((double)30); 	
    		dataSeries2.add((double)30); 
    		dataSeries2.add((double)15); 
    		
    		//设置每条线各自的显示属性
    		//key,数据集,线颜色,区域颜色
    		AreaData line1 = new AreaData("小熊",dataSeries1,Color.BLUE,Color.YELLOW);
    		//不显示点
    		line1.setDotStyle(XEnum.DotStyle.HIDE);
    		
    		AreaData line2 = new AreaData("小小熊",dataSeries2,
    											(int)Color.rgb(79, 200, 100),Color.GREEN);
    		//设置线上每点相应标签的颜色
    		line2.getPlotLabelsPaint().setColor(Color.RED);
    		//设置点标签
    		line2.setLineLabelVisible(true);
    		
    		mChartDataSet.add(line1);
    		mChartDataSet.add(line2);	
    	}
    	
    	private void chartLabels()
    	{		
    		mChartLabels.add("2010");
    		mChartLabels.add("2011");
    		mChartLabels.add("2012");
    		mChartLabels.add("2013");
    		mChartLabels.add("2014");
    	}
    	
    }
    



    MAIL:  xcl_168@aliyun.com

    BLOG: http://blog.csdn.net/xcl168



    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    GCD 使用说明
    iOS操作系统的层次结构
    Objective-C 类型转换
    UIView和Masonry实现动画效果
    iOS 常用手势
    SDUT 2610 Boring Counting(离散化+主席树区间内的区间求和)
    HDU 4417 Super Mario(主席树求区间内的区间查询+离散化)
    NBUT 1525 Cow Xor(01字典树+前缀思想)
    HDU 4825 Xor Sum(经典01字典树+贪心)
    HDU 1069 Monkey and Banana(二维偏序LIS的应用)
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4629160.html
Copyright © 2011-2022 走看看