private XYMultipleSeriesRenderer getCostsRenderer() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    int renderCount = 0; // which color to use for the current render
    for (Calculator curCalculator : calculatorList) {
      XYSeriesRenderer existingCosts = new XYSeriesRenderer();
      existingCosts.setColor(COLOR_LIST[renderCount]);
      existingCosts.setPointStyle(PointStyle.POINT);
      existingCosts.setLineWidth(3.0f);
      renderer.addSeriesRenderer(existingCosts);

      renderCount = incrementRenderCount(renderCount);

      XYSeriesRenderer solarCosts = new XYSeriesRenderer();
      solarCosts.setColor(COLOR_LIST[renderCount]);
      solarCosts.setPointStyle(PointStyle.POINT);
      solarCosts.setLineWidth(3.0f);
      renderer.addSeriesRenderer(solarCosts);

      renderCount = incrementRenderCount(renderCount);
    }

    renderer.setAxesColor(Color.BLACK);
    renderer.setLabelsColor(Color.BLACK);
    renderer.setXLabelsColor(Color.BLACK);
    renderer.setYLabelsColor(0, Color.BLACK);
    renderer.setMarginsColor(Color.WHITE);
    renderer.setYLabels(
        16); // Needs to be about double what we want - not sure why...it works as expected on the
             // other graph - TP
    renderer.setXTitle("Year");
    renderer.setYTitle("Annual Electricity Cost ($)");
    renderer.setPanEnabled(false); // don't think this is working as expected
    renderer.setZoomEnabled(false); // don't think this is working as expected
    return renderer;
  }
 protected void setChartSettings(
     XYMultipleSeriesRenderer mXYMultipleSeriesRenderer,
     String xTitle,
     String yTitle,
     double xMin,
     double xMax,
     double yMin,
     double yMax,
     int axesColor,
     int labelsColor) {
   // 有关对图表的渲染可参看api文档
   mXYMultipleSeriesRenderer.setChartTitle(title);
   mXYMultipleSeriesRenderer.setXTitle(xTitle);
   mXYMultipleSeriesRenderer.setYTitle(yTitle);
   mXYMultipleSeriesRenderer.setXAxisMin(xMin);
   mXYMultipleSeriesRenderer.setAxisTitleTextSize(30);
   mXYMultipleSeriesRenderer.setChartTitleTextSize(50);
   mXYMultipleSeriesRenderer.setLabelsTextSize(15);
   mXYMultipleSeriesRenderer.setXAxisMax(xMax);
   mXYMultipleSeriesRenderer.setYAxisMin(yMin);
   mXYMultipleSeriesRenderer.setYAxisMax(yMax);
   mXYMultipleSeriesRenderer.setAxesColor(axesColor);
   mXYMultipleSeriesRenderer.setLabelsColor(labelsColor);
   mXYMultipleSeriesRenderer.setShowGrid(true);
   mXYMultipleSeriesRenderer.setGridColor(Color.GRAY);
   mXYMultipleSeriesRenderer.setXLabels(20);
   mXYMultipleSeriesRenderer.setYLabels(10);
   mXYMultipleSeriesRenderer.setXTitle("time");
   mXYMultipleSeriesRenderer.setYLabelsAlign(Align.RIGHT);
   mXYMultipleSeriesRenderer.setPointSize((float) 5);
   mXYMultipleSeriesRenderer.setShowLegend(true);
   mXYMultipleSeriesRenderer.setLegendTextSize(20);
 }
  private static XYMultipleSeriesRenderer getDemoRenderer() {

    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setPointSize(5f);
    renderer.setMargins(new int[] {20, 30, 15, 0});

    XYSeriesRenderer r = new XYSeriesRenderer();
    r.setColor(Color.DKGRAY);
    r.setFillPoints(false);
    renderer.addSeriesRenderer(r);

    int count = 0;
    while (count < 20) {
      if (Compte_Present[count] != null) {
        r = new XYSeriesRenderer();
        //		    r.setPointStyle(PointStyle.CIRCLE);
        r.setColor(_DataPool.BudgetColor(Compte_Present[count]));
        r.setFillPoints(false);
        renderer.addSeriesRenderer(r);
      }
      count++;
    }

    renderer.setAxesColor(Color.DKGRAY);
    renderer.setLabelsColor(Color.LTGRAY);
    return renderer;
  }
Beispiel #4
0
  protected void setRenderer(XYMultipleSeriesRenderer renderer, int[] colors, PointStyle[] styles) {
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(20);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setPointSize(5f);
    renderer.setYLabels(5);
    renderer.setMargins(new int[] {30, 15, 30, 15});
    int length = colors.length;
    for (int i = 0; i < length; i++) {
      XYSeriesRenderer r = new XYSeriesRenderer();
      r.setColor(colors[i]);
      r.setPointStyle(styles[i]);
      renderer.addSeriesRenderer(r);
    }
    renderer.setClickEnabled(true);
    renderer.setSelectableBuffer(100);
    renderer.setApplyBackgroundColor(true);
    renderer.setBackgroundColor(Color.argb(100, 50, 50, 50));

    renderer.setAxesColor(Color.LTGRAY);
    renderer.setZoomButtonsVisible(true);
    renderer.setPointSize(10);

    renderer.setChartTitle("Fuel Efficiency and Cost");
    // mRenderer.setXTitle("Date");

    renderer.setShowGrid(true);
    renderer.setXLabelsAlign(Align.RIGHT);
    renderer.setYLabelsAlign(Align.LEFT);

    renderer.setYTitle(cunits, 0);

    renderer.setLabelsColor(Color.WHITE);
    renderer.setXLabelsColor(Color.GREEN);
    renderer.setYLabelsColor(0, colors[0]);
    renderer.setYLabelsColor(1, colors[1]);

    renderer.setYTitle(dunits, 1);
    renderer.setYAxisAlign(Align.RIGHT, 1);
    renderer.setYLabelsAlign(Align.RIGHT, 1);
  }
  protected void setChartSettings(XYMultipleSeriesRenderer renderer) {
    double xMin, xMax, yMin = 5, yMax = 40;

    // 有关对图表的渲染可参看api文档
    renderer.setAxisTitleTextSize(16);
    renderer.setChartTitleTextSize(16);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);

    renderer.setXTitle("时间 (月/日 时:分)");
    renderer.setYTitle("温度 (摄氏度)");
    renderer.setChartTitle(title);

    // XY轴的最大/最小值
    // renderer.setXAxisMin(xMin);
    // renderer.setXAxisMax(xMax);
    renderer.setYAxisMin(yMin);
    renderer.setYAxisMax(yMax);

    // 坐标轴颜色
    renderer.setAxesColor(Color.RED);
    // 标签(title、单位)颜色
    renderer.setLabelsColor(Color.WHITE);
    // 网格属性
    renderer.setShowGrid(true);
    renderer.setGridColor(Color.BLACK);
    // 背景色 不起作用
    // renderer.setBackgroundColor(Color.WHITE);

    // 横纵坐标格数
    renderer.setXLabels(5);
    renderer.setYLabels((int) ((yMax - yMin) / 5));
    // Y轴的刻度到Y轴的右边
    renderer.setYLabelsAlign(Align.RIGHT);
    // 折线转折点大小
    renderer.setPointSize((float) 7);
    // 是否显示图例
    renderer.setShowLegend(false);
    // 显示折线转折点值
    // renderer.setDisplayChartValues(true);
  }
Beispiel #6
0
 /**
  * Sets a few of the series renderer settings.
  *
  * @param renderer the renderer to set the properties to
  * @param title the chart title
  * @param xTitle the title for the X axis
  * @param yTitle the title for the Y axis
  * @param xMin the minimum value on the X axis
  * @param xMax the maximum value on the X axis
  * @param yMin the minimum value on the Y axis
  * @param yMax the maximum value on the Y axis
  * @param axesColor the axes color
  * @param labelsColor the labels color
  */
 public void setChartSettings(
     XYMultipleSeriesRenderer renderer,
     String title,
     String xTitle,
     String yTitle,
     double xMin,
     double xMax,
     double yMin,
     double yMax,
     int axesColor,
     int labelsColor) {
   renderer.setChartTitle(title);
   renderer.setXTitle(xTitle);
   renderer.setYTitle(yTitle);
   renderer.setXAxisMin(xMin);
   renderer.setXAxisMax(xMax);
   renderer.setYAxisMin(yMin);
   renderer.setYAxisMax(yMax);
   renderer.setAxesColor(axesColor);
   renderer.setLabelsColor(labelsColor);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.observation_chart);

    if (!FileUtils.storageReady()) {
      showCustomToast(getString(R.string.error_storage));
      finish();
    }

    // TODO Check for invalid patient IDs
    String patientIdStr = getIntent().getStringExtra(Constants.KEY_PATIENT_ID);
    Integer patientId = Integer.valueOf(patientIdStr);
    mPatient = getPatient(patientId);

    mObservationFieldName = getIntent().getStringExtra(Constants.KEY_OBSERVATION_FIELD_NAME);

    setTitle(getString(R.string.app_name) + " > " + getString(R.string.view_observation));

    TextView textView = (TextView) findViewById(R.id.title_text);
    if (textView != null) {
      textView.setText(mObservationFieldName);
    }

    XYSeriesRenderer r = new XYSeriesRenderer();
    r.setLineWidth(3.0f);
    r.setColor(getResources().getColor(R.color.chart_red));
    r.setPointStyle(PointStyle.CIRCLE);
    r.setFillPoints(true);

    mRenderer.addSeriesRenderer(r);
    mRenderer.setShowLegend(false);
    // mRenderer.setXTitle("Encounter Date");
    // mRenderer.setAxisTitleTextSize(18.0f);
    mRenderer.setLabelsTextSize(11.0f);
    // mRenderer.setXLabels(10);
    mRenderer.setShowGrid(true);
    mRenderer.setLabelsColor(getResources().getColor(android.R.color.black));
  }
 private XYMultipleSeriesRenderer getDemoRenderer() {
   XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
   renderer.setAxisTitleTextSize(16);
   renderer.setChartTitleTextSize(20);
   renderer.setLabelsTextSize(15);
   renderer.setLegendTextSize(15);
   renderer.setPointSize(5f);
   renderer.setMargins(new int[] {20, 30, 15, 0});
   XYSeriesRenderer r = new XYSeriesRenderer();
   r.setColor(Color.BLUE);
   r.setPointStyle(PointStyle.SQUARE);
   r.setFillBelowLine(true);
   r.setFillBelowLineColor(Color.WHITE);
   r.setFillPoints(true);
   renderer.addSeriesRenderer(r);
   r = new XYSeriesRenderer();
   r.setPointStyle(PointStyle.CIRCLE);
   r.setColor(Color.GREEN);
   r.setFillPoints(true);
   renderer.addSeriesRenderer(r);
   renderer.setAxesColor(Color.DKGRAY);
   renderer.setLabelsColor(Color.LTGRAY);
   return renderer;
 }
  private void openChart() {

    String[] chartTitles;
    chartTitles = new String[] {"Total"};
    List<double[]> values = new ArrayList<double[]>();
    values.add(mStatsDataDaysList.getDataDoubleArray());
    int totalXlength = 0;

    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

    List<double[]> xAxisValues = new ArrayList<double[]>();
    xAxisValues.add(mStatsDataDaysList.getXDoubleArray());

    for (int i = 0; i < chartTitles.length; i++) {
      XYSeries series = new XYSeries(chartTitles[i]);
      double[] xV = xAxisValues.get(i);
      double[] yV = values.get(i);
      int seriesLength = xV.length;
      for (int k = 0; k < seriesLength; k++) {
        System.out.println("LOG X is " + xV[k] + " y is " + yV[k]);
        series.add(xV[k] - 1, yV[k]);
      }
      dataset.addSeries(series);
    }

    XYSeriesRenderer incomeRenderer = new XYSeriesRenderer();
    incomeRenderer.setColor(Color.WHITE);
    incomeRenderer.setPointStyle(PointStyle.CIRCLE);
    incomeRenderer.setFillPoints(true);
    incomeRenderer.setDisplayChartValues(true);
    incomeRenderer.setDisplayChartValuesDistance(15);
    incomeRenderer.setDisplayBoundingPoints(false); // for hiding the series when we scroll

    // Creating a XYMultipleSeriesRenderer to customize the whole chart
    XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer();
    multiRenderer.setChartTitle(getString(R.string.my_mined_km_history));
    multiRenderer.setXTitle(getString(R.string.days));
    multiRenderer.setYTitle(getString(R.string.km));
    multiRenderer.setZoomButtonsVisible(true);
    multiRenderer.setBackgroundColor(0xf7f7f7);
    multiRenderer.setMarginsColor(0xf7f7f7);
    multiRenderer.setMargins(new int[] {50, 60, 60, 30});

    multiRenderer.setXLabelsAlign(Align.CENTER);
    multiRenderer.setYLabelsAlign(Align.RIGHT);
    multiRenderer.setPanEnabled(true, false); // scroll only x axis so true
    multiRenderer.setZoomEnabled(ZOOM_X, false);

    multiRenderer.setPointSize(8); // increase the width of point size
    multiRenderer.setXLabelsPadding(10);

    if (Utils.getScreenDendity(this) > DisplayMetrics.DENSITY_HIGH) {
      multiRenderer.setAxisTitleTextSize(20);
      multiRenderer.setChartTitleTextSize(25);
      multiRenderer.setLabelsTextSize(20);
      multiRenderer.setPointSize(8);
      incomeRenderer.setLineWidth(4);
      incomeRenderer.setChartValuesTextSize(20);
    } else {
      multiRenderer.setAxisTitleTextSize(12);
      multiRenderer.setChartTitleTextSize(18);
      multiRenderer.setLabelsTextSize(12);
      multiRenderer.setPointSize(5);
      incomeRenderer.setLineWidth(2);
      incomeRenderer.setChartValuesTextSize(15);
    }

    xyValues = new LinkedHashMap<Integer, String>();

    for (int i = 0; i < chartTitles.length; i++) {
      double[] xV = xAxisValues.get(i);
      totalXlength = xV.length;
      System.out.println("LOG len is " + totalXlength);
      for (int j = 0; j < totalXlength; j++) {
        multiRenderer.addXTextLabel(j + 1, Utils.addDays(xV[j], mInitialDateUser));
        xyValues.put(j + 1, Utils.addDays(xV[j], mInitialDateUser));
      }
    }

    multiRenderer.setXLabels(0);
    multiRenderer.setShowAxes(false);

    multiRenderer.setXAxisMin(totalXlength - 5);
    multiRenderer.setXAxisMax(totalXlength + 1);

    if (totalXlength <= X_AXIS_MAX) {
      multiRenderer.setXAxisMin(0);
      multiRenderer.setXAxisMax(totalXlength);
    }

    multiRenderer.setPanEnabled(true);
    multiRenderer.setPanLimits(new double[] {0, totalXlength + 1, 0, 0});

    multiRenderer.setYAxisMin(Utils.getMinValueFromList(values));
    multiRenderer.setYAxisMax(Utils.getMaxValueFromList(values));
    multiRenderer.setAxesColor(Color.GRAY);
    multiRenderer.setLabelsColor(Color.WHITE);
    multiRenderer.addSeriesRenderer(incomeRenderer);

    // Creating a Time Chart
    mChartView2 =
        (GraphicalView)
            ChartFactory.getTimeChartView(getBaseContext(), dataset, multiRenderer, "dd-MMM-yyyy");

    multiRenderer.setClickEnabled(true);
    multiRenderer.setSelectableBuffer(10);

    // Setting a click event listener for the graph
    mChartView2.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {

            SeriesSelection seriesSelection = mChartView2.getCurrentSeriesAndPoint();
            double[] xy = mChartView2.toRealPoint(0);

            if (seriesSelection != null) {

              //                  debug
              Log.d("Punto", seriesSelection.getXValue() + ", " + seriesSelection.getValue());
              //                  debug
              Log.d(
                  "Chart point",
                  "Chart element in series index "
                      + seriesSelection.getSeriesIndex()
                      + " data point index "
                      + seriesSelection.getPointIndex()
                      + " was clicked"
                      + " closest point value X="
                      + seriesSelection.getXValue()
                      + ", Y="
                      + seriesSelection.getValue()
                      + " clicked point value X="
                      + (float) xy[0]
                      + ", Y="
                      + (float) xy[1]);

              Toast.makeText(
                      getBaseContext(),
                      ""
                          + xyValues.get((int) seriesSelection.getXValue())
                          + " , "
                          + seriesSelection.getValue()
                          + " "
                          + getString(R.string.km),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    // Adding the Line Chart to the LinearLayout
    mLayoutChart2.addView(mChartView2);
  }
  @Override
  protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();

    try {
      elec_thread.join();
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    int k = CH.getNum_of_msg(); // 보여줄 데이터 개수

    Log.d("get", "onStart시작");

    int seriesLength = 0;
    double max = 0;

    recv_packet = new Packet[k];

    for (int i = 0; i < k; i++) {
      recv_packet[i] = CH.get_Packet(i);
    }
    Log.d("get", "recv_packet배열 저장");

    List<Float[]> values = new ArrayList<Float[]>();
    Float[][] a = new Float[4][k];
    int[][] c = new int[4][k];

    for (int j = 0; j < k; j++) {
      a[0][j] = Float.parseFloat(recv_packet[j].getData(3));
      a[1][j] = Float.parseFloat(recv_packet[j].getData(4));
      a[2][j] = Float.parseFloat(recv_packet[j].getData(5));
      a[3][j] = Float.parseFloat(recv_packet[j].getData(7));
      c[0][j] = (int) (a[0][j] * 10);
      c[1][j] = (int) (a[1][j] * 10);
      c[2][j] = (int) (a[2][j] * 10);
      c[3][j] = (int) (a[3][j] * 10);
      a[0][j] = ((float) c[0][j] / (float) 10);
      a[1][j] = ((float) c[1][j] / (float) 10);
      a[2][j] = ((float) c[2][j] / (float) 10);
      a[3][j] = ((float) c[3][j] / (float) 10);

      // a[3][j] = (float) Math.round(Float.parseFloat(recv_packet[j].getData(7))*10000)/10000;
      // values.add(a);// 이번달
    }
    for (int w = 0; w < 4; w++) {
      //        a[w] = Math.round(a[w]*10) / 10.0;
      values.add(a[w]);
    }

    Log.d("get", "values배열 저장");
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

    renderer.setChartTitle("과거 사용량과의 비교");
    renderer.setChartTitleTextSize(50);

    String[] titles = new String[] {"3달 전", "2달 전", "1달 전", "이번 달"};

    int[] colors =
        new int[] {
          Color.rgb(255, 90, 217),
          Color.rgb(54, 255, 255),
          Color.rgb(255, 255, 72),
          Color.rgb(83, 255, 76)
        };
    // //////////////////////////////////////////////////////
    //   renderer.setLegendTextSize(35);

    int length = values.size(); // 항목갯수

    Log.d("get", "legnth : " + length);
    for (int i = 0; i < length; i++) {
      SimpleSeriesRenderer r = new SimpleSeriesRenderer();
      r.setColor(colors[i]);
      renderer.addSeriesRenderer(r);
    }

    renderer.setXTitle("제품별");
    renderer.setYTitle("사용량");
    renderer.setAxisTitleTextSize(28);
    renderer.setMarginsColor(Color.WHITE);

    renderer.setLabelsTextSize(20);
    renderer.setLegendHeight(200);
    renderer.setXAxisMin(0.5);
    // renderer.setXAxisMax(length + 0.5); // 장비 갯수 +0.5
    renderer.setYAxisMin(0);

    renderer.setLabelsColor(Color.BLACK);
    renderer.setBackgroundColor(Color.WHITE);

    // 그래프 위에 값 표시하기
    for (int i = 0; i < length; i++) {
      renderer.getSeriesRendererAt(i).setDisplayChartValues(true);
      renderer.getSeriesRendererAt(i).setChartValuesTextAlign(Align.RIGHT);
      renderer.getSeriesRendererAt(i).setChartValuesTextSize(20);
    }
    Log.d("get", "그래프위값 표시하기");

    renderer.setYLabels(5);

    // x,y축 정렬 방향
    renderer.setXLabelsAlign(Align.CENTER);
    renderer.setYLabelsAlign(Align.CENTER);
    renderer.setPanEnabled(true, true); // x,y축 스크롤 여부 on/off
    renderer.setZoomEnabled(true); // zoom기능 on/off
    renderer.setZoomRate(1.0f);
    renderer.setBarSpacing(0.5f);

    Log.d("get", "xy축 정렬 방향");

    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
    for (int i = 0; i < titles.length; i++) {
      CategorySeries series = new CategorySeries(titles[i]);
      Float[] v = values.get(i);

      Log.d("get", "int i = 0; i < titles.length; i++");

      seriesLength = v.length;
      renderer.setXAxisMax(seriesLength + 0.5);

      for (int q = 0; q < seriesLength; q++) {
        series.add(v[q]);
        if (max < v[q]) {
          max = v[q];
        }
        // Log.d("Test", "series.add : " + v[q]);
        renderer.setXLabels(seriesLength + 1);
      }
      dataset.addSeries(series.toXYSeries());
    }
    Log.d("get", "111111111");
    String[] x_name = new String[seriesLength];
    for (int b = 0; b < k; b++) {
      x_name[b] = recv_packet[b].getData(2);
    }
    Log.d("get", "222222222");
    renderer.setXLabels(0);
    for (int i = 0; i < seriesLength; i++) {
      renderer.addXTextLabel(i + 1, x_name[i]);
    }
    renderer.setYAxisMax(max + (max * 0.1)); // max 찾아서 넣기
    GraphicalView gv = ChartFactory.getBarChartView(this, dataset, renderer, Type.DEFAULT);

    setContentView(gv);
  }
Beispiel #11
0
  public static View genBarChart(final Activity activity, final BarChartData data) {
    if (data == null || data.getData() == null) return null;
    Resources resources = activity.getResources();
    final String[] axis_x_string = resources.getStringArray(R.array.week);
    final XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    XYMultipleSeriesDataset dataSet = new XYMultipleSeriesDataset();
    renderer.setApplyBackgroundColor(true);
    renderer.setBackgroundColor(Color.WHITE);
    renderer.setMarginsColor(Color.WHITE);
    renderer.setTextTypeface(null, Typeface.NORMAL);

    renderer.setShowGrid(true);
    renderer.setGridColor(resources.getColor(R.color.gray3));

    renderer.setLabelsColor(Color.BLACK);
    renderer.setAxesColor(resources.getColor(R.color.gray1));
    renderer.setBarSpacing(0.5);

    renderer.setXTitle("");
    renderer.setYTitle("");
    renderer.setXLabelsColor(Color.BLACK);
    renderer.setLabelsTextSize(
        activity.getResources().getDimensionPixelSize(R.dimen.ov_statistics_axis_text_size));
    renderer.setYLabelsColor(0, Color.BLACK);
    renderer.setXLabelsPadding(resources.getDimension(R.dimen.ov_statistics_x_axis_padding));
    renderer.setYLabelsPadding(resources.getDimension(R.dimen.ov_statistics_x_axis_padding));
    renderer.setXLabelsAlign(Paint.Align.CENTER);
    renderer.setYLabelsAlign(Paint.Align.CENTER);
    renderer.setXLabelsAngle(0);
    renderer.setShowTickMarks(false);

    renderer.setXLabels(0);
    renderer.setYAxisMin(0);

    for (int i = 0; i < data.getData().length; i++) {
      final XYSeries series = new XYSeries("");
      dataSet.addSeries(series);
      XYSeriesRenderer yRenderer = new XYSeriesRenderer();
      renderer.addSeriesRenderer(yRenderer);
      yRenderer.setColor(resources.getColor(data.sColorId[i]));
      series.add(0, 0);
      renderer.addXTextLabel(0, "");
      for (int j = 0; j < data.getData()[i].length; j++) {
        renderer.addXTextLabel(j + 1, axis_x_string[j]);
        series.add(j + 1, ((float) data.getData()[i][j]) / 3600000);
      }
      series.add(data.getData()[i].length + 1, 0);
      renderer.addXTextLabel(data.getData()[i].length + 1, "");
    }

    renderer.setZoomEnabled(false);
    renderer.setZoomEnabled(false, false);
    renderer.setClickEnabled(true);
    renderer.setPanEnabled(false);
    renderer.setShowLegend(false);
    try {
      renderer.setDrawGridAfterBar(true);
      renderer.setHighLightRectEnabled(true);
      renderer.setHighLightRectStrokeWidth(
          activity
              .getResources()
              .getDimensionPixelOffset(R.dimen.ov_statistics_highlight_stroke_width));
      renderer.setHighLightRectStrokeColor(activity.getResources().getColor(R.color.gray3));
    } catch (NoSuchMethodError e) {
      e.printStackTrace();
    }
    View view = ChartFactory.getBarChartView(activity, dataSet, renderer, BarChart.Type.DEFAULT);
    view.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (!(v instanceof GraphicalView)) return;
            final GraphicalView view = (GraphicalView) v;
            SeriesSelection selection = view.getCurrentSeriesAndPoint();
            try {
              view.onClick(selection);
            } catch (NoSuchMethodError e) {
              e.printStackTrace();
            }
            if (selection == null) return;
            int idx = selection.getPointIndex() - 1;
            View popupView = activity.getLayoutInflater().inflate(R.layout.bar_chart_popup, null);
            if (data.from.equals(CaseOverviewFragment.class.getSimpleName())
                || data.from.equals(EquipmentOverviewFragment.class.getSimpleName())) {
              ((TextView) popupView.findViewById(R.id.date)).setText(data.getDate()[idx]);
              if (data.getData()[0][idx] >= 0) {
                int hour = (int) data.getData()[0][idx] / 3600000;
                int min = (int) ((data.getData()[0][idx] % 3600000)) / 60000;
                ((TextView) popupView.findViewById(R.id.working_time))
                    .setText(
                        activity.getResources().getString(R.string.statistics_popup_time_finish)
                            + " "
                            + (hour < 10 ? ("0" + hour) : hour)
                            + " : "
                            + (min < 10 ? ("0" + min) : min));
              } else {
                popupView.findViewById(R.id.vg_working_time).setVisibility(View.GONE);
              }
              popupView.findViewById(R.id.vg_overtime).setVisibility(View.GONE);
            } else if (data.from.equals(WorkerOverviewFragment.class.getSimpleName())) {
              ((TextView) popupView.findViewById(R.id.date)).setText(data.getDate()[idx]);
              if (data.getData()[0][idx] >= 0) {
                int hour = (int) data.getData()[0][idx] / 3600000;
                int min = (int) ((data.getData()[0][idx] % 3600000)) / 60000;
                ((TextView) popupView.findViewById(R.id.working_time))
                    .setText(
                        activity.getResources().getString(R.string.statistics_popup_time_work)
                            + " "
                            + (hour < 10 ? ("0" + hour) : hour)
                            + " : "
                            + (min < 10 ? ("0" + min) : min));
              } else {
                popupView.findViewById(R.id.vg_working_time).setVisibility(View.GONE);
              }
              if (data.getData()[1][idx] >= 0) {
                int hour = (int) data.getData()[1][idx] / 3600000;
                int min = (int) ((data.getData()[1][idx] % 3600000)) / 60000;
                ((TextView) popupView.findViewById(R.id.overtime))
                    .setText(
                        activity.getResources().getString(R.string.statistics_popup_time_overtime)
                            + " "
                            + (hour < 10 ? ("0" + hour) : hour)
                            + " : "
                            + (min < 10 ? ("0" + min) : min));
              } else {
                popupView.findViewById(R.id.vg_overtime).setVisibility(View.GONE);
              }
            }
            final PopupWindow popup =
                new PopupWindow(
                    popupView,
                    LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
            popup.setBackgroundDrawable(new BitmapDrawable());
            popup.setOutsideTouchable(true);
            popup.setOnDismissListener(
                new PopupWindow.OnDismissListener() {
                  @Override
                  public void onDismiss() {
                    try {
                      view.onClick(null);
                    } catch (NoSuchMethodError e) {
                      e.printStackTrace();
                    }
                  }
                });
            /* calculate popup position */
            popupView.measure(
                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            int[] dateChooserLocations = new int[2];
            (activity.findViewById(R.id.ov_statistics_week_chooser))
                .getLocationOnScreen(dateChooserLocations);
            int[] statisticsViewLocations = new int[2];
            v.getLocationOnScreen(statisticsViewLocations);
            int[] barChartLocations = new int[2];
            v.getLocationOnScreen(barChartLocations);
            int x_pos =
                barChartLocations[0]
                    + (int) ((XYChart) view.getChart()).getXAxisPos((double) (idx + 1))
                    - popupView.getMeasuredWidth() / 2;
            int y_base =
                dateChooserLocations[1]
                    + (activity.findViewById(R.id.ov_statistics_week_chooser)).getMeasuredHeight();
            int y_pos =
                (statisticsViewLocations[1] - y_base) / 2
                    + y_base
                    - popupView.getMeasuredHeight() / 2;
            popup.showAtLocation(v, Gravity.NO_GRAVITY, x_pos, y_pos);
          }
        });
    return view;
  }