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


Java LineDataSet.setColors方法代码示例

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


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

示例1: setLineDataSetStyle

import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
private void setLineDataSetStyle(LineDataSet dataSet) {
    dataSet.setColors(new int[] {R.color.accent}, getContext());
    dataSet.setCircleColors(new int[] {R.color.accent}, getContext());
    dataSet.setLineWidth(2f);
    dataSet.setCircleRadius(5);
    dataSet.setDrawValues(false);
}
 
开发者ID:AIDEA775,项目名称:UNCmorfi,代码行数:8,代码来源:CounterFragment.java

示例2: onCreate

import com.github.mikephil.charting.data.LineDataSet; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_main);

    Bundle extras = this.getIntent().getExtras();
    if (extras != null && extras.getBoolean("stop", true)) {
        this.finish();
    }
    gsonstringobject();
    // Inflate the layout that we're using for the watch face
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    myLayout = inflater.inflate(R.layout.wear_drip_watchface_layout, null);


    LineChart lineChart = (LineChart) myLayout.findViewById(R.id.chart);
    lineChart.setDescription("");
    lineChart.setNoDataTextDescription("You need to provide data for the chart.");

    ArrayList<Entry> entries = new ArrayList<>();
    entries.add(new Entry(4f, 0));
    entries.add(new Entry(8f, 1));
    entries.add(new Entry(6f, 2));
    entries.add(new Entry(2f, 3));
    entries.add(new Entry(18f, 4));
    entries.add(new Entry(9f, 5));

    LineDataSet dataset = new LineDataSet(entries, "# of Calls");

    ArrayList<String> labels = new ArrayList<String>();
    labels.add("January");
    labels.add("February");
    labels.add("March");
    labels.add("April");
    labels.add("May");
    labels.add("June");

    LineData data = new LineData(labels, dataset);
    //dataset.setColors(ColorTemplate.COLORFUL_COLORS);
    //dataset.setColors(ColorTemplate.VORDIPLOM_COLORS);
    //dataset.setColors(ColorTemplate.JOYFUL_COLORS);
    dataset.setColors(ColorTemplate.LIBERTY_COLORS);
    //dataset.setColors(ColorTemplate.PASTEL_COLORS);
    dataset.setDrawCubic(true);
    dataset.setDrawFilled(true);
    dataset.setDrawCircles(false);
    dataset.setDrawValues(false);

    lineChart.setPinchZoom(false);
    lineChart.setDragEnabled(false);
    lineChart.setScaleEnabled(false);
    lineChart.setDrawGridBackground(false);
    lineChart.setTouchEnabled(false);
    lineChart.setData(data);
    lineChart.animateY(5000);

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

    XAxis xl = lineChart.getXAxis();
    xl.setDrawGridLines(true);
    xl.setEnabled(false);

    YAxis leftAxis = lineChart.getAxisLeft();
    leftAxis.setDrawGridLines(false);

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


}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:73,代码来源:MainActivity.java

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

示例4: 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.setColors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。