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


Java LineDataSet.setDrawHorizontalHighlightIndicator方法代码示例

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


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

示例1: setData

import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setData(int count, float range) {

        ArrayList<String> xVals = new ArrayList<String>();
        for (int i = 0; i < count; i++) {
            xVals.add((1990 +i) + "");
        }

        ArrayList<Entry> vals1 = new ArrayList<Entry>();

        for (int i = 0; i < count; i++) {
            float mult = (range + 1);
            float val = (float) (Math.random() * mult) + 20;// + (float)
                                                           // ((mult *
                                                           // 0.1) / 10);
            vals1.add(new Entry(val, i));
        }
        
        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(vals1, "DataSet 1");
        set1.setDrawCubic(true);
        set1.setCubicIntensity(0.2f);
        //set1.setDrawFilled(true);
        set1.setDrawCircles(false); 
        set1.setLineWidth(1.8f);
        set1.setCircleRadius(4f);
        set1.setCircleColor(Color.WHITE);
        set1.setHighLightColor(Color.rgb(244, 117, 117));
        set1.setColor(Color.WHITE);
        set1.setFillColor(Color.WHITE);
        set1.setFillAlpha(100);
        set1.setDrawHorizontalHighlightIndicator(false);
        set1.setFillFormatter(new FillFormatter() {
            @Override
            public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
                return -10;
            }
        });
        
        // create a data object with the datasets
        LineData data = new LineData(xVals, set1);
        data.setValueTypeface(tf);
        data.setValueTextSize(9f);
        data.setDrawValues(false);

        // set data
        mChart.setData(data);
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:48,代码来源:CubicLineChartActivity.java

示例2: setVotingHistory

import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
/**
 * Initialize the line graph to show voting history
 * @param vF
 * @param vA
 */
private void setVotingHistory(List<Integer> vF, List<Integer> vA) {
    votesFor = vF;
    votesAgainst = vA;
    votesFor.add(resolution.votesFor);
    votesAgainst.add(resolution.votesAgainst);

    final float lineWidth = 2.5f;

    List<Entry> entryFor = new ArrayList<Entry>();
    List<Entry> entryAgainst = new ArrayList<Entry>();

    // Build data
    for (int i=0; i < votesFor.size(); i++) {
        entryFor.add(new Entry(i, votesFor.get(i)));
        entryAgainst.add(new Entry(i, votesAgainst.get(i)));
    }

    // lots of formatting for the FOR and AGAINST lines
    LineDataSet setFor = new LineDataSet(entryFor, context.getString(R.string.wa_for));
    setFor.setAxisDependency(YAxis.AxisDependency.LEFT);
    setFor.setColors(ContextCompat.getColor(context, R.color.colorChart0));
    setFor.setDrawValues(false);
    setFor.setDrawVerticalHighlightIndicator(true);
    setFor.setDrawHorizontalHighlightIndicator(false);
    setFor.setHighLightColor(RaraHelper.getThemeButtonColour(context));
    setFor.setHighlightLineWidth(lineWidth);
    setFor.setDrawCircles(false);
    setFor.setLineWidth(lineWidth);

    LineDataSet setAgainst = new LineDataSet(entryAgainst, context.getString(R.string.wa_against));
    setAgainst.setAxisDependency(YAxis.AxisDependency.LEFT);
    setAgainst.setColors(ContextCompat.getColor(context, R.color.colorChart1));
    setAgainst.setDrawValues(false);
    setAgainst.setDrawVerticalHighlightIndicator(true);
    setAgainst.setDrawHorizontalHighlightIndicator(false);
    setAgainst.setHighLightColor(RaraHelper.getThemeButtonColour(context));
    setAgainst.setHighlightLineWidth(lineWidth);
    setAgainst.setDrawCircles(false);
    setAgainst.setLineWidth(lineWidth);

    // Match data with x-axis labels
    List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(setFor);
    dataSets.add(setAgainst);

    LineData data = new LineData(dataSets);
    List<String> xLabels = new ArrayList<String>();
    for (int i=0; i < votesFor.size(); i++) {
        // Only add labels for each day
        if (i%24 == 0) {
            xLabels.add(String.format(Locale.US, context.getString(R.string.wa_x_axis_d), (i/24)+1));
        } else {
            xLabels.add(String.format(Locale.US, context.getString(R.string.wa_x_axis_h), i));
        }
    }

    // formatting
    votingHistory = RaraHelper.getFormattedLineChart(context, votingHistory, this, xLabels, true, 24, false);

    votingHistory.setData(data);
    votingHistory.invalidate();
}
 
开发者ID:lloydtorres,项目名称:stately,代码行数:68,代码来源:ResolutionRecyclerAdapter.java

示例3: init

import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
public void init(CensusHistoryScale scale) {
    dataset = scale;
    // Set selected indicator text to latest data
    resetDataSelected();

    // Calculate max, min, average
    List<CensusHistoryPoint> datapoints = dataset.points;

    float maxVal = Float.MIN_VALUE;
    float minVal = Float.MAX_VALUE;
    float total = 0;
    for (int i=0; i < datapoints.size(); i++) {
        float value = datapoints.get(i).score;
        if (value > maxVal) {
            maxVal = value;
        }
        if (value < minVal) {
            minVal = value;
        }
        total += value;
    }
    float avgVal = total / datapoints.size();

    max.setText(SparkleHelper.getPrettifiedNumber(maxVal));
    min.setText(SparkleHelper.getPrettifiedNumber(minVal));
    avg.setText(SparkleHelper.getPrettifiedNumber(avgVal));

    // Set up chart
    final float lineWidth = 2.5f;
    List<Entry> historyEntries = new ArrayList<Entry>();
    for (int i=0; i < datapoints.size(); i++) {
        historyEntries.add(new Entry(i, datapoints.get(i).score));
    }

    // Formatting
    LineDataSet lineHistoryData = new LineDataSet(historyEntries, "");
    lineHistoryData.setAxisDependency(YAxis.AxisDependency.LEFT);
    lineHistoryData.setColors(ContextCompat.getColor(context, R.color.colorChart0));
    lineHistoryData.setDrawValues(false);
    lineHistoryData.setDrawVerticalHighlightIndicator(true);
    lineHistoryData.setDrawHorizontalHighlightIndicator(false);
    lineHistoryData.setHighLightColor(RaraHelper.getThemeButtonColour(context));
    lineHistoryData.setHighlightLineWidth(lineWidth);
    lineHistoryData.setDrawCircles(false);
    lineHistoryData.setLineWidth(lineWidth);

    // Match data with x-axis labels
    List<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
    dataSets.add(lineHistoryData);
    LineData dataFinal = new LineData(dataSets);
    List<String> xLabels = new ArrayList<String>();
    for (int i=0; i < datapoints.size(); i++) {
        xLabels.add(String.format(Locale.US, SparkleHelper.getMonthYearDateFromUTC(datapoints.get(i).timestamp), i));
    }

    // formatting
    boolean isLargeValue = maxVal >= 1000f;
    chart = RaraHelper.getFormattedLineChart(context, chart, this, xLabels, isLargeValue, 12, false);
    chart.setData(dataFinal);
    chart.invalidate();
}
 
开发者ID:lloydtorres,项目名称:stately,代码行数:62,代码来源:TrendsRecyclerAdapter.java


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