private LineDataSet prepareInitData(@NonNull LineChart chart, @NonNull List<Entry> entries) { final LineDataSet set = new LineDataSet(entries, "Accuracy"); set.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); set.setAxisDependency(YAxis.AxisDependency.LEFT); set.setLineWidth(2F); set.setDrawCircleHole(false); set.setDrawCircles(false); set.setHighlightEnabled(false); set.setDrawFilled(true); final LineData group = new LineData(set); group.setDrawValues(false); chart.setData(group); return set; }
protected LineData generateLineData() { ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function"); ds1.setLineWidth(2f); ds2.setLineWidth(2f); ds1.setDrawCircles(false); ds2.setDrawCircles(false); ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]); // load DataSets from textfiles in assets folders sets.add(ds1); sets.add(ds2); LineData d = new LineData(sets); d.setValueTypeface(tf); return d; }
private LineData generateLineData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<Entry>(); for (int index = 0; index < itemcount; index++) entries.add(new Entry(index + 0.5f, getRandom(15, 5))); LineDataSet set = new LineDataSet(entries, "Line DataSet"); set.setColor(Color.rgb(240, 238, 70)); set.setLineWidth(2.5f); set.setCircleColor(Color.rgb(240, 238, 70)); set.setCircleRadius(5f); set.setFillColor(Color.rgb(240, 238, 70)); set.setMode(LineDataSet.Mode.CUBIC_BEZIER); set.setDrawValues(true); set.setValueTextSize(10f); set.setValueTextColor(Color.rgb(240, 238, 70)); set.setAxisDependency(YAxis.AxisDependency.LEFT); d.addDataSet(set); return d; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_linechart_noseekbar); mChart = (LineChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); mChart.setDrawGridBackground(false); mChart.getDescription().setEnabled(false); // add an empty data object mChart.setData(new LineData()); // mChart.getXAxis().setDrawLabels(false); // mChart.getXAxis().setDrawGridLines(false); mChart.invalidate(); }
private void removeLastEntry() { LineData data = mChart.getData(); if (data != null) { ILineDataSet set = data.getDataSetByIndex(0); if (set != null) { Entry e = set.getEntryForXValue(set.getEntryCount() - 1, Float.NaN); data.removeEntry(e, 0); // or remove by index // mData.removeEntryByXValue(xIndex, dataSetIndex); data.notifyDataChanged(); mChart.notifyDataSetChanged(); mChart.invalidate(); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_colored_lines); mCharts[0] = (LineChart) findViewById(R.id.chart1); mCharts[1] = (LineChart) findViewById(R.id.chart2); mCharts[2] = (LineChart) findViewById(R.id.chart3); mCharts[3] = (LineChart) findViewById(R.id.chart4); mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf"); for (int i = 0; i < mCharts.length; i++) { LineData data = getData(36, 100); data.setValueTypeface(mTf); // add some transparency to the color with "& 0x90FFFFFF" setupChart(mCharts[i], data, mColors[i % mColors.length]); } }
private void setData() { RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll(); RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue"); set.setMode(LineDataSet.Mode.CUBIC_BEZIER); set.setLabel("Realm LineDataSet"); set.setDrawCircleHole(false); set.setColor(ColorTemplate.rgb("#FF5722")); set.setCircleColor(ColorTemplate.rgb("#FF5722")); set.setLineWidth(1.8f); set.setCircleRadius(3.6f); ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(set); // add the dataset // create a data object with the dataset list LineData data = new LineData(dataSets); styleData(data); // set data mChart.setData(data); mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart); }
private void setData(int count, float range) { ArrayList<Entry> entries = new ArrayList<Entry>(); for (int i = 0; i < count; i++) { float xVal = (float) (Math.random() * range); float yVal = (float) (Math.random() * range); entries.add(new Entry(xVal, yVal)); } // sort by x-value Collections.sort(entries, new EntryXComparator()); // create a dataset and give it a type LineDataSet set1 = new LineDataSet(entries, "DataSet 1"); set1.setLineWidth(1.5f); set1.setCircleRadius(4f); // create a data object with the datasets LineData data = new LineData(set1); // set data mChart.setData(data); }
private void bindActivityChart() { LineData lineData = generateActivityLineData(); lineChart.setData(lineData); int maxYData = (int) (Math.ceil(lineData.getYMax()) + 7200); lineChart.getAxisLeft().setAxisMaximum(maxYData); long referenceTime = new DateTime(stats.endDate).minusDays(6).getMillis(); lineChart.getXAxis() .setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime)); CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime); lineChart.setMarker(customMarkerView); customMarkerView.setChartView(lineChart); lineChart.animateX(1500, Easing.EasingOption.Linear); }
private LineData generateA1cData() { ArrayList<String> xVals = new ArrayList<>(); ArrayList<Entry> yVals = new ArrayList<>(); for (int i = 0; i < presenter.getA1cReadings().size(); i++) { float val = Float.parseFloat(presenter.getA1cReadings().get(i).toString()); yVals.add(new Entry(val, i)); } xVals.clear(); for (int i = 0; i < presenter.getA1cReadingsDateTime().size(); i++) { String date = presenter.convertDate(presenter.getA1cReadingsDateTime().get(i)); xVals.add(date + ""); } // create a data object with the datasets return new LineData(xVals, generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_HB1AC))); }
private LineData generateKetonesData() { List<String> xVals = new ArrayList<>(); List<Entry> yVals = new ArrayList<>(); for (int i = 0; i < presenter.getKetonesReadings().size(); i++) { float val = Float.parseFloat(presenter.getKetonesReadings().get(i).toString()); yVals.add(new Entry(val, i)); } xVals.clear(); for (int i = 0; i < presenter.getKetonesReadingsDateTime().size(); i++) { String date = presenter.convertDate(presenter.getKetonesReadingsDateTime().get(i)); xVals.add(date + ""); } // create a data object with the datasets return new LineData(xVals, generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_ketones))); }
private LineData generateWeightData() { List<String> xVals = new ArrayList<>(); List<Entry> yVals = new ArrayList<>(); for (int i = 0; i < presenter.getWeightReadings().size(); i++) { float val = Float.parseFloat(presenter.getWeightReadings().get(i).toString()); yVals.add(new Entry(val, i)); } xVals.clear(); for (int i = 0; i < presenter.getWeightReadingsDateTime().size(); i++) { String date = presenter.convertDate(presenter.getWeightReadingsDateTime().get(i)); xVals.add(date + ""); } // create a data object with the datasets return new LineData(xVals, generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_weight))); }
private LineData generateCholesterolData() { List<String> xVals = new ArrayList<>(); List<Entry> yVals = new ArrayList<>(); for (int i = 0; i < presenter.getCholesterolReadings().size(); i++) { float val = Float.parseFloat(presenter.getCholesterolReadings().get(i).toString()); yVals.add(new Entry(val, i)); } xVals.clear(); for (int i = 0; i < presenter.getCholesterolReadingsDateTime().size(); i++) { String date = presenter.convertDate(presenter.getCholesterolReadingsDateTime().get(i)); xVals.add(date + ""); } // create a data object with the datasets return new LineData(xVals, generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_cholesterol))); }
/** * generates a random ChartData object with just one DataSet * * @return */ private LineData generateDataLine(float[] datas, String type) { ArrayList<Entry> entryList = new ArrayList<Entry>(); for (int i = 0; i < datas.length; i++) { entryList.add(new Entry(i, datas[i])); } LineDataSet d1 = new LineDataSet(entryList, "DataSet :" + type); d1.setLineWidth(2.5f); Random r = new Random(); d1.setHighLightColor(Color.rgb(r.nextInt(256), r.nextInt(256), r.nextInt(256))); d1.setDrawValues(false); ArrayList<ILineDataSet> sets = new ArrayList<>(); sets.add(d1); return new LineData(sets); }
private LineData buildLineData(List<Entry> seniors, List<Entry> engineer, List<Entry> juniors, String[] jobTitles ){ List<ILineDataSet> sets = new ArrayList<>(); if (!seniors.isEmpty()){ LineDataSet dSenior = buildLineDataSet(seniors, jobTitles[0]); sets.add(dSenior); } if (!engineer.isEmpty()){ LineDataSet dEngineer = buildLineDataSet(engineer, jobTitles[1]); dEngineer.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); dEngineer.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]); sets.add(dEngineer); } if (!juniors.isEmpty()) { LineDataSet dJunior = buildLineDataSet(juniors, jobTitles[2]); dJunior.setColor(ColorTemplate.VORDIPLOM_COLORS[2]); dJunior.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]); sets.add(dJunior);//add data } return new LineData(sets); }
private LineData getData(ArrayList<Entry> yVals) { LineDataSet set1 = new LineDataSet(yVals, ""); set1.setLineWidth(1.45f); set1.setColor(Color.argb(240, 255, 255, 255)); set1.setCircleColor(Color.WHITE); set1.setHighLightColor(Color.WHITE); set1.setFillColor(getResources().getColor(R.color.chartFilled)); set1.setDrawCircles(false); set1.setDrawValues(false); set1.setDrawFilled(true); set1.setFillFormatter(new IFillFormatter() { @Override public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { return priceChart.getAxisLeft().getAxisMinimum(); } }); LineData data = new LineData(set1); return data; }
@BindingAdapter({"bind:items"}) public static void populateDiagram(LineChart view, List<SingleValue> items) { if (null == items || items.size() == 0) { return; } List<Entry> entries = new ArrayList<>(); for (int i = 0; i < items.size(); i++) { final SingleValue item = items.get(i); final Entry entry = new Entry(i, (float) item.getValue(), item); entries.add(entry); } LineDataSet dataSet = new LineDataSet(entries, view.getContext().getString(R.string.currency_value)); LineData lineData = new LineData(dataSet); formatXAxisLabels(view, items); view.setData(lineData); view.invalidate(); }
private void addEntry(String label, int value) { LineData data = chart.getData(); if (data != null) { int index; if (label.equals(pm1Label)) { index = 0; } else if (label.equals(pm25Label)) { index = 1; } else { index = 2; } ILineDataSet set = data.getDataSetByIndex(index); if (set == null) { set = createSet(label); data.addDataSet(set); } data.addEntry(new Entry(set.getEntryCount(), value), index); } }
@Override public void update(ParticulateMatterSample sample) { if (!ready) { return; } LineData data = chart.getData(); addEntry(pm1Label, sample.getPm1_0()); addEntry(pm25Label, sample.getPm2_5()); addEntry(pm10Label, sample.getPm10()); data.notifyDataChanged(); // let the chart know it's data has changed chart.notifyDataSetChanged(); // limit the number of visible entries chart.setVisibleXRangeMaximum(120); // move to the latest entry chart.moveViewToX(data.getEntryCount()); }
/** * Adds the main data set for all times and the data set for the progression of record best * times among all times. The progression of best times are marked in a different color to the * main line of all time using circles lined with a dashed line. This will appear to connect * the lowest troughs along the main line of all times. * * @param chartData The chart data to which to add the new data sets. * @param allLabel The label of the all-times line. * @param allColor The color of the all-times line. * @param bestLabel The label of the best-times line. * @param bestColor The color of the best-times line. */ private void addMainDataSets(LineData chartData, String allLabel, int allColor, String bestLabel, int bestColor) { // Main data set for all solve times. chartData.addDataSet(createDataSet(allLabel, allColor)); // Data set to show the progression of best times along the main line of all times. final LineDataSet bestDataSet = createDataSet(bestLabel, bestColor); bestDataSet.enableDashedLine(3f, 6f, 0f); bestDataSet.setDrawCircles(true); bestDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP); bestDataSet.setCircleColor(bestColor); bestDataSet.setDrawValues(false); bestDataSet.setValueTextColor(bestColor); bestDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP); bestDataSet.setValueFormatter(new TimeChartValueFormatter()); chartData.addDataSet(bestDataSet); }
/** * Adds the data set for the average-of-N (AoN) times and the corresponding data set for the * single best average time for that value of "N". The best AoN times are not shown as a * progression; only one time is shown and it superimposed on its main AoN line, rendered in * the same color as a circle and with the value drawn on the chart. * * @param chartData The chart data to which to add the new data sets. * @param label The label of the AoN line and best AoN time marker. * @param color The color of the AoN line and best AoN time marker. */ private void addAoNDataSets(LineData chartData, String label, int color) { // Main AoN data set for all AoN times for one value of "N". chartData.addDataSet(createDataSet(label, color)); // Data set for the single best AoN time for this "N". final LineDataSet bestAoNDataSet = createDataSet(label, color); bestAoNDataSet.setDrawCircles(true); bestAoNDataSet.setCircleRadius(BEST_TIME_CIRCLE_RADIUS_DP); bestAoNDataSet.setCircleColor(color); // Drawing the value of the best AoN time for each "N" seems like it would be a good idea, // but the values are really hard because they appear over other chart lines and sometimes // over the values drawn for the best time progression. Disabling them is no great loss, // as the statistics table shows the same values, anyway. Just showing a circle to mark // the best AoN time looks well enough on its own. bestAoNDataSet.setDrawValues(false); // bestAoNDataSet.setValueTextColor(color); // bestAoNDataSet.setValueTextSize(BEST_TIME_VALUES_TEXT_SIZE_DP); // bestAoNDataSet.setValueFormatter(new TimeChartValueFormatter()); chartData.addDataSet(bestAoNDataSet); }
private void addEntry(int db) { LineData data = mLineChart.getData(); if (data != null) { ILineDataSet set = data.getDataSetByIndex(0); // set.addEntry(...); // can be called as well if (set == null) { set = createSet(); data.addDataSet(set); } data.addEntry(new Entry(set.getEntryCount(), db), 0); data.notifyDataChanged(); // let the chart know it's data has changed mLineChart.notifyDataSetChanged(); // limit the number of visible entries mLineChart.setVisibleXRangeMaximum(60); //mLineChart.setVisibleYRange(30, AxisDependency.LEFT); // move to the latest entry mLineChart.moveViewToX(data.getEntryCount()); } }
public LineData createLineChartData() { mDashboardHelper = new DashboardHelper(getActivity()); HashMap<String, ArrayList> holder = mDashboardHelper.generateBeaconTotalDurationPerDayMap(); ArrayList<String> xValues = holder.get("dayOfThisMonth"); ArrayList<Entry> entries = holder.get("totalDurationPerDay"); LineDataSet set = new LineDataSet(entries, ""); set.setCircleColor(0xFF2196f3); set.setCircleRadius(4f); set.setDrawCircleHole(false); set.setColor(0xFF2196f3); set.setLineWidth(2f); set.setDrawValues(false); return new LineData(xValues, set); }
private void initWithDummyData() { ArrayList<String> xVals = new ArrayList<String>(); for (int i = 0; i < 24; i++) { xVals.add((i) + ":00"); } ArrayList<Entry> yVals = new ArrayList<Entry>(); // create a dataset and give it a type (0) LineDataSet set1 = new LineDataSet(yVals, "DataSet"); set1.setLineWidth(3f); set1.setCircleRadius(5f); ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>(); dataSets.add(set1); // add the datasets // create a data object with the datasets LineData data = new LineData(xVals, dataSets); mChart.setData(data); }
private LineData generateLineData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<Entry>(); for (int index = 0; index < itemcount; index++) entries.add(new Entry(getRandom(15, 10), index)); LineDataSet set = new LineDataSet(entries, "Line DataSet"); set.setColor(Color.rgb(240, 238, 70)); set.setLineWidth(2.5f); set.setCircleColor(Color.rgb(240, 238, 70)); set.setCircleRadius(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); return d; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_linechart_noseekbar); mChart = (LineChart) findViewById(R.id.chart1); mChart.setOnChartValueSelectedListener(this); mChart.setDrawGridBackground(false); mChart.setDescription(""); // add an empty data object mChart.setData(new LineData()); // mChart.getXAxis().setDrawLabels(false); // mChart.getXAxis().setDrawGridLines(false); mChart.invalidate(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_colored_lines); mCharts[0] = (LineChart) findViewById(R.id.chart1); mCharts[1] = (LineChart) findViewById(R.id.chart2); mCharts[2] = (LineChart) findViewById(R.id.chart3); mCharts[3] = (LineChart) findViewById(R.id.chart4); mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf"); LineData data = getData(36, 100); data.setValueTypeface(mTf); for (int i = 0; i < mCharts.length; i++) // add some transparency to the color with "& 0x90FFFFFF" setupChart(mCharts[i], data, mColors[i % mColors.length]); }
/** * Called in the UI thread. */ private void pulse() { addEntries(); LineData historyData = (LineData) mStepsPerMinuteHistoryChart.getData(); if (historyData == null) { return; } historyData.notifyDataChanged(); mTotalStepsData.notifyDataSetChanged(); mStepsPerMinuteData.notifyDataSetChanged(); mStepsPerMinuteHistoryChart.notifyDataSetChanged(); renderCharts(); // have to enable it again and again to keep it measureing GBApplication.deviceService().onEnableRealtimeHeartRateMeasurement(true); }
private LineData getLineData(List<String> xVals, List<Entry> lineEntries) { final LineDataSet dataSet = new LineDataSet(lineEntries, getContext().getString(R.string.moving_average)); final int color = ContextCompat.getColor(getContext(), R.color.brown); dataSet.setColor(color); dataSet.setLineWidth(2.5f); dataSet.setCircleColor(color); dataSet.setFillColor(color); dataSet.setDrawValues(true); dataSet.setValueTextSize(12); dataSet.setValueTextColor(color); // Format the value labels to two decimal places dataSet.setValueFormatter(new LineChartValueFormatter()); return new LineData(xVals, dataSet); }
private LineData generateLineData() { LineData d = new LineData(); ArrayList<Entry> entries = new ArrayList<Entry>(); for (int index = 0; index < 3; index++) entries.add(new Entry(index + 0.5f, UtilsRG.getRandomNumberInRange(0, 1))); LineDataSet set = new LineDataSet(entries, "Line DataSet"); set.setColor(R.color.colorPrimaryLight); set.setLineWidth(2.5f); set.setCircleColor(R.color.colorPrimaryLight); set.setCircleRadius(5f); set.setFillColor(R.color.colorPrimaryLight); set.setMode(LineDataSet.Mode.CUBIC_BEZIER); set.setDrawValues(true); set.setValueTextSize(10f); set.setValueTextColor(R.color.colorPrimaryLight); set.setAxisDependency(YAxis.AxisDependency.LEFT); d.addDataSet(set); return d; }
/** * Create dataset to be displayed in chart legend * @return CombinedData representing dummy data for a legend */ private CombinedData buildDummyDataForLegend(){ CombinedData combinedData = new CombinedData(); float xIndex = 1.5f; float close = 13; float open = 26f; float shadowH = 30.33f; float shadowL = -2.05f; float average = 20f; CandleData candleData = generateCandleData(xIndex, shadowH, shadowL, open, close, "EMU HI/LO" ); ScatterData scatterData = generateScatterData(average, "EMU Mean"); LineData s1 = generateOceanHiLo(close, open, "Ocean HI/LO"); combinedData.setData(s1); combinedData.setData(candleData); combinedData.setData(scatterData); return combinedData; }
/** * Generate line data line data. * * @return the line data */ protected LineData generateLineData() { ArrayList<ILineDataSet> sets = new ArrayList<ILineDataSet>(); LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function"); LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function"); ds1.setLineWidth(2f); ds2.setLineWidth(2f); ds1.setDrawCircles(false); ds2.setDrawCircles(false); ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]); // load DataSets from textfiles in assets folders sets.add(ds1); sets.add(ds2); LineData d = new LineData(sets); d.setValueTypeface(tf); return d; }
public void updateChart(float value, int index) { LineData data = messagesChart.getData(); ILineDataSet set = data.getDataSetByIndex(index); if (set == null) { set = createSet(getLineColor(index)); data.addDataSet(set); } data.addEntry(new Entry(set.getEntryCount(), value), index); data.notifyDataChanged(); messagesChart.notifyDataSetChanged(); messagesChart.setVisibleXRangeMaximum(getVisibleRange().getRange()); messagesChart.moveViewToX(data.getEntryCount()); }
@Override public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { float fillMin = 0f; float chartMaxY = dataProvider.getYChartMax(); float chartMinY = dataProvider.getYChartMin(); LineData data = dataProvider.getLineData(); if (dataSet.getYMax() > 0 && dataSet.getYMin() < 0) { fillMin = 0f; } else { float max, min; if (data.getYMax() > 0) max = 0f; else max = chartMaxY; if (data.getYMin() < 0) min = 0f; else min = chartMinY; fillMin = dataSet.getYMin() >= 0 ? min : max; } return fillMin; }
@Override public void drawData(Canvas c) { int width = (int) mViewPortHandler.getChartWidth(); int height = (int) mViewPortHandler.getChartHeight(); if (mDrawBitmap == null || (mDrawBitmap.get().getWidth() != width) || (mDrawBitmap.get().getHeight() != height)) { if (width > 0 && height > 0) { mDrawBitmap = new WeakReference<Bitmap>(Bitmap.createBitmap(width, height, mBitmapConfig)); mBitmapCanvas = new Canvas(mDrawBitmap.get()); } else return; } mDrawBitmap.get().eraseColor(Color.TRANSPARENT); LineData lineData = mChart.getLineData(); for (ILineDataSet set : lineData.getDataSets()) { if (set.isVisible()) drawDataSet(c, set); } c.drawBitmap(mDrawBitmap.get(), 0, 0, mRenderPaint); }