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


Java XAxis.setDrawAxisLine方法代码示例

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


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

示例1: chartXAxisStyling

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void chartXAxisStyling(XAxis xAxis) {
    xAxis.setPosition(XAxis.XAxisPosition.TOP);
    xAxis.setTextColor(getResources().getColor(R.color.traffic_chart_text_color_light));
    xAxis.setDrawAxisLine(true);
    xAxis.setDrawGridLines(false);
    xAxis.setCenterAxisLabels(true);
    xAxis.setValueFormatter(new AxisValueFormatter() {
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return Utils.humanReadable((long) value);
        }

        @Override
        public int getDecimalDigits() {
            return 0;
        }
    });
}
 
开发者ID:DmitryMalkovich,项目名称:gito-github-client,代码行数:20,代码来源:TrafficFragment.java

示例2: setLineChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * Set the line chart pattern
 * @param lineChart chart
 * @param chartData pie chart data
 * @param month data
 * @param typeface Typeface font
 */
public static void setLineChart(Context context, LineChart lineChart, ChartData<?> chartData,
                                final String[] month, Typeface typeface) {
    // apply styling
    lineChart.getDescription().setEnabled(false);
    lineChart.setDrawGridBackground(false);
    // create a custom MarkerView (extend MarkerView) and specify the layout to use for it
    SalaryMarker marker = new SalaryMarker(context, R.layout.marker_salary_detail);
    marker.setChartView(lineChart); // For bounds control
    lineChart.setMarker(marker);
    //fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
    lineChart.setDrawMarkers(false);

    XAxis xAxis = lineChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTypeface(typeface);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(true);
    xAxis.setValueFormatter(new LineChartValueFormatter(month));
    xAxis.setLabelCount(month.length / 2, true);//xAxis label count

    YAxis leftAxis = lineChart.getAxisLeft();
    leftAxis.setTypeface(typeface);
    leftAxis.setLabelCount(9, false);
    leftAxis.setAxisMinimum(0f);
    YAxis rightAxis = lineChart.getAxisRight();
    rightAxis.setTypeface(typeface);
    rightAxis.setDrawGridLines(false);
    rightAxis.setAxisMinimum(0f);
    Legend l = lineChart.getLegend();
    l.setWordWrapEnabled(true);
    l.setTypeface(typeface);
    l.setFormSize(14f);
    l.setTextSize(9f);
    lineChart.setData((LineData) chartData);
    lineChart.animateX(DURATION_SHORT);

}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:45,代码来源:ChartHelper.java

示例3: setHorizontalBarChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * Set the horizontal bar pattern
 * @param barChart chart
 * @param chartData horizontal bar chart data
 * @param jobs string array of job titles
 * @param typeface Typeface font
 */
public static void setHorizontalBarChart(BarChart barChart, final ChartData<?> chartData,
                                         final String[] jobs, Typeface typeface) {
    barChart.setDrawGridBackground(false);
    XAxis xAxis = barChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    //xAxis.setLabelCount(chartData.getEntryCount());
    xAxis.setLabelCount(jobs.length);
    xAxis.setTypeface(typeface);
    xAxis.setDrawAxisLine(true);
    xAxis.setDrawGridLines(false);
    xAxis.setGranularity(1f);

    YAxis leftAxis = barChart.getAxisLeft();
    leftAxis.setTypeface(typeface);
    leftAxis.setSpaceTop(15f);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setGranularity(1f);
    leftAxis.setDrawAxisLine(true);
    leftAxis.setDrawGridLines(true);
    YAxis axisRight = barChart.getAxisRight();
    axisRight.setTypeface(typeface);
    axisRight.setDrawAxisLine(true);
    axisRight.setDrawGridLines(false);
    axisRight.setGranularity(1f);
    axisRight.setAxisMinimum(0f);

    final Legend legend = barChart.getLegend();
    legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    legend.setDrawInside(false);
    legend.setFormSize(8f);
    legend.setXEntrySpace(4f);
    barChart.setData((BarData) chartData);
    barChart.setFitBars(true);
    barChart.animateY(DURATION_LONG);
    xAxis.setValueFormatter(new HorizontalBarValueFormatter(jobs));
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:46,代码来源:ChartHelper.java

示例4: setVerticalBarChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * Set the vertical bar  pattern
 * @param barChart chart
 * @param chartData pie chart data
 * @param typeface Typeface font
 */
public static void setVerticalBarChart(Context context, BarChart barChart, ChartData<?> chartData,
                                        Typeface typeface) {
    // create a custom MarkerView (extend MarkerView) and specify the layout to use for it
    ExperienceMarker marker = new ExperienceMarker(context, R.layout.marker_exp_age);
    marker.setChartView(barChart); // For bounds control
    barChart.setMarker(marker);
    //fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
    barChart.setDrawMarkers(false);

    barChart.getDescription().setEnabled(false);
    barChart.setDrawGridBackground(false);
    barChart.setDrawBarShadow(false);
    XAxis xAxis = barChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    //Sets the number of labels for the x-axis (display all the x-axis values)
   // xAxis.setLabelCount(chartData.getEntryCount());
    xAxis.setTypeface(typeface);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(true);
    YAxis leftAxis = barChart.getAxisLeft();
    leftAxis.setTypeface(typeface);
    leftAxis.setSpaceTop(20f);
    leftAxis.setAxisMinimum(0f);

    YAxis rightAxis = barChart.getAxisRight();
    rightAxis.setTypeface(typeface);
    rightAxis.setSpaceTop(20f);
    rightAxis.setAxisMinimum(0f);
    chartData.setValueTypeface(typeface);
    barChart.setData((BarData) chartData);
    barChart.setFitBars(true);
    barChart.animateY(DURATION_SHORT);
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:40,代码来源:ChartHelper.java

示例5: 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

示例6: onCreateView

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

    BarChart chart = (BarChart) view.findViewById(R.id.chart);

    BarData data = new BarData(getXAxisValues(), getDataSet());

    //legend coding
    Legend l=chart.getLegend();
    l.setFormSize(10f);
    l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
    l.setTextSize(12f);
    l.setTextColor(Color.BLACK);
    l.setXEntrySpace(5f);
    l.setYEntrySpace(5f);
    //l.setCustom();

    XAxis xaxis=chart.getXAxis();
    xaxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xaxis.setTextSize(7f);
    xaxis.setTextColor(Color.parseColor("#212121"));
    xaxis.setDrawAxisLine(true);
    xaxis.setDrawGridLines(false);


    chart.setData(data);
    chart.setDescription("");
    chart.animateXY(2000, 2000);
    chart.invalidate();
   // chart.zoom(100, 10, 10, 10);


    return view;


}
 
开发者ID:Ronak-59,项目名称:Trinity-App,代码行数:38,代码来源:IDPTFragment.java

示例7: setupXAxis

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupXAxis(BarLineChartBase chart, IAxisValueFormatter formatter) {
    XAxis x = chart.getXAxis();
    x.setGranularity(1.0f);
    x.setDrawGridLines(false);
    x.setPosition(XAxis.XAxisPosition.BOTTOM);
    x.setDrawAxisLine(false);
    x.setCenterAxisLabels(true);
    x.setAxisMinimum(2.0f);
    x.setAxisMaximum(5.0f);
    x.setValueFormatter(formatter);
}
 
开发者ID:jasonwyatt,项目名称:SQLite-Performance,代码行数:12,代码来源:TestSuiteFragment.java

示例8: init

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
    setDrawBarShadow(false);
    setDrawValueAboveBar(true);
    getDescription().setEnabled(false);
    setMaxVisibleValueCount(60);
    setDrawGridBackground(false);

    XAxis xl = getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setDrawAxisLine(true);
    xl.setDrawGridLines(false);
    xl.setGranularity(10f);
    xl.setTextColor(Color.GRAY);

    YAxis yl = getAxisLeft();
    yl.setDrawAxisLine(false);
    yl.setDrawGridLines(false);
    yl.setDrawLabels(false);
    yl.setAxisMinimum(0f);
    yl.setTextColor(Color.GRAY);

    YAxis yr = getAxisRight();
    yr.setDrawAxisLine(true);
    yr.setDrawGridLines(false);
    yr.setAxisMinimum(0f);
    yl.setTextColor(Color.GRAY);

    setFitBars(true);
    animateY(2500);

    Legend l = getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setFormSize(8f);
    l.setXEntrySpace(4f);

}
 
开发者ID:VidyaSastry,项目名称:Opal-Chat-AnalyticsDashboard,代码行数:40,代码来源:MyHorizontalBarChart.java

示例9: initHeartRateChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void initHeartRateChart(LineChart mChart) {
    mChart.setViewPortOffsets(0, 0, 0, 0);
    mChart.setBackgroundColor(getResources().getColor(R.color.gold_pressed));
    mChart.setDescription("Heart Rate");
    mChart.setTouchEnabled(true);
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);
    mChart.setPinchZoom(false);
    mChart.setDrawGridBackground(false);
    mChart.setMaxHighlightDistance(300);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
    xAxis.setTextSize(11f);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);

    YAxis y = mChart.getAxisLeft();
    y.setTypeface(BandApplication.INSTANCE.getTfLight());
    y.setLabelCount(6, false);
    y.setTextColor(Color.RED);
    y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    y.setDrawGridLines(false);
    y.setAxisLineColor(Color.WHITE);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setTypeface(BandApplication.INSTANCE.getTfLight());
    y.setLabelCount(6, false);
    y.setTextColor(Color.RED);
    y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    y.setDrawGridLines(false);
    y.setAxisLineColor(Color.WHITE);

    mChart.getLegend().setEnabled(false);
    mChart.animateXY(2000, 2000);
}
 
开发者ID:qizhenghao,项目名称:Microsoft_Band,代码行数:38,代码来源:HeartRateFragment.java

示例10: createChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private static void createChart(Chart barChart, List<Pair<String, Integer>> chartData, String title, Context context){

        int count = chartData.size() > 10 ? 10 : chartData.size();

        String[] stateNames = new String[count];
        for (int i=0; i<count; ++i) {
            Pair<String, Integer> record = chartData.get(i);
            stateNames[i] = record.first;
        }

        StateAxisValueFormatter stateAxisValueFormatter = new StateAxisValueFormatter(stateNames);

        barChart.getDescription().setEnabled(false);
        barChart.setTouchEnabled(false);

        XAxis xl = barChart.getXAxis();
        xl.setPosition(XAxis.XAxisPosition.BOTTOM);
        xl.setDrawAxisLine(true);
        xl.setDrawGridLines(true);
        xl.setGridLineWidth(0.3f);
        xl.setTextSize(11f);
        xl.setTextColor(Color.BLACK);
        xl.setLabelCount(count);
        xl.setValueFormatter(stateAxisValueFormatter);

        // setting data
        Legend l = barChart.getLegend();
        l.setDirection(Legend.LegendDirection.LEFT_TO_RIGHT);
        l.setFormSize(11f);
        l.setTextSize(11f);
        l.setXEntrySpace(4f);

        setData(barChart, chartData, title,context);
    }
 
开发者ID:fga-gpp-mds,项目名称:2016.2-CidadeDemocratica,代码行数:35,代码来源:CharterGenerator.java

示例11: initChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void initChart(BarChart chart) {
    float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
    chart.setDragEnabled(true);
    chart.setScaleYEnabled(false);
    chart.setScaleXEnabled(false);
    chart.setDoubleTapToZoomEnabled(false);
    chart.setPinchZoom(false);
    chart.setHighlightPerDragEnabled(false);
    chart.setHighlightPerTapEnabled(false);

    chart.setDrawGridBackground(false);
    chart.setDrawBorders(false);
    chart.setDrawValueAboveBar(false);
    chart.getAxisLeft().setEnabled(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setDrawAxisLine(true);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawLabels(false);
    xAxis.setDrawLimitLinesBehindData(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

    YAxis yAxis = chart.getAxisRight();
    yAxis.setDrawAxisLine(false);
    yAxis.setStartAtZero(false);
    yAxis.setSpaceTop(10f);
    yAxis.setSpaceBottom(0f);
    yAxis.setTextSize(10 * scaledDensity);
    yAxis.setTextColor(ContextCompat.getColor(this, R.color.text));
    chart.getLegend().setEnabled(false);
    chart.setDescription(" ");

    chart.setNoDataText("Can't see sh*t captain!");
    Paint p = chart.getPaint(Chart.PAINT_INFO);
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 18, dm); //TODO use styles
    p.setTextSize(size);
    p.setColor(ContextCompat.getColor(this, R.color.gray600));
    p.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
}
 
开发者ID:stanleyguevara,项目名称:beaconradar,代码行数:40,代码来源:DetailsActivity.java

示例12: setupChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * Setup chart (axis, grid, etc.).
 *
 * @param lineChart      chart to setup.
 * @param data           chart with the data.
 * @param firstTimestamp seconds timestamp of the first record (used as initial reference).
 */
private void setupChart(LineChart lineChart, LineData data, long firstTimestamp) {
    // General setup
    lineChart.setDrawGridBackground(false);
    lineChart.setDrawBorders(false);
    lineChart.setViewPortOffsets(50, 0, 50, 50);
    lineChart.getDescription().setEnabled(false);
    lineChart.getLegend().setEnabled(false);
    lineChart.setTouchEnabled(false);
    lineChart.setNoDataText(context.getString(R.string.no_flight_act_data_available));
    // X axis setup
    IAxisValueFormatter xAxisFormatter = new HourAxisValueFormatter(firstTimestamp);
    XAxis xAxis = lineChart.getXAxis();
    xAxis.setValueFormatter(xAxisFormatter);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setCenterAxisLabels(false);
    xAxis.setTextColor(ContextCompat.getColor(context, R.color.colorIcons));
    // Y axis setup
    YAxis yAxis = lineChart.getAxisLeft();
    yAxis.setAxisMaximum(40);
    yAxis.setAxisMinimum(0);
    yAxis.setDrawLabels(false);
    yAxis.setDrawAxisLine(false);
    yAxis.setDrawGridLines(true);
    lineChart.getAxisRight().setEnabled(false);
    // Add data
    lineChart.setData(data);
}
 
开发者ID:davidmigloz,项目名称:go-bees,代码行数:37,代码来源:RecordingsAdapter.java

示例13: initChart

import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
 * 初始化图表
 *
 * @param chart 原始图表
 * @return 初始化后的图表
 */
public static LineChart initChart(LineChart chart) {
    // 不显示数据描述
    chart.getDescription().setEnabled(false);
    // 没有数据的时候,显示“暂无数据”
    chart.setNoDataText("暂无数据");
    // 不显示表格颜色
    chart.setDrawGridBackground(false);
    // 不可以缩放
    chart.setScaleEnabled(false);
    // 不显示y轴右边的值
    chart.getAxisRight().setEnabled(false);
    // 不显示图例
    Legend legend = chart.getLegend();
    legend.setEnabled(false);
    // 向左偏移15dp,抵消y轴向右偏移的30dp
    chart.setExtraLeftOffset(-15);

    XAxis xAxis = chart.getXAxis();
    // 不显示x轴
    xAxis.setDrawAxisLine(false);
    // 设置x轴数据的位置
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setTextSize(12);
    xAxis.setGridColor(Color.parseColor("#30FFFFFF"));
    // 设置x轴数据偏移量
    xAxis.setYOffset(-12);

    YAxis yAxis = chart.getAxisLeft();
    // 不显示y轴
    yAxis.setDrawAxisLine(false);
    // 设置y轴数据的位置
    yAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
    // 不从y轴发出横向直线
    yAxis.setDrawGridLines(false);
    yAxis.setTextColor(Color.WHITE);
    yAxis.setTextSize(12);
    // 设置y轴数据偏移量
    yAxis.setXOffset(30);
    yAxis.setYOffset(-3);
    yAxis.setAxisMinimum(0);

    //Matrix matrix = new Matrix();
    // x轴缩放1.5倍
    //matrix.postScale(1.5f, 1f);
    // 在图表动画显示之前进行缩放
    //chart.getViewPortHandler().refresh(matrix, chart, false);
    // x轴执行动画
    //chart.animateX(2000);
    chart.invalidate();
    return chart;
}
 
开发者ID:alidili,项目名称:Demos,代码行数:59,代码来源:ChartUtils.java

示例14: 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_time);

    tvX = (TextView) findViewById(R.id.tvXMax);
    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarX.setProgress(100);
    tvX.setText("100");

    mSeekBarX.setOnSeekBarChangeListener(this);

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

    // no description text
    mChart.getDescription().setEnabled(false);

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

    mChart.setDragDecelerationFrictionCoef(0.9f);

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

    // set an alternative background color
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setViewPortOffsets(0f, 0f, 0f, 0f);

    // add data
    setData(100, 30);
    mChart.invalidate();

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE);
    xAxis.setTypeface(mTfLight);
    xAxis.setTextSize(10f);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setDrawAxisLine(false);
    xAxis.setDrawGridLines(true);
    xAxis.setTextColor(Color.rgb(255, 192, 56));
    xAxis.setCenterAxisLabels(true);
    xAxis.setGranularity(1f); // one hour
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        private SimpleDateFormat mFormat = new SimpleDateFormat("dd MMM HH:mm");

        @Override
        public String getFormattedValue(float value, AxisBase axis) {

            long millis = TimeUnit.HOURS.toMillis((long) value);
            return mFormat.format(new Date(millis));
        }
    });

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
    leftAxis.setTypeface(mTfLight);
    leftAxis.setTextColor(ColorTemplate.getHoloBlue());
    leftAxis.setDrawGridLines(true);
    leftAxis.setGranularityEnabled(true);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setAxisMaximum(170f);
    leftAxis.setYOffset(-9f);
    leftAxis.setTextColor(Color.rgb(255, 192, 56));

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setEnabled(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:LineChartTime.java

示例15: 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_barchart_noseekbar);

    mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    mChart = (BarChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.WHITE);
    mChart.setExtraTopOffset(-30f);
    mChart.setExtraBottomOffset(10f);
    mChart.setExtraLeftOffset(70f);
    mChart.setExtraRightOffset(70f);

    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);

    mChart.getDescription().setEnabled(false);

    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);

    mChart.setDrawGridBackground(false);

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setDrawAxisLine(false);
    xAxis.setTextColor(Color.LTGRAY);
    xAxis.setTextSize(13f);
    xAxis.setLabelCount(5);
    xAxis.setCenterAxisLabels(true);
    xAxis.setGranularity(1f);

    YAxis left = mChart.getAxisLeft();
    left.setDrawLabels(false);
    left.setSpaceTop(25f);
    left.setSpaceBottom(25f);
    left.setDrawAxisLine(false);
    left.setDrawGridLines(false);
    left.setDrawZeroLine(true); // draw a zero line
    left.setZeroLineColor(Color.GRAY);
    left.setZeroLineWidth(0.7f);
    mChart.getAxisRight().setEnabled(false);
    mChart.getLegend().setEnabled(false);

    // THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
    final List<Data> data = new ArrayList<>();
    data.add(new Data(0f, -224.1f, "12-29"));
    data.add(new Data(1f, 238.5f, "12-30"));
    data.add(new Data(2f, 1280.1f, "12-31"));
    data.add(new Data(3f, -442.3f, "01-01"));
    data.add(new Data(4f, -2280.1f, "01-02"));

    xAxis.setValueFormatter(new IAxisValueFormatter() {
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
        }
    });

    setData(data);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:66,代码来源:BarChartPositiveNegative.java


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