// Path: app/src/main/java/com/w9jds/marketbot/classes/models/MarketHistory.java
// public final class MarketHistory {
// 
//     private int orderCount;
//     private double lowPrice;
//     private double highPrice;
//     private double averagePrice;
//     private long volume;
//     private long recordDate;
// 
//     public int getOrderCount() {
//         return orderCount;
//     }
// 
//     public double getAveragePrice() {
//         return averagePrice;
//     }
// 
//     public double getHighPrice() {
//         return highPrice;
//     }
// 
//     public double getLowPrice() {
//         return lowPrice;
//     }
// 
//     public long getVolume() {
//         return volume;
//     }
// 
//     public long getRecordDate() {
//         return recordDate;
//     }
// 
//     public static class Builder {
// 
//         private int orderCount;
//         private double lowPrice;
//         private double highPrice;
//         private double averagePrice;
//         private long volume;
//         private long recordDate;
// 
//         public Builder setOrderCount(int orderCount) {
//             this.orderCount = orderCount;
//             return this;
//         }
// 
//         public Builder setAveragePrice(double averagePrice) {
//             this.averagePrice = averagePrice;
//             return this;
//         }
// 
//         public Builder setHighPrice(double highPrice) {
//             this.highPrice = highPrice;
//             return this;
//         }
// 
//         public Builder setLowPrice(double lowPrice) {
//             this.lowPrice = lowPrice;
//             return this;
//         }
// 
//         public Builder setRecordDate(long recordDate) {
//             this.recordDate = recordDate;
//             return this;
//         }
// 
//         public Builder setVolume(long volume) {
//             this.volume = volume;
//             return this;
//         }
// 
//         public MarketHistory build() {
//             MarketHistory history = new MarketHistory();
//             history.orderCount = orderCount;
//             history.lowPrice = lowPrice;
//             history.highPrice = highPrice;
//             history.averagePrice = averagePrice;
//             history.volume = volume;
//             history.recordDate = recordDate;
// 
//             return history;
//         }
//     }
// }
// 
// Path: app/src/main/java/com/w9jds/marketbot/utils/NumberUtils.java
// public class NumberUtils {
// 
//     private static char[] c = new char[]{'k', 'M', 'B', 'T', 'P', 'E', 'Z', 'Y'};
// 
//     public static String shortened(double n, int iteration) {
//         double d = ((long) n / 100) / 10.0;
//         boolean isRound = (d * 10) % 10 == 0;
//         return (d < 1000 ? ((d > 99.9 || isRound || (!isRound && d > 9.99) ?
//                 (int) d * 10 / 10 : d + "") + "" + c[iteration]) : shortened(d, iteration + 1));
//     }
// }


import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.mikephil.charting.charts.CombinedChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.CandleData;
import com.github.mikephil.charting.data.CandleDataSet;
import com.github.mikephil.charting.data.CandleEntry;
import com.github.mikephil.charting.data.CombinedData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.w9jds.marketbot.R;
import com.w9jds.marketbot.classes.models.MarketHistory;
import com.w9jds.marketbot.utils.NumberUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import butterknife.Bind;
import butterknife.ButterKnife;
import rx.functions.Action1;
import rx.subjects.BehaviorSubject;
import rx.subscriptions.CompositeSubscription;
//        xAxis.setDrawLabels(false);

        return view;
    }

    private BarData generateOrderBarData(List<MarketHistory> historyEntries) {

        SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());

        int size = historyEntries.size();
        List<BarEntry> entries = new ArrayList<>(size);
        List<String> xAxis = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            MarketHistory history = historyEntries.get(i);
            Date recordDate = new Date(history.getRecordDate());

            xAxis.add(format.format(recordDate));
            entries.add(new BarEntry((float) history.getOrderCount(), i));
        }

        BarDataSet set = new BarDataSet(entries, "Order Count");
        set.setColor(Color.parseColor("#99FF99"));
//        set.setValueTextSize(0f);

        set.setDrawValues(false);

        set.setAxisDependency(YAxis.AxisDependency.RIGHT);
        return new BarData(xAxis, set);
    }

// Path: app/src/main/java/com/w9jds/marketbot/classes/models/MarketHistory.java
// public final class MarketHistory {
// 
//     private int orderCount;
//     private double lowPrice;
//     private double highPrice;
//     private double averagePrice;
//     private long volume;
//     private long recordDate;
// 
//     public int getOrderCount() {
//         return orderCount;
//     }
// 
//     public double getAveragePrice() {
//         return averagePrice;
//     }
// 
//     public double getHighPrice() {
//         return highPrice;
//     }
// 
//     public double getLowPrice() {
//         return lowPrice;
//     }
// 
//     public long getVolume() {
//         return volume;
//     }
// 
//     public long getRecordDate() {
//         return recordDate;
//     }
// 
//     public static class Builder {
// 
//         private int orderCount;
//         private double lowPrice;
//         private double highPrice;
//         private double averagePrice;
//         private long volume;
//         private long recordDate;
// 
//         public Builder setOrderCount(int orderCount) {
//             this.orderCount = orderCount;
//             return this;
//         }
// 
//         public Builder setAveragePrice(double averagePrice) {
//             this.averagePrice = averagePrice;
//             return this;
//         }
// 
//         public Builder setHighPrice(double highPrice) {
//             this.highPrice = highPrice;
//             return this;
//         }
// 
//         public Builder setLowPrice(double lowPrice) {
//             this.lowPrice = lowPrice;
//             return this;
//         }
// 
//         public Builder setRecordDate(long recordDate) {
//             this.recordDate = recordDate;
//             return this;
//         }
// 
//         public Builder setVolume(long volume) {
//             this.volume = volume;
//             return this;
//         }
// 
//         public MarketHistory build() {
//             MarketHistory history = new MarketHistory();
//             history.orderCount = orderCount;
//             history.lowPrice = lowPrice;
//             history.highPrice = highPrice;
//             history.averagePrice = averagePrice;
//             history.volume = volume;
//             history.recordDate = recordDate;
// 
//             return history;
//         }
//     }
// }
// 
// Path: app/src/main/java/com/w9jds/marketbot/utils/NumberUtils.java
// public class NumberUtils {
// 
//     private static char[] c = new char[]{'k', 'M', 'B', 'T', 'P', 'E', 'Z', 'Y'};
// 
//     public static String shortened(double n, int iteration) {
//         double d = ((long) n / 100) / 10.0;
//         boolean isRound = (d * 10) % 10 == 0;
//         return (d < 1000 ? ((d > 99.9 || isRound || (!isRound && d > 9.99) ?
//                 (int) d * 10 / 10 : d + "") + "" + c[iteration]) : shortened(d, iteration + 1));
//     }
// }


// Path: app/src/main/java/com/w9jds/marketbot/ui/fragments/MarketHistoryTab.java
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.github.mikephil.charting.charts.CombinedChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.CandleData;
import com.github.mikephil.charting.data.CandleDataSet;
import com.github.mikephil.charting.data.CandleEntry;
import com.github.mikephil.charting.data.CombinedData;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.w9jds.marketbot.R;
import com.w9jds.marketbot.classes.models.MarketHistory;
import com.w9jds.marketbot.utils.NumberUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import butterknife.Bind;
import butterknife.ButterKnife;
import rx.functions.Action1;
import rx.subjects.BehaviorSubject;
import rx.subscriptions.CompositeSubscription;

//        xAxis.setDrawLabels(false);

        return view;
    }

    private BarData generateOrderBarData(List<MarketHistory> historyEntries) {

        SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());

        int size = historyEntries.size();
        List<BarEntry> entries = new ArrayList<>(size);
        List<String> xAxis = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            MarketHistory history = historyEntries.get(i);
            Date recordDate = new Date(history.getRecordDate());

            xAxis.add(format.format(recordDate));
            entries.add(new BarEntry((float) history.getOrderCount(), i));
        }

        BarDataSet set = new BarDataSet(entries, "Order Count");
        set.setColor(Color.parseColor("#99FF99"));
//        set.setValueTextSize(0f);

        set.setDrawValues(false);

        set.setAxisDependency(YAxis.AxisDependency.RIGHT);
        return new BarData(xAxis, set);
    }

    private LineData generateAverageLineData(List<MarketHistory> historyEntries) {