当前位置: 首页>>代码示例>>Java>>正文


Java XAxis.setAvoidFirstLastClipping方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.components.XAxis.setAvoidFirstLastClipping方法的典型用法代码示例。如果您正苦于以下问题:Java XAxis.setAvoidFirstLastClipping方法的具体用法?Java XAxis.setAvoidFirstLastClipping怎么用?Java XAxis.setAvoidFirstLastClipping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.components.XAxis的用法示例。


在下文中一共展示了XAxis.setAvoidFirstLastClipping方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setXAxis

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * xAxis config details: https://github.com/PhilJay/MPAndroidChart/wiki/XAxis
 */
@ReactProp(name = "xAxis")
public void setXAxis(Chart chart, ReadableMap propMap) {
    XAxis axis = chart.getXAxis();

    setCommonAxisConfig(chart, axis, propMap);

    if (BridgeUtils.validate(propMap, ReadableType.Number, "labelsToSkip")) {
        axis.setLabelsToSkip(propMap.getInt("labelsToSkip"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Boolean, "avoidFirstLastClipping")) {
        axis.setAvoidFirstLastClipping(propMap.getBoolean("avoidFirstLastClipping"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceBetweenLabels")) {
        axis.setSpaceBetweenLabels(propMap.getInt("spaceBetweenLabels"));
    }
    if (BridgeUtils.validate(propMap, ReadableType.String, "position")) {
        axis.setPosition(XAxisPosition.valueOf(propMap.getString("position")));
    }
}
 
开发者ID:mskec,项目名称:react-native-mp-android-chart,代码行数:23,代码来源:ChartBaseManager.java

示例2: onCreate

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_draw_chart);

    mChart = (LineChart) findViewById(R.id.chart1);

    // listener for selecting and drawing
    mChart.setOnChartValueSelectedListener(this);
    mChart.setOnDrawListener(this);

    // if disabled, drawn datasets with the finger will not be automatically
    // finished
    // mChart.setAutoFinish(true);
    mChart.setDrawGridBackground(false);

    // add dummy-data to the chart
    initWithDummyData();

    Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(tf);
    xl.setAvoidFirstLastClipping(true);

    YAxis yl = mChart.getAxisLeft();
    yl.setTypeface(tf);

    mChart.getLegend().setEnabled(false);

    // mChart.setYRange(-40f, 40f, true);
    // call this to reset the changed y-range
    // mChart.resetYRange(true);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:DrawChartActivity.java

示例3: setXAxis

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setXAxis(int epochs) {
    final XAxis axis = mChart.getXAxis();
    axis.setEnabled(true);
    axis.setAxisMinimum(1F);
    axis.setAxisMaximum(epochs);
    axis.setPosition(XAxis.XAxisPosition.BOTTOM);
    axis.setDrawAxisLine(true);
    axis.setDrawGridLines(false);
    axis.setGranularity(1F);
    axis.setAvoidFirstLastClipping(true);

    mChart.getAxisRight().setDrawAxisLine(true);
}
 
开发者ID:huazhouwang,项目名称:Synapse,代码行数:14,代码来源:ModelDetailActivity.java

示例4: setData

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * By calling setData initializes the rest of the view
 * @param data the chart data
 */
@Override
public void setData(LineData data) {
    super.setData(data);
    setOnChartValueSelectedListener(this);
    setDescription("");
    setNoDataTextDescription("No chart data");
    setTouchEnabled(true);
    setScaleEnabled(true);
    setDragEnabled(true);
    setDrawGridBackground(true);
    setPinchZoom(true);

    Legend legend = getLegend();
    legend.setForm(Legend.LegendForm.CIRCLE);
    legend.setWordWrapEnabled(true);

    XAxis xAxis = getXAxis();
    xAxis.setAvoidFirstLastClipping(true);
    xAxis.setPosition(XAxis.XAxisPosition.TOP);

    YAxis yAxisLeft = getAxisLeft();
    yAxisLeft.setAxisMinValue(0);

    YAxis yAxisRight = getAxisRight();
    yAxisRight.setEnabled(false);
}
 
开发者ID:nairbspace,项目名称:octoandroid,代码行数:31,代码来源:TempChart.java

示例5: onCreate

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_realtime_linechart);

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);

    // enable description text
    mChart.getDescription().setEnabled(true);

    // enable touch gestures
    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setDrawGridBackground(false);

    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);

    // set an alternative background color
    mChart.setBackgroundColor(Color.LTGRAY);

    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mChart.setData(data);

    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();

    // modify the legend ...
    l.setForm(LegendForm.LINE);
    l.setTypeface(mTfLight);
    l.setTextColor(Color.WHITE);

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(mTfLight);
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(true);
    xl.setEnabled(true);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTfLight);
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setAxisMaximum(100f);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setDrawGridLines(true);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:60,代码来源:RealtimeLineChartActivity.java

示例6: onCreate

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_linechart);

    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);

    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);

    mSeekBarX.setProgress(45);
    mSeekBarY.setProgress(100);

    mSeekBarY.setOnSeekBarChangeListener(this);
    mSeekBarX.setOnSeekBarChangeListener(this);

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    
    // no description text
    mChart.getDescription().setEnabled(false);

    // enable touch gestures
    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);

    // set an alternative background color
    // mChart.setBackgroundColor(Color.GRAY);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
    mv.setChartView(mChart); // For bounds control
    mChart.setMarker(mv); // Set the marker to the chart
    
    XAxis xl = mChart.getXAxis();
    xl.setAvoidFirstLastClipping(true);
    xl.setAxisMinimum(0f);
    
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setInverted(true);
    leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
    
    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);

    // add data
    setData(25, 50);

    // // restrain the maximum scale-out factor
    // mChart.setScaleMinima(3f, 3f);
    //
    // // center the view to a specific position inside the chart
    // mChart.centerViewPort(10, 50);

    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();

    // modify the legend ...
    l.setForm(LegendForm.LINE);

    // dont forget to refresh the drawing
    mChart.invalidate();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:75,代码来源:InvertedLineChartActivity.java

示例7: onCreateView

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_voice_db_record_db, container, false);

    mDBTextView = (TextView) view.findViewById(R.id.record_db_fragment_db_tv);

    mDurationTimeView = (TextView) view.findViewById(R.id.record_db_fragment_duration_tv);

    mAverageTextView = (TextView) view.findViewById(R.id.record_db_fragment_average_tv);

    mMaxTextView = (TextView) view.findViewById(R.id.record_db_fragment_max_tv);

    mBtn = (Button) view.findViewById(R.id.record_db_fragment_switch_btn);
    mBtn.setOnClickListener(this);

    mLineChart = (LineChart) view.findViewById(R.id.record_db_fragment_info_lc);
    mLineChart.setOnChartValueSelectedListener(this);
    // 设置表描述为不可见
    mLineChart.getDescription().setEnabled(false);
    // 设置表描述可见,颜色值以及显示的文本
    // mLineChart.getDescription().setEnabled(true);
    // mLineChart.getDescription().setText(getString(R.string.db));
    // mLineChart.getDescription().setTextColor(Color.WHITE);
    // enable touch gestures
    mLineChart.setTouchEnabled(true);
    // enable scaling and dragging
    mLineChart.setDragEnabled(true);
    mLineChart.setScaleEnabled(true);
    mLineChart.setDrawGridBackground(false);
    // if disabled, scaling can be done on x- and y-axis separately
    mLineChart.setPinchZoom(true);
    // set an alternative background color
    mLineChart.setBackgroundColor(Color.parseColor("#6A1B9A") );
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mLineChart.setData(data);

    // get the legend (only possible after setting data)
    Legend l = mLineChart.getLegend();

    // modify the legend ...
    l.setForm(Legend.LegendForm.LINE);
    //l.setTypeface(mTfLight);
    l.setTextColor(Color.WHITE);

    // 获得图表的x轴
    XAxis xAxis = mLineChart.getXAxis();
    // 设置x轴的文本颜色为白色
    xAxis.setTextColor(Color.WHITE);
    // 不设置纵向的网格线,即与x轴垂直的线
    xAxis.setDrawGridLines(false);
    // 避免图表剪辑的边缘是屏幕
    xAxis.setAvoidFirstLastClipping(true);
    // 设置x轴可见
    xAxis.setEnabled(true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis leftYAxis = mLineChart.getAxisLeft();
    leftYAxis.setTextColor(Color.WHITE);
    leftYAxis.setAxisMaximum(100f);
    leftYAxis.setAxisMinimum(0f);
    leftYAxis.setDrawGridLines(true);
    // 获取右y轴并将其设置为可见
    YAxis rightYAxis  = mLineChart.getAxisRight();
    rightYAxis.setEnabled(true);
    rightYAxis.setDrawGridLines(false);
    // 设置与背景颜色相同使文本不可见
    rightYAxis.setTextColor(Color.parseColor("#6A1B9A"));

    addEntry(UserInfo.getInt(getContext(),"AverageDb"));
    return view;
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:76,代码来源:RecordDBFragment.java

示例8: onCreateView

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_store_db_record, container, false);
    mDBTextView = (TextView) view.findViewById(R.id.store_record_db_fragment_db_tv);

    mDurationTimeView = (TextView) view.findViewById(R.id.store_record_db_fragment_duration_tv);

    mAverageTextView = (TextView) view.findViewById(R.id.store_record_db_fragment_average_tv);

    mMaxTextView = (TextView) view.findViewById(R.id.store_record_db_fragment_max_tv);

    mBtn = (Button) view.findViewById(R.id.store_record_db_fragment_switch_btn);
    mBtn.setOnClickListener(this);

    mLineChart = (LineChart) view.findViewById(R.id.store_record_db_fragment_info_lc);
    mLineChart.setOnChartValueSelectedListener(this);
    // 设置表描述为不可见
    mLineChart.getDescription().setEnabled(false);
    // 设置表描述可见,颜色值以及显示的文本
    // mLineChart.getDescription().setEnabled(true);
    // mLineChart.getDescription().setText(getString(R.string.db));
    // mLineChart.getDescription().setTextColor(Color.WHITE);
    // enable touch gestures
    mLineChart.setTouchEnabled(true);
    // enable scaling and dragging
    mLineChart.setDragEnabled(true);
    mLineChart.setScaleEnabled(true);
    mLineChart.setDrawGridBackground(false);
    // if disabled, scaling can be done on x- and y-axis separately
    mLineChart.setPinchZoom(true);
    // set an alternative background color
    mLineChart.setBackgroundColor(Color.parseColor("#6A1B9A"));
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mLineChart.setData(data);

    // get the legend (only possible after setting data)
    Legend l = mLineChart.getLegend();

    // modify the legend ...
    l.setForm(Legend.LegendForm.LINE);
    //l.setTypeface(mTfLight);
    l.setTextColor(Color.WHITE);

    // 获得图表的x轴
    XAxis xAxis = mLineChart.getXAxis();
    // 设置x轴的文本颜色为白色
    xAxis.setTextColor(Color.WHITE);
    // 不设置纵向的网格线,即与x轴垂直的线
    xAxis.setDrawGridLines(false);
    // 避免图表剪辑的边缘是屏幕
    xAxis.setAvoidFirstLastClipping(true);
    // 设置x轴可见
    xAxis.setEnabled(true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis leftYAxis = mLineChart.getAxisLeft();
    leftYAxis.setTextColor(Color.WHITE);
    leftYAxis.setAxisMaximum(100f);
    leftYAxis.setAxisMinimum(0f);
    leftYAxis.setDrawGridLines(true);
    // 获取右y轴并将其设置为可见
    YAxis rightYAxis = mLineChart.getAxisRight();
    rightYAxis.setEnabled(true);
    rightYAxis.setDrawGridLines(false);
    // 设置与背景颜色相同使文本不可见
    rightYAxis.setTextColor(Color.parseColor("#6A1B9A"));

    addEntry(UserInfo.getInt(getContext(), "AverageDb"));
    return view;
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:75,代码来源:StoreDbRecordFragment.java

示例9: initChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
     * 初始化报表
     *
     * @param showAnimation 是否显示动画
     */
    void initChart(boolean showAnimation) {

        int screenWidth = Utils.getScreenWidth(mContext);
        combinedChart.getLayoutParams().height = screenWidth * 300 / 640;

        //启用缩放和拖动
        combinedChart.setDragEnabled(true);//拖动
        combinedChart.setScaleEnabled(false);//缩放
        combinedChart.setOnChartValueSelectedListener(this);
        combinedChart.getDescription().setEnabled(false);
        combinedChart.setBackgroundColor(ContextCompat.getColor(mContext, R.color.co10));
        combinedChart.setDrawGridBackground(false);
        combinedChart.setDrawBarShadow(false);
        combinedChart.setHighlightFullBarEnabled(false);

        Legend l = combinedChart.getLegend();
        l.setForm(Legend.LegendForm.NONE);//底部样式
        l.setTextColor(ContextCompat.getColor(mContext, R.color.transparent));
        l.setWordWrapEnabled(false);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        l.setDrawInside(false);

        YAxis rightAxis = combinedChart.getAxisRight();
        rightAxis.setEnabled(false);

        YAxis leftAxis = combinedChart.getAxisLeft();
        leftAxis.setDrawGridLines(false);
        leftAxis.setGranularityEnabled(false);
        leftAxis.setDrawAxisLine(false);
        leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
        leftAxis.setTextColor(ContextCompat.getColor(mContext, R.color.co4));

        updateTitle(items.get(dateSelected));
        XAxis xAxis = combinedChart.getXAxis();
        xAxis.setTypeface(mTfLight);
        xAxis.setEnabled(true);//设置轴启用或禁用 如果禁用以下的设置全部不生效
        xAxis.setDrawAxisLine(true);//是否绘制轴线
        xAxis.setDrawGridLines(false);//设置x轴上每个点对应的线
        xAxis.setDrawLabels(true);//绘制标签  指x轴上的对应数值
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//设置x轴的显示位置
        xAxis.setTextSize(10f); //设置X轴文字大小
        xAxis.setGranularityEnabled(true);//是否允许X轴上值重复出现
        xAxis.setTextColor(ContextCompat.getColor(this, R.color.co4));//设置X轴文字颜色
//        //设置竖线的显示样式为虚线
//        //lineLength控制虚线段的长度
//        //spaceLength控制线之间的空间
        xAxis.enableGridDashedLine(10f, 10f, 0f);
        xAxis.setAxisMinimum(0f);//设置x轴的最小值
        xAxis.setAxisMaximum(mDatas.length);//设置最大值
        xAxis.setAvoidFirstLastClipping(true);//图表将避免第一个和最后一个标签条目被减掉在图表或屏幕的边缘
        xAxis.setLabelRotationAngle(0f);//设置x轴标签字体的旋转角度
//        设置x轴显示标签数量  还有一个重载方法第二个参数为布尔值强制设置数量 如果启用会导致绘制点出现偏差
        xAxis.setLabelCount(10);
        xAxis.setGridLineWidth(10f);//设置竖线大小
//        xAxis.setGridColor(Color.RED);//设置竖线颜色
        xAxis.setAxisLineColor(Color.GRAY);//设置x轴线颜色
        xAxis.setAxisLineWidth(1f);//设置x轴线宽度

        CombinedData combinedData = new CombinedData();
        combinedData.setData(generateLineData());
        combinedData.setData(generateBarData());
        combinedData.setValueTypeface(mTfLight);
        xAxis.setAxisMaximum(combinedData.getXMax() + 0.25f);
        //X轴的数据格式
        ValueFormatter xAxisFormatter = new ValueFormatter(combinedChart);
        xAxisFormatter.setmValues(xAxisValue);
        xAxis.setValueFormatter(xAxisFormatter);//格式化x轴标签显示字符
        combinedChart.setData(combinedData);
        combinedChart.invalidate();
        if (showAnimation) {
            combinedChart.animateY(2000);
        }
    }
 
开发者ID:jay16,项目名称:shengyiplus-android,代码行数:81,代码来源:HomeTricsActivity.java

示例10: onCreate

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_realtime_linechart);

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);

    // no description text
    mChart.setDescription("");
    mChart.setNoDataTextDescription("You need to provide data for the chart.");

    // enable touch gestures
    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setDrawGridBackground(false);

    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);

    // set an alternative background color
    mChart.setBackgroundColor(Color.LTGRAY);

    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);

    // add empty data
    mChart.setData(data);

    Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();

    // modify the legend ...
    // l.setPosition(LegendPosition.LEFT_OF_CHART);
    l.setForm(LegendForm.LINE);
    l.setTypeface(tf);
    l.setTextColor(Color.WHITE);

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(tf);
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(true);
    xl.setSpaceBetweenLabels(5);
    xl.setEnabled(true);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(tf);
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setAxisMaxValue(100f);
    leftAxis.setAxisMinValue(0f);
    leftAxis.setDrawGridLines(true);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);

}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:65,代码来源:RealtimeLineChartActivity.java

示例11: onCreate

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_linechart);

    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);

    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);

    mSeekBarX.setProgress(45);
    mSeekBarY.setProgress(100);

    mSeekBarY.setOnSeekBarChangeListener(this);
    mSeekBarX.setOnSeekBarChangeListener(this);

    mChart = (LineChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawGridBackground(false);
    
    // no description text
    mChart.setDescription("");

    // enable touch gestures
    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    // if disabled, scaling can be done on x- and y-axis separately
    mChart.setPinchZoom(true);

    // set an alternative background color
    // mChart.setBackgroundColor(Color.GRAY);

    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);

    // set the marker to the chart
    mChart.setMarkerView(mv);
    
    XAxis xl = mChart.getXAxis();
    xl.setAvoidFirstLastClipping(true);
    
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setInverted(true);
    leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
    
    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);

    // add data
    setData(25, 50);

    // // restrain the maximum scale-out factor
    // mChart.setScaleMinima(3f, 3f);
    //
    // // center the view to a specific position inside the chart
    // mChart.centerViewPort(10, 50);

    // get the legend (only possible after setting data)
    Legend l = mChart.getLegend();

    // modify the legend ...
    // l.setPosition(LegendPosition.LEFT_OF_CHART);
    l.setForm(LegendForm.LINE);

    // dont forget to refresh the drawing
    mChart.invalidate();
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:76,代码来源:InvertedLineChartActivity.java

示例12: SetupChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
public void SetupChart() {
    lineChart = (LineChart) myLayout.findViewById(R.id.chart);
    lineChart.setDescription("");
    lineChart.setDrawBorders(false);
    lineChart.setNoDataTextDescription("You need to provide data for the chart.");
    lineChart.setDrawGridBackground(false);
    lineChart.setOnChartValueSelectedListener(this);
    lineChart.setTouchEnabled(true);
    lineChart.setDragEnabled(false);
    lineChart.setPinchZoom(false);
    lineChart.setScaleXEnabled(true);
    lineChart.setScaleYEnabled(true);
    lineChart.invalidate();
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);
    // add empty data
    lineChart.setData(data);
    // get the legend (only possible after setting data)
    Legend l = lineChart.getLegend();
    l.setEnabled(false);
    // x axis setup
    XAxis xl = lineChart.getXAxis();
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(false);
    xl.setSpaceBetweenLabels(3);
    xl.setEnabled(true);
    xl.setDrawAxisLine(false);
    xl.removeAllLimitLines();
    //right y axis setup
    YAxis rightAxis = lineChart.getAxisRight();
    rightAxis.setEnabled(false);
    //left y axis setup
    YAxis leftAxis = lineChart.getAxisLeft();
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setLabelCount(6, true);
    leftAxis.setAxisMaxValue(400f);
    leftAxis.setAxisMinValue(0f);
    leftAxis.setDrawGridLines(false);
    leftAxis.setStartAtZero(false);
    leftAxis.setEnabled(true);
    leftAxis.setDrawAxisLine(false);
    leftAxis.setDrawZeroLine(false);
    leftAxis.setGranularityEnabled(false);
    //define min max line
    LimitLine max = new LimitLine(150f);
    max.enableDashedLine(10f, 10f, 0f);
    LimitLine min = new LimitLine(50f);
    min.enableDashedLine(10f, 10f, 0f);
    // reset all limit lines to avoid overlapping lines
    leftAxis.removeAllLimitLines();
    //add min max line
    leftAxis.addLimitLine(max);
    leftAxis.addLimitLine(min);

    lineChart.invalidate();
}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:58,代码来源:wearDripWatchFace.java


注:本文中的com.github.mikephil.charting.components.XAxis.setAvoidFirstLastClipping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。