private void setData(int start, int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((start + i) + "日"); } ArrayList<Entry> vals1 = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { vals1.add(new Entry(TurnControl.PunchPerDay[9 - i], i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(vals1, "近期打卡情况"); set1.setDrawCubic(true); set1.setCubicIntensity(0.2f); set1.setDrawFilled(true); set1.setDrawCircles(true); set1.setLineWidth(2f); set1.setCircleSize(5f); set1.setHighLightColor(Color.rgb(244, 117, 117)); set1.setColor(Color.rgb(104, 241, 175)); set1.setFillColor(ColorTemplate.getHoloBlue()); // 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); }
private void setData(int count, float range) { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < count; i++) { xVals.add((i % 30) + "/" + (i % 12) + "/14"); } ArrayList<Entry> yVals = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float mult = (range + 1); float val = (float) (Math.random() * mult) + 3; // + (float) // ((mult * // 0.1) / 10); yVals.add(new Entry(val, i)); } // create a dataset and give it a type LineDataSet set1 = new LineDataSet(yVals, "DataSet 1"); set1.setLineWidth(1.5f); set1.setCircleSize(4f); // create a data object with the datasets LineData data = new LineData(xVals, set1); // set data mChart.setData(data); }
public void formatDataSet(LineDataSet set, @ColorInt int color) { set.setColor(color); set.setLineWidth(2.5f); set.setCircleColor(color); set.setCircleSize(5f); set.setFillColor(color); set.setDrawCubic(true); set.setValueTextSize(10f); set.setDrawValues(false); set.setDrawCircles(false); set.setValueTextColor(color); set.setDrawFilled(true); }
private LineDataSet createSet() { LineDataSet set = new LineDataSet(null, "Dynamic Data"); set.setAxisDependency(YAxis.AxisDependency.LEFT); set.setColor(ColorTemplate.getHoloBlue()); set.setCircleColor(Color.WHITE); set.setLineWidth(2f); set.setCircleSize(4f); set.setFillAlpha(65); set.setFillColor(ColorTemplate.getHoloBlue()); set.setHighLightColor(Color.rgb(244, 117, 117)); set.setValueTextColor(Color.WHITE); set.setValueTextSize(9f); set.setDrawValues(false); return set; }
private LineDataSet createSet() { LineDataSet set = new LineDataSet(null, "Realtime Beschleunigungskraefte"); set.setDrawCubic(true); set.setCubicIntensity(0.2f); set.setAxisDependency(YAxis.AxisDependency.LEFT); set.setColor(ColorTemplate.getHoloBlue()); set.setCircleColor(Color.BLACK); set.setLineWidth(2f); set.setCircleSize(4f); set.setFillAlpha(65); set.setFillColor(ColorTemplate.getHoloBlue()); set.setHighLightColor(Color.rgb(244, 117, 117)); set.setValueTextColor(Color.BLACK); set.setValueTextSize(10f); return set; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_status, container, false); // TODO Need lot of design changes in chart // TODO Have to update LineChart with CombineChart to display LineChart with BarChart mChart = (LineChart) view.findViewById(R.id.chartInsight); mChart.setDescription(""); mChart.setBackgroundColor(Color.WHITE); mChart.setDrawGridBackground(false); LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<>(); for (int index = 0; index < 12; index++) entries.add(new Entry(getRandom(25, 10), index)); LineDataSet set = new LineDataSet(entries, "DataSet1"); set.setColor(Color.rgb(240, 238, 70)); set.setLineWidth(2.5f); set.setCircleColor(Color.rgb(240, 238, 70)); set.setCircleSize(5f); set.setFillColor(Color.rgb(240, 238, 70)); set.setDrawCubic(true); set.setDrawValues(true); set.setValueTextSize(10f); set.setValueTextColor(Color.rgb(240, 238, 70)); for (int index = 0; index < 12; index++) entries.add(new Entry(getRandom(25, 10), index)); LineDataSet set2 = new LineDataSet(entries, "DataSet2"); set.setColor(Color.rgb(240, 238, 70)); set.setLineWidth(2.5f); set.setCircleColor(Color.rgb(240, 238, 70)); set.setCircleSize(5f); set.setFillColor(Color.rgb(240, 238, 70)); set.setDrawCubic(true); set.setDrawValues(true); set.setValueTextSize(10f); set.setValueTextColor(Color.rgb(240, 238, 70)); set.setAxisDependency(YAxis.AxisDependency.LEFT); d.addDataSet(set); d.addDataSet(set2); mChart.setData(d); mChart.setDescription("Fuel Insight"); mChart.animateXY(2000, 2000); mChart.invalidate(); // String[] projection = { FuelContract.COLUMN_AMOUNT, FuelContract.COLUMN_ID }; // Cursor fuelData = // inflater.getContext().getContentResolver().query(FuelProvider.FUEL_CONTENT_URI, projection, // null, null, null); // while (fuelData.getCount()!=0) { // fuelData.moveToNext(); // Log.i("FuelData", "ID: " + fuelData.getString(1) + " Amount: " + // fuelData.getString(0)); // } return view; }