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


Java Legend.setVerticalAlignment方法代码示例

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


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

示例1: setAxis

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
@Override
public void setAxis(AnalysisXAxisValueFormatter formatter, float yAxisMaxValue) {

    XAxis xAxis = mRadarChart.getXAxis();
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(formatter);
    xAxis.setTextColor(Color.WHITE);

    YAxis yAxis = mRadarChart.getYAxis();
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(yAxisMaxValue);
    yAxis.setDrawLabels(false);

    Legend l = mRadarChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
 
开发者ID:Alex-ZHOU,项目名称:VMAndroid,代码行数:27,代码来源:AnalysisChartFragment.java

示例2: prepareLegend

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
/**
 * Create a legend based on a dummy chart.  The legend
 * is used by all charts and is positioned
 * across the top of the screen.
 * @param data - CombinedData used to generate the legend
 */
private void prepareLegend(final CombinedData data){
  //The dummy chart is never shown, but it's legend is.
  final CombinedChart dummyChart = (CombinedChart) mRoot.findViewById(R.id.legend);
  dummyChart.getPaint(Chart.PAINT_DESCRIPTION).setTextAlign(Paint.Align.CENTER);
  dummyChart.getXAxis().setEnabled(false);
  dummyChart.getAxisRight().setEnabled(false);
  dummyChart.getAxisLeft().setEnabled(false);
  final Description description = new Description();
  description.setText("");
  description.setTextSize(10f);
  dummyChart.setDescription(description);
  dummyChart.setBackgroundColor(Color.WHITE);
  dummyChart.setDrawGridBackground(false);
  dummyChart.setData(data);

  final Legend l = dummyChart.getLegend();
  l.setEnabled(true);
  // The positioning of the legend effectively
  // hides the dummy chart from view.
  l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
  l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
  dummyChart.invalidate();
}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:30,代码来源:SummaryChartFragment.java

示例3: runTests

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
public void runTests() {
    for (TestCaseRunner runner : mRunners) {
        runner.cancel(true);
    }
    mRunners.clear();

    mChart.clear();

    BarData data = new BarData();
    mChart.setData(data);

    MetricsVariableAxisFormatter formatter = new MetricsVariableAxisFormatter(getMetricsTransformer());

    setupYAxes(mChart);
    setupXAxis(mChart, formatter);
    setupDescription(mChart);

    Legend legend = mChart.getLegend();
    legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    legend.setWordWrapEnabled(true);
    legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    legend.setDrawInside(false);

    mChart.invalidate();

    Map<TestScenarioMetadata, TestCase[]> scenarios = getTestScenarios();
    for (Map.Entry<TestScenarioMetadata, TestCase[]> scenario : scenarios.entrySet()) {
        TestScenarioMetadata d = scenario.getKey();

        TestCaseRunner r = new TestCaseRunner(d.iterations, mChart, d.title, d.color, formatter);
        r.executeOnExecutor(TestCaseRunner.SERIAL_EXECUTOR, scenario.getValue());
        mRunners.add(r);
    }
}
 
开发者ID:jasonwyatt,项目名称:SQLite-Performance,代码行数:36,代码来源:TestSuiteFragment.java

示例4: init

import com.github.mikephil.charting.components.Legend; //导入方法依赖的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

示例5: init

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyle) {
    setUsePercentValues(true);
    getDescription().setEnabled(false);
    setExtraOffsets(5, 10, 5, 5);
    setDragDecelerationFrictionCoef(0.95f);

    setDrawHoleEnabled(true);
    setHoleColor(Color.WHITE);

    setTransparentCircleColor(Color.WHITE);
    setTransparentCircleAlpha(110);

    setHoleRadius(58f);
    setTransparentCircleRadius(61f);

    setDrawCenterText(true);

    setRotationAngle(0);
    setRotationEnabled(true);
    setHighlightPerTapEnabled(true);


    Legend l = getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
    l.setTextColor(Color.GRAY);
    l.setDrawInside(false);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(0f);
    l.setYOffset(0f);

    setEntryLabelColor(Color.GRAY);
    setEntryLabelTextSize(12f);
}
 
开发者ID:VidyaSastry,项目名称:Opal-Chat-AnalyticsDashboard,代码行数:36,代码来源:MyPieChart.java

示例6: onCreate

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

    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(4);
    mSeekBarY.setProgress(10);

    mChart = (PieChart) findViewById(R.id.chart1);
    mChart.setUsePercentValues(true);
    mChart.getDescription().setEnabled(false);
    mChart.setExtraOffsets(5, 10, 5, 5);

    mChart.setDragDecelerationFrictionCoef(0.95f);

    mChart.setCenterTextTypeface(mTfLight);
    mChart.setCenterText(generateCenterSpannableText());

    mChart.setDrawHoleEnabled(true);
    mChart.setHoleColor(Color.WHITE);

    mChart.setTransparentCircleColor(Color.WHITE);
    mChart.setTransparentCircleAlpha(110);

    mChart.setHoleRadius(58f);
    mChart.setTransparentCircleRadius(61f);

    mChart.setDrawCenterText(true);

    mChart.setRotationAngle(0);
    // enable rotation of the chart by touch
    mChart.setRotationEnabled(true);
    mChart.setHighlightPerTapEnabled(true);

    // mChart.setUnit(" €");
    // mChart.setDrawUnitsInChart(true);

    // add a selection listener
    mChart.setOnChartValueSelectedListener(this);

    setData(4, 100);

    mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
    // mChart.spin(2000, 0, 360);

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

    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
    l.setDrawInside(false);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(0f);
    l.setYOffset(0f);

    // entry label styling
    mChart.setEntryLabelColor(Color.WHITE);
    mChart.setEntryLabelTypeface(mTfRegular);
    mChart.setEntryLabelTextSize(12f);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:70,代码来源:PieChartActivity.java

示例7: initLineChart

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
/**
 * 初始化LineChart
 */
private void initLineChart() {
    //设置支持触控
    mBarChart.setTouchEnabled(true); // 设置是否可以触摸
    mBarChart.setDragEnabled(false);// 是否可以拖拽
    mBarChart.setScaleEnabled(false);// 是否可以缩放
    mBarChart.setBackgroundColor(Color.WHITE);//背景颜色
    mBarChart.setDrawGridBackground(false);  //网格
    mBarChart.setDrawBarShadow(false);//背景阴影
    mBarChart.setHighlightFullBarEnabled(false);//设置高光
    mBarChart.setDrawBorders(false);//显示边界
    mBarChart.getXAxis().setDrawGridLines(false);//是否显示竖直标尺线
    mBarChart.getAxisLeft().setDrawGridLines(false);//是否显示横直标尺线
    mBarChart.getAxisRight().setEnabled(false);//是否显示最右侧竖线
    mBarChart.setDescription(null);

    //设置动画效果
    mBarChart.animateY(1000, Easing.EasingOption.Linear);
    mBarChart.animateX(1000, Easing.EasingOption.Linear);

    //折线图例 标签 设置
    Legend legend = mBarChart.getLegend();
    legend.setForm(Legend.LegendForm.LINE);
    legend.setTextSize(11f);
    //显示位置
    legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    legend.setDrawInside(false);
    legend.setEnabled(false);

    //XY轴的设置
    //X轴设置显示位置在底部
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setGranularity(1f);
    //保证Y轴从0开始,不然会上移一点
    leftAxis.setAxisMinimum(0f);
    rightAxis.setAxisMinimum(0f);
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:42,代码来源:BarChartManager.java

示例8: setHorizontalBarChart

import com.github.mikephil.charting.components.Legend; //导入方法依赖的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

示例9: initializeChart

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
private void initializeChart() {
    chart.setUsePercentValues(true);
    chart.getDescription().setEnabled(false);
    chart.setDragDecelerationFrictionCoef(0.95f);
    chart.setCenterText(generateCenterSpannableText());
    chart.setExtraOffsets(15.f, 15.f, 15.f, 15.f);
    chart.setDrawHoleEnabled(true);
    chart.setHoleColor(Color.WHITE);
    chart.setTransparentCircleColor(Color.WHITE);
    chart.setTransparentCircleAlpha(110);
    chart.setHoleRadius(58f);
    chart.setTransparentCircleRadius(61f);
    chart.setDrawCenterText(true);
    chart.setRotationAngle(0);
    // enable rotation of the chart by touch
    chart.setRotationEnabled(true);
    chart.setHighlightPerTapEnabled(true);

    // add a selection listener
    chart.setOnChartValueSelectedListener(this);

    Legend l = chart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setEnabled(true);
}
 
开发者ID:iotaledger,项目名称:android-wallet-app,代码行数:29,代码来源:NodeInfoFragment.java

示例10: setupPie

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
private void setupPie(PieChart pieChart, int pos, float dados[], String labels[]) {


        List<PieEntry> entries = new ArrayList<>();
        int index = 0;
        for (float dado : dados) {
            entries.add(new PieEntry(dado, labels[index]));
            index++;
        }

        //entries.add(new PieEntry(24.0f, "Red"));
        //entries.add(new PieEntry(30.8f, "Blue"));

        PieDataSet set = new PieDataSet(entries, "");
        Description description = new Description();
        description.setText(" ");
        pieChart.setDescription(description);
        set.setColors(ColorTemplate.MATERIAL_COLORS);
        PieData data = new PieData(set);
        pieChart.setData(data);
        pieChart.invalidate();


        Legend l = pieChart.getLegend();
        l.setFormSize(15f); // set the size of the legend forms/shapes
        l.setForm(Legend.LegendForm.CIRCLE); // set what type of form/shape should be used
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
        l.setOrientation(Legend.LegendOrientation.VERTICAL);
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
        l.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        l.setTextSize(18f);
        l.setTextColor(Color.BLACK);
        l.setXEntrySpace(5f); // set the space between the legend entries on the x-axis
        l.setYEntrySpace(5f);

        pieChart.animateXY(3000, 3000);

    }
 
开发者ID:ivoribeiro,项目名称:AndroidQuiz,代码行数:39,代码来源:AdapterEstatisticasGraph.java

示例11: preparePieChart

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
public PieChart preparePieChart(PieChart pieChart) {
    pieChart.setUsePercentValues(true);
    pieChart.getDescription().setEnabled(false);
    pieChart.setExtraOffsets(5, 10, 5, 5);
    pieChart.setDragDecelerationFrictionCoef(0.96f);

    pieChart.setDrawHoleEnabled(true);
    pieChart.setHoleColor(android.R.color.transparent);

    pieChart.setTransparentCircleColor(utilsUI.getColor(android.R.color.white));
    pieChart.setTransparentCircleAlpha(50);

    pieChart.setHoleRadius(40f);
    pieChart.setTransparentCircleRadius(45f);

    pieChart.setDrawCenterText(true);
    pieChart.setCenterText("Balance");

    pieChart.setRotationAngle(0);
    // enable rotation of the chart by touch
    pieChart.setRotationEnabled(false);
    pieChart.setHighlightPerTapEnabled(true);
    pieChart.setDrawEntryLabels(true);
    pieChart.setEntryLabelColor(utilsUI.getColor(android.R.color.white));
    pieChart.setEntryLabelTextSize(15f);

    Legend l = pieChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);

    return pieChart;
}
 
开发者ID:MLSDev,项目名称:RecipeFinderJavaVersion,代码行数:35,代码来源:DiagramUtils.java

示例12: getFormattedPieChart

import com.github.mikephil.charting.components.Legend; //导入方法依赖的package包/类
/**
 * Formats a pie chart in a standardized way
 * @param c Context
 * @param p Pie chart
 * @param shouldShowLegend
 * @return the PieChart, whose data must be set and invalidated
 */
public static PieChart getFormattedPieChart(Context c, PieChart p, boolean shouldShowLegend) {
    Legend cLegend = p.getLegend();
    if (shouldShowLegend) {
        cLegend.setEnabled(true);
        cLegend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
        cLegend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
        cLegend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
        cLegend.setDrawInside(false);
        cLegend.setForm(Legend.LegendForm.CIRCLE);
        cLegend.setTextSize(15);
        cLegend.setWordWrapEnabled(true);
    } else {
        cLegend.setEnabled(false);
    }

    p.setDrawEntryLabels(false);
    p.setDescription(EMPTY_CHART_DESCRIPTION);
    p.setHoleRadius(60f);
    p.setTransparentCircleRadius(65f);
    p.setCenterTextSize(20);

    if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
        int colorPrimaryNoir = ContextCompat.getColor(c, R.color.colorPrimaryNoir);
        int colorPrimaryTextNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);

        p.setHoleColor(colorPrimaryNoir);
        p.setTransparentCircleColor(colorPrimaryNoir);
        p.setCenterTextColor(colorPrimaryTextNoir);
        cLegend.setTextColor(colorPrimaryTextNoir);
    }

    p.setRotationEnabled(false);

    p.setOnChartValueSelectedListener(new PieChartListener(p));
    return p;
}
 
开发者ID:lloydtorres,项目名称:stately,代码行数:44,代码来源:RaraHelper.java

示例13: init

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

    XAxis xAxis = getXAxis();
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
    xAxis.setDrawGridLines(false);
    xAxis.setGranularity(1f);
    xAxis.setLabelCount(7);
    xAxis.setTextColor(Color.GRAY);

    YAxis leftAxis = getAxisLeft();
    leftAxis.setDrawGridLines(false);
    leftAxis.setLabelCount(8, false);
    leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
    leftAxis.setSpaceTop(15f);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setTextColor(Color.GRAY);

    YAxis rightAxis = getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setDrawAxisLine(false);
    rightAxis.setLabelCount(8, false);
    rightAxis.setDrawLabels(false);
    rightAxis.setSpaceTop(15f);
    rightAxis.setAxisMinimum(0f);

    Legend l = getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setForm(Legend.LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);

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

示例14: onCreate

import com.github.mikephil.charting.components.Legend; //导入方法依赖的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_sinus);

    mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");

    tvX = (TextView) findViewById(R.id.tvValueCount);

    mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);

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

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

    mChart.getDescription().setEnabled(false);

    // 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);

    // draw shadows for each bar that show the maximum value
    // mChart.setDrawBarShadow(true);

    // mChart.setDrawXLabels(false);

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

    XAxis xAxis = mChart.getXAxis();
    xAxis.setEnabled(false);

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTfLight);
    leftAxis.setLabelCount(6, false);
    leftAxis.setAxisMinimum(-2.5f);
    leftAxis.setAxisMaximum(2.5f);
    leftAxis.setGranularityEnabled(true);
    leftAxis.setGranularity(0.1f);

    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setDrawGridLines(false);
    rightAxis.setTypeface(mTfLight);
    rightAxis.setLabelCount(6, false);
    rightAxis.setAxisMinimum(-2.5f);
    rightAxis.setAxisMaximum(2.5f);
    rightAxis.setGranularity(0.1f);

    mSeekBarX.setOnSeekBarChangeListener(this);
    mSeekBarX.setProgress(150); // set data

    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);

    mChart.animateXY(2000, 2000);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:70,代码来源:BarChartActivitySinus.java

示例15: onCreate

import com.github.mikephil.charting.components.Legend; //导入方法依赖的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);
        tvX.setTextSize(10);
        tvY = (TextView) findViewById(R.id.tvYMax);

        mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
        mSeekBarX.setOnSeekBarChangeListener(this);

        mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
        mSeekBarY.setOnSeekBarChangeListener(this);

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

//        mChart.setDrawBorders(true);

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

        mChart.setDrawBarShadow(false);

        mChart.setDrawGridBackground(false);

        // 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

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

        Legend l = mChart.getLegend();
        l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
        l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
        l.setOrientation(Legend.LegendOrientation.VERTICAL);
        l.setDrawInside(true);
        l.setTypeface(mTfLight);
        l.setYOffset(0f);
        l.setXOffset(10f);
        l.setYEntrySpace(0f);
        l.setTextSize(8f);

        XAxis xAxis = mChart.getXAxis();
        xAxis.setTypeface(mTfLight);
        xAxis.setGranularity(1f);
        xAxis.setCenterAxisLabels(true);
        xAxis.setValueFormatter(new IAxisValueFormatter() {
            @Override
            public String getFormattedValue(float value, AxisBase axis) {
                return String.valueOf((int) value);
            }
        });

        YAxis leftAxis = mChart.getAxisLeft();
        leftAxis.setTypeface(mTfLight);
        leftAxis.setValueFormatter(new LargeValueFormatter());
        leftAxis.setDrawGridLines(false);
        leftAxis.setSpaceTop(35f);
        leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)

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


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