Search in sources :

Example 1 with PlotGrid

use of org.xclcharts.renderer.plot.PlotGrid in project XCL-Charts by xcltapestry.

the class MultiAxisChart03View method chartRender.

private void chartRender() {
    try {
        //设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....		
        int[] ltrb = getBarLnDefaultSpadding();
        //chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
        //left 40	
        float left = DensityUtil.dip2px(getContext(), 40);
        //right	20			
        float right = DensityUtil.dip2px(getContext(), 40);
        //ltrb[2]
        chart.setPadding(left, ltrb[1], right, ltrb[3]);
        //轴数据源						
        //标签轴
        chart.setCategories(mLabels);
        //数据轴
        chart.setDataSource(mDataset);
        //仅横向平移
        chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
        //数据轴最大值
        chart.getDataAxis().setAxisMax(300);
        chart.getDataAxis().setAxisMin(0);
        //数据轴刻度间隔
        chart.getDataAxis().setAxisSteps(50);
        //网格
        chart.getPlotGrid().showHorizontalLines();
        chart.getPlotGrid().showVerticalLines();
        //把轴线和刻度线给隐藏起来
        //chart.getDataAxis().hideAxisLine();
        chart.getDataAxis().hideTickMarks();
        //	chart.getCategoryAxis().hideAxisLine();
        chart.getCategoryAxis().hideTickMarks();
        chart.getDataAxis().setTickLabelRotateAngle(-90);
        chart.getDataAxis().getTickLabelPaint().setColor(Color.RED);
        chart.getCategoryAxis().getTickLabelPaint().setColor(Color.RED);
        //标题
        chart.setTitle("混合图(区域、折线、饼图)");
        chart.addSubtitle("(XCL-Charts Demo)");
        //轴标题
        //chart.getAxisTitle().setLowerAxisTitle("(时间点)");
        //透明度
        chart.setAreaAlpha(200);
        //显示图例
        chart.getPlotLegend().hide();
        //把轴线设成和横向网络线一样和大小和颜色,演示下定制性,这块问得人较多
        PlotGrid plot = chart.getPlotGrid();
        chart.getDataAxis().getAxisPaint().setStrokeWidth(plot.getHorizontalLinePaint().getStrokeWidth());
        chart.getCategoryAxis().getAxisPaint().setStrokeWidth(plot.getHorizontalLinePaint().getStrokeWidth());
        chart.getDataAxis().getAxisPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chart.getCategoryAxis().getAxisPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chart.getDataAxis().getTickMarksPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chart.getCategoryAxis().getTickMarksPaint().setColor(plot.getHorizontalLinePaint().getColor());
        plot.hideHorizontalLines();
        //激活点击监听
        chart.ActiveListenItemClick();
        //为了让触发更灵敏,可以扩大5px的点击监听范围
        chart.extPointClickRange(10);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.e(TAG, e.toString());
    }
}
Also used : PlotGrid(org.xclcharts.renderer.plot.PlotGrid)

Example 2 with PlotGrid

use of org.xclcharts.renderer.plot.PlotGrid in project XCL-Charts by xcltapestry.

the class MultiAxisChart03View method chartRenderLn.

private void chartRenderLn() {
    try {
        //设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....		
        int[] ltrb = getBarLnDefaultSpadding();
        //left 40	
        float left = DensityUtil.dip2px(getContext(), 40);
        //right	20			
        float right = DensityUtil.dip2px(getContext(), 40);
        //ltrb[2]
        chartLn.setPadding(left, ltrb[1], right, ltrb[3]);
        //设定数据源
        chartLn.setCategories(mLabels);
        chartLn.setDataSource(chartData);
        //数据轴最大值
        chartLn.getDataAxis().setAxisMax(70);
        //数据轴刻度间隔
        chartLn.getDataAxis().setAxisSteps(10);
        //仅横向平移
        chartLn.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
        //背景网格
        chartLn.getPlotGrid().hideEvenRowBgColor();
        chartLn.getPlotGrid().hideHorizontalLines();
        chartLn.getPlotGrid().hideOddRowBgColor();
        chartLn.getPlotGrid().hideVerticalLines();
        //chartLn.getPlotGrid().showHorizontalLines();
        //chartLn.getDataAxis().hideAxisLine();
        chartLn.getDataAxis().hideTickMarks();
        //chartLn.getCategoryAxis().hideAxisLine();
        chartLn.getCategoryAxis().hideTickMarks();
        chartLn.getDataAxis().setTickLabelRotateAngle(-90);
        chartLn.getDataAxis().getTickLabelPaint().setColor(Color.rgb(106, 218, 92));
        chartLn.getCategoryAxis().getTickLabelPaint().setColor(Color.rgb(106, 218, 92));
        chartLn.getDataAxis().setHorizontalTickAlign(Align.RIGHT);
        chartLn.getDataAxis().getTickLabelPaint().setTextAlign(Align.LEFT);
        //调整轴显示位置
        chartLn.setDataAxisLocation(XEnum.AxisLocation.RIGHT);
        chartLn.setCategoryAxisLocation(XEnum.AxisLocation.TOP);
        //把轴线设成和横向网络线一样和大小和颜色,演示下定制性,这块问得人较多
        PlotGrid plot = chart.getPlotGrid();
        chartLn.getDataAxis().getAxisPaint().setStrokeWidth(plot.getHorizontalLinePaint().getStrokeWidth());
        chartLn.getCategoryAxis().getAxisPaint().setStrokeWidth(plot.getHorizontalLinePaint().getStrokeWidth());
        chartLn.getDataAxis().getAxisPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chartLn.getCategoryAxis().getAxisPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chartLn.getDataAxis().getTickMarksPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chartLn.getCategoryAxis().getTickMarksPaint().setColor(plot.getHorizontalLinePaint().getColor());
        //图例显示在正下方
        chartLn.getPlotLegend().setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
        chartLn.getPlotLegend().setHorizontalAlign(XEnum.HorizontalAlign.CENTER);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        Log.e(TAG, e.toString());
    }
}
Also used : PlotGrid(org.xclcharts.renderer.plot.PlotGrid)

Example 3 with PlotGrid

use of org.xclcharts.renderer.plot.PlotGrid in project XCL-Charts by xcltapestry.

the class SplineChart05View method chartRender.

private void chartRender() {
    try {
        //设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....		
        int[] ltrb = getBarLnDefaultSpadding();
        chart.setPadding(ltrb[0] + DensityUtil.dip2px(this.getContext(), 20), ltrb[1], ltrb[2] + DensityUtil.dip2px(this.getContext(), 30), ltrb[3]);
        //标题
        chart.setTitle("一周状态");
        chart.addSubtitle("(XCL-Charts Demo)");
        chart.getPlotTitle().setVerticalAlign(XEnum.VerticalAlign.BOTTOM);
        chart.getPlotTitle().getTitlePaint().setColor(Color.WHITE);
        chart.getPlotTitle().getSubtitlePaint().setColor(Color.WHITE);
        //显示边框
        chart.showRoundBorder();
        //数据源	
        chart.setCategories(labels);
        chart.setDataSource(chartData);
        //	chart.setCustomLines(mCustomLineDataset);
        //坐标系
        //数据轴最大值
        chart.getDataAxis().setAxisMax(20);
        //chart.getDataAxis().setAxisMin(0);
        //数据轴刻度间隔
        chart.getDataAxis().setAxisSteps(5);
        //标签轴最大值
        chart.setCategoryAxisMax(5);
        //标签轴最小值
        chart.setCategoryAxisMin(0);
        //chart.setCategoryAxisCustomLines(mXCustomLineDataset); //x轴
        //chart.setCustomLines(mYCustomLineDataset); //y轴
        //背景网格
        PlotGrid plot = chart.getPlotGrid();
        plot.hideHorizontalLines();
        plot.hideVerticalLines();
        chart.getPlotArea().setBackgroundColor(true, Color.rgb(30, 179, 143));
        chart.getCategoryAxis().getAxisPaint().setColor(Color.WHITE);
        chart.getCategoryAxis().getAxisPaint().setTextSize(6);
        chart.getCategoryAxis().hideTickMarks();
        chart.getCategoryAxis().getTickLabelPaint().setColor(Color.WHITE);
        chart.getCategoryAxis().getTickLabelPaint().setFakeBoldText(true);
        chart.getCategoryAxis().setTickLabelMargin(20);
        chart.getCategoryAxis().getTickLabelPaint().setTextSize(25);
        //不使用精确计算,忽略Java计算误差,提高性能
        chart.disableHighPrecision();
        chart.disablePanMode();
        chart.hideBorder();
        chart.getPlotLegend().hide();
        chart.getDataAxis().hide();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.e(TAG, e.toString());
    }
}
Also used : PlotGrid(org.xclcharts.renderer.plot.PlotGrid)

Example 4 with PlotGrid

use of org.xclcharts.renderer.plot.PlotGrid in project XCL-Charts by xcltapestry.

the class SplineChart01View method chartRender.

private void chartRender() {
    try {
        //设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....		
        int[] ltrb = getBarLnDefaultSpadding();
        chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
        //平移时收缩下
        //float margin = DensityUtil.dip2px(getContext(), 20);
        //chart.setXTickMarksOffsetMargin(margin);
        //显示边框
        chart.showRoundBorder();
        //数据源	
        chart.setCategories(labels);
        chart.setDataSource(chartData);
        //坐标系
        //数据轴最大值
        chart.getDataAxis().setAxisMax(100);
        //chart.getDataAxis().setAxisMin(0);
        //数据轴刻度间隔
        chart.getDataAxis().setAxisSteps(10);
        //标签轴最大值
        chart.setCategoryAxisMax(10);
        //标签轴最小值
        chart.setCategoryAxisMin(0);
        //设置图的背景色
        //chart.setBackgroupColor(true,Color.BLACK);
        //设置绘图区的背景色
        //chart.getPlotArea().setBackgroupColor(true, Color.WHITE);
        //背景网格
        PlotGrid plot = chart.getPlotGrid();
        plot.showHorizontalLines();
        plot.showVerticalLines();
        plot.getHorizontalLinePaint().setStrokeWidth(3);
        plot.getHorizontalLinePaint().setColor(Color.rgb(127, 204, 204));
        plot.setHorizontalLineStyle(XEnum.LineStyle.DOT);
        //把轴线设成和横向网络线一样和大小和颜色,演示下定制性,这块问得人较多
        //chart.getDataAxis().getAxisPaint().setStrokeWidth(
        //		plot.getHorizontalLinePaint().getStrokeWidth());
        //chart.getCategoryAxis().getAxisPaint().setStrokeWidth(
        //		plot.getHorizontalLinePaint().getStrokeWidth());
        chart.getDataAxis().getAxisPaint().setColor(Color.rgb(127, 204, 204));
        chart.getCategoryAxis().getAxisPaint().setColor(Color.rgb(127, 204, 204));
        chart.getDataAxis().getTickMarksPaint().setColor(Color.rgb(127, 204, 204));
        chart.getCategoryAxis().getTickMarksPaint().setColor(Color.rgb(127, 204, 204));
        //居中
        chart.getDataAxis().setHorizontalTickAlign(Align.CENTER);
        chart.getDataAxis().getTickLabelPaint().setTextAlign(Align.CENTER);
        //居中显示轴 
        //plot.hideHorizontalLines();
        //plot.hideVerticalLines();	
        //chart.setDataAxisLocation(XEnum.AxisLocation.VERTICAL_CENTER);
        //chart.setCategoryAxisLocation(XEnum.AxisLocation.HORIZONTAL_CENTER);
        //定义交叉点标签显示格式,特别备注,因曲线图的特殊性,所以返回格式为:  x值,y值
        //请自行分析定制
        chart.setDotLabelFormatter(new IFormatterTextCallBack() {

            @Override
            public String textFormatter(String value) {
                // TODO Auto-generated method stub						
                String label = "(" + value + ")";
                return (label);
            }
        });
        //标题
        chart.setTitle("Spline Chart");
        chart.addSubtitle("(XCL-Charts Demo)");
        //激活点击监听
        chart.ActiveListenItemClick();
        //为了让触发更灵敏,可以扩大5px的点击监听范围
        chart.extPointClickRange(5);
        chart.showClikedFocus();
        //显示十字交叉线
        chart.showDyLine();
        chart.getDyLine().setDyLineStyle(XEnum.DyLineStyle.Vertical);
        //扩大实际绘制宽度
        //chart.getPlotArea().extWidth(500.f);
        //封闭轴
        chart.setAxesClosed(true);
        //将线显示为直线,而不是平滑的
        chart.setCrurveLineStyle(XEnum.CrurveLineStyle.BEELINE);
        //不使用精确计算,忽略Java计算误差,提高性能
        chart.disableHighPrecision();
        //仅能横向移动
        chart.setPlotPanMode(XEnum.PanMode.HORIZONTAL);
        //批注
        List<AnchorDataPoint> mAnchorSet = new ArrayList<AnchorDataPoint>();
        AnchorDataPoint an1 = new AnchorDataPoint(2, 0, XEnum.AnchorStyle.CAPROUNDRECT);
        an1.setAlpha(200);
        an1.setBgColor(Color.RED);
        an1.setAreaStyle(XEnum.DataAreaStyle.FILL);
        AnchorDataPoint an2 = new AnchorDataPoint(1, 1, XEnum.AnchorStyle.CIRCLE);
        an2.setBgColor(Color.GRAY);
        AnchorDataPoint an3 = new AnchorDataPoint(0, 2, XEnum.AnchorStyle.RECT);
        an3.setBgColor(Color.BLUE);
        mAnchorSet.add(an1);
        mAnchorSet.add(an2);
        mAnchorSet.add(an3);
        chart.setAnchorDataPoint(mAnchorSet);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.e(TAG, e.toString());
    }
}
Also used : IFormatterTextCallBack(org.xclcharts.common.IFormatterTextCallBack) ArrayList(java.util.ArrayList) PlotGrid(org.xclcharts.renderer.plot.PlotGrid) AnchorDataPoint(org.xclcharts.renderer.info.AnchorDataPoint)

Example 5 with PlotGrid

use of org.xclcharts.renderer.plot.PlotGrid in project XCL-Charts by xcltapestry.

the class SplineChart02View method chartRender.

private void chartRender() {
    try {
        //设置绘图区默认缩进px值,留置空间显示Axis,Axistitle....		
        int[] ltrb = getBarLnDefaultSpadding();
        chart.setPadding(ltrb[0], ltrb[1], ltrb[2], ltrb[3]);
        //显示边框
        chart.showRoundBorder();
        //数据源	
        chart.setCategories(labels);
        chart.setDataSource(chartData);
        //坐标系
        //数据轴最大值
        chart.getDataAxis().setAxisMax(1);
        chart.getDataAxis().setAxisMin(-1);
        //数据轴刻度间隔
        chart.getDataAxis().setAxisSteps(0.5f);
        //标签轴最大值
        chart.setCategoryAxisMax(360);
        //标签轴最小值
        chart.setCategoryAxisMin(0);
        //设置图的背景色
        //chart.setBackgroupColor(true,Color.BLACK);
        //设置绘图区的背景色
        //chart.getPlotArea().setBackgroupColor(true, Color.WHITE);
        //背景网格
        PlotGrid plot = chart.getPlotGrid();
        plot.showHorizontalLines();
        plot.showVerticalLines();
        plot.getHorizontalLinePaint().setStrokeWidth(3);
        plot.getHorizontalLinePaint().setColor(Color.rgb(127, 204, 204));
        plot.setHorizontalLineStyle(XEnum.LineStyle.DOT);
        //把轴线设成和横向网络线一样和大小和颜色,演示下定制性,这块问得人较多
        chart.getDataAxis().getAxisPaint().setStrokeWidth(plot.getHorizontalLinePaint().getStrokeWidth());
        chart.getCategoryAxis().getAxisPaint().setStrokeWidth(plot.getHorizontalLinePaint().getStrokeWidth());
        chart.getDataAxis().getAxisPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chart.getCategoryAxis().getAxisPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chart.getDataAxis().getTickMarksPaint().setColor(plot.getHorizontalLinePaint().getColor());
        chart.getCategoryAxis().getTickMarksPaint().setColor(plot.getHorizontalLinePaint().getColor());
        //定义交叉点标签显示格式,特别备注,因曲线图的特殊性,所以返回格式为:  x值,y值
        //请自行分析定制
        chart.setDotLabelFormatter(new IFormatterTextCallBack() {

            @Override
            public String textFormatter(String value) {
                // TODO Auto-generated method stub						
                String label = "(" + value + ")";
                return (label);
            }
        });
        //标题
        chart.setTitle("三角函数曲线图");
        chart.addSubtitle("(XCL-Charts Demo)");
        //激活点击监听
        //chart.ActiveListenItemClick();
        //为了让触发更灵敏,可以扩大5px的点击监听范围
        //chart.extPointClickRange(5);
        //chart.showClikedFocus();
        //不使用精确误差计算,速度提升明显
        chart.disableHighPrecision();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Log.e(TAG, e.toString());
    }
}
Also used : IFormatterTextCallBack(org.xclcharts.common.IFormatterTextCallBack) PlotGrid(org.xclcharts.renderer.plot.PlotGrid)

Aggregations

PlotGrid (org.xclcharts.renderer.plot.PlotGrid)6 IFormatterTextCallBack (org.xclcharts.common.IFormatterTextCallBack)3 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)1