• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java YAxisLabelPosition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



YAxisLabelPosition类属于com.github.mikephil.charting.components.YAxis包,在下文中一共展示了YAxisLabelPosition类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: renderAxisLabels

import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; //导入依赖的package包/类
/**
 * draws the y-axis labels to the screen
 */
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    float[] positions = getTransformedPositions();

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    float xoffset = mYAxis.getXOffset();
    float yoffset = Utils.calcTextHeight(mAxisLabelPaint, "A") / 2.5f + mYAxis.getYOffset();

    AxisDependency dependency = mYAxis.getAxisDependency();
    YAxisLabelPosition labelPosition = mYAxis.getLabelPosition();

    float xPos = 0f;

    if (dependency == AxisDependency.LEFT) {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            mAxisLabelPaint.setTextAlign(Align.RIGHT);
            xPos = mViewPortHandler.offsetLeft() - xoffset;
        } else {
            mAxisLabelPaint.setTextAlign(Align.LEFT);
            xPos = mViewPortHandler.offsetLeft() + xoffset;
        }

    } else {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            mAxisLabelPaint.setTextAlign(Align.LEFT);
            xPos = mViewPortHandler.contentRight() + xoffset;
        } else {
            mAxisLabelPaint.setTextAlign(Align.RIGHT);
            xPos = mViewPortHandler.contentRight() - xoffset;
        }
    }

    drawYLabels(c, xPos, positions, yoffset);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:47,代码来源:YAxisRenderer.java


示例2: renderAxisLabels

import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; //导入依赖的package包/类
/**
 * draws the y-axis labels to the screen
 */
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    float[] positions = getTransformedPositions();

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());
    mAxisLabelPaint.setTextAlign(Align.CENTER);

    float baseYOffset = Utils.convertDpToPixel(2.5f);
    float textHeight = Utils.calcTextHeight(mAxisLabelPaint, "Q");

    AxisDependency dependency = mYAxis.getAxisDependency();
    YAxisLabelPosition labelPosition = mYAxis.getLabelPosition();

    float yPos = 0f;

    if (dependency == AxisDependency.LEFT) {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            yPos = mViewPortHandler.contentTop() - baseYOffset;
        } else {
            yPos = mViewPortHandler.contentTop() - baseYOffset;
        }

    } else {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            yPos = mViewPortHandler.contentBottom() + textHeight + baseYOffset;
        } else {
            yPos = mViewPortHandler.contentBottom() + textHeight + baseYOffset;
        }
    }

    drawYLabels(c, yPos, positions, mYAxis.getYOffset());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:YAxisRendererHorizontalBarChart.java


示例3: renderAxisLabels

import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; //导入依赖的package包/类
/**
 * draws the y-axis labels to the screen
 */
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    float[] positions = new float[mYAxis.mEntryCount * 2];

    for (int i = 0; i < positions.length; i += 2) {
        // only fill y values, x values are not needed since the y-labels
        // are
        // static on the x-axis
        positions[i + 1] = mYAxis.mEntries[i / 2];
    }

    mTrans.pointValuesToPixel(positions);

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());

    float xoffset = mYAxis.getXOffset();
    float yoffset = Utils.calcTextHeight(mAxisLabelPaint, "A") / 2.5f + mYAxis.getYOffset();

    AxisDependency dependency = mYAxis.getAxisDependency();
    YAxisLabelPosition labelPosition = mYAxis.getLabelPosition();

    float xPos = 0f;

    if (dependency == AxisDependency.LEFT) {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            mAxisLabelPaint.setTextAlign(Align.RIGHT);
            xPos = mViewPortHandler.offsetLeft() - xoffset;
        } else {
            mAxisLabelPaint.setTextAlign(Align.LEFT);
            xPos = mViewPortHandler.offsetLeft() + xoffset;
        }

    } else {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            mAxisLabelPaint.setTextAlign(Align.LEFT);
            xPos = mViewPortHandler.contentRight() + xoffset;
        } else {
            mAxisLabelPaint.setTextAlign(Align.RIGHT);
            xPos = mViewPortHandler.contentRight() - xoffset;
        }
    }

    drawYLabels(c, xPos, positions, yoffset);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:56,代码来源:YAxisRenderer.java


示例4: renderAxisLabels

import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; //导入依赖的package包/类
/**
 * draws the y-axis labels to the screen
 */
@Override
public void renderAxisLabels(Canvas c) {

    if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
        return;

    float[] positions = new float[mYAxis.mEntryCount * 2];

    for (int i = 0; i < positions.length; i += 2) {
        // only fill y values, x values are not needed since the y-labels
        // are
        // static on the x-axis
        positions[i] = mYAxis.mEntries[i / 2];
    }

    mTrans.pointValuesToPixel(positions);

    mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
    mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
    mAxisLabelPaint.setColor(mYAxis.getTextColor());
    mAxisLabelPaint.setTextAlign(Align.CENTER);

    float baseYOffset = Utils.convertDpToPixel(2.5f);
    float textHeight = Utils.calcTextHeight(mAxisLabelPaint, "Q");

    AxisDependency dependency = mYAxis.getAxisDependency();
    YAxisLabelPosition labelPosition = mYAxis.getLabelPosition();

    float yPos = 0f;

    if (dependency == AxisDependency.LEFT) {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            yPos = mViewPortHandler.contentTop() - baseYOffset;
        } else {
            yPos = mViewPortHandler.contentTop() - baseYOffset;
        }

    } else {

        if (labelPosition == YAxisLabelPosition.OUTSIDE_CHART) {
            yPos = mViewPortHandler.contentBottom() + textHeight + baseYOffset;
        } else {
            yPos = mViewPortHandler.contentBottom() + textHeight + baseYOffset;
        }
    }

    drawYLabels(c, yPos, positions, mYAxis.getYOffset());
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:53,代码来源:YAxisRendererHorizontalBarChart.java


示例5: onCreate

import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition; //导入依赖的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);

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

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

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

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

    mChart.setDescription("");

    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    mChart.setMaxVisibleValueCount(60);

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

    mChart.setDrawGridBackground(false);
    // mChart.setDrawYLabels(false);

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setSpaceBetweenLabels(2);

    YAxisValueFormatter custom = new MyYAxisValueFormatter();

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(8, false);
    leftAxis.setValueFormatter(custom);
    leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
    leftAxis.setSpaceTop(15f);
    leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setTypeface(mTf);
    rightAxis.setLabelCount(8, false);
    rightAxis.setValueFormatter(custom);
    rightAxis.setSpaceTop(15f);
    rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_LEFT);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);
    // l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
    // "def", "ghj", "ikl", "mno" });
    // l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
    // "def", "ghj", "ikl", "mno" });

    setData(12, 50);

    // setting data
    mSeekBarY.setProgress(50);
    mSeekBarX.setProgress(12);

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

    // mChart.setDrawLegend(false);
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:80,代码来源:BarChartActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClusterMessage类代码示例发布时间:2022-05-23
下一篇:
Java HSAdmin类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap