예제 #1
0
  private void drawDyLegend() {

    Legend dyLegend = chart.getDyLegend();
    if (null == dyLegend) return;
    dyLegend.setPosition(0.8f, 0.5f);
    if (chart.getPlotArea().getHeight() > chart.getPlotArea().getWidth()) {
      dyLegend.setPosition(0.6f, 0.5f);
    }
    // dyLegend.setColSpan(30.f);
    dyLegend.getBackgroundPaint().setColor(Color.BLACK);
    dyLegend.getBackgroundPaint().setAlpha(100);
    dyLegend.setRowSpan(20.f);
    dyLegend.setMargin(15.f);
    dyLegend.setStyle(XEnum.DyInfoStyle.ROUNDRECT);

    Paint pDyLegend = new Paint(Paint.ANTI_ALIAS_FLAG);
    pDyLegend.setColor(Color.GREEN);
    PlotDot dotDyLegend = new PlotDot();
    dotDyLegend.setDotStyle(XEnum.DotStyle.RECT);
    dyLegend.addLegend(dotDyLegend, "库可用xxx(PB)", pDyLegend);

    Paint pDyLegend2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    pDyLegend2.setColor(Color.RED);
    dyLegend.addLegend(dotDyLegend, "库已用xxx(PB)", pDyLegend2);

    Paint pDyLegend3 = new Paint(Paint.ANTI_ALIAS_FLAG);
    pDyLegend3.setColor(Color.CYAN);
    dyLegend.addLegend(dotDyLegend, "未分配xxx(PB)", pDyLegend3);

    Paint pDyLegend4 = new Paint(Paint.ANTI_ALIAS_FLAG);
    pDyLegend4.setColor(Color.YELLOW);
    dyLegend.addLegend("总计:xxx(PB)", pDyLegend4);
  }
예제 #2
0
  private void renderDotAndLabel(
      Canvas canvas,
      RadarData lineData,
      // float previousX,float previousY,
      float currentX,
      float currentY,
      int listID) {
    PlotLine plotLine = lineData.getPlotLine();

    if (!plotLine.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
      PlotDot pDot = plotLine.getPlotDot();

      PlotDotRender.getInstance()
          .renderDot(
              canvas,
              pDot,
              currentX - pDot.getDotRadius(),
              currentY - pDot.getDotRadius(),
              currentX,
              currentY,
              lineData.getPlotLine().getDotPaint()); // 标识图形            			
    }
    // 是否显示标签
    if (lineData.getLabelVisible()) {
      canvas.drawText(
          getFormatterDotLabel(lineData.getLinePoint().get(listID)),
          currentX,
          currentY,
          lineData.getPlotLine().getDotLabelPaint());
    }
  }
예제 #3
0
  // 触发监听
  private void triggerClick(float x, float y) {

    // 交叉线
    if (chart.getDyLineVisible()) chart.getDyLine().setCurrentXY(x, y);

    if (!chart.getListenItemClickStatus()) {
      // 交叉线
      if (chart.getDyLineVisible() && chart.getDyLine().isInvalidate()) this.invalidate();
    } else {
      BarPosition record = chart.getPositionRecord(x, y);
      if (null == record) {
        if (chart.getDyLineVisible()) this.invalidate();
        return;
      }

      if (record.getDataID() >= chartData.size()) return;
      BarData bData = chartData.get(record.getDataID());

      if (record.getDataChildID() >= bData.getDataSet().size()) return;
      Double bValue = bData.getDataSet().get(record.getDataChildID());

      // 显示选中框
      chart.showFocusRectF(record.getRectF());
      chart.getFocusPaint().setStyle(Style.STROKE);
      chart.getFocusPaint().setStrokeWidth(3);
      chart.getFocusPaint().setColor(Color.GREEN);

      // 在点击处显示tooltip
      mPaintToolTip.setAntiAlias(true);
      mPaintToolTip.setColor(bData.getColor());

      mDotToolTip.setDotStyle(XEnum.DotStyle.RECT);
      mDotToolTip.setColor(Color.BLUE); // bData.getColor());

      // 位置显示方法一:
      // 用下列方法可以让tooltip显示在柱形顶部
      // chart.getToolTip().setCurrentXY(record.getRectF().centerX(),record.getRectF().top);
      // 位置显示方法二:
      // 用下列方法可以让tooltip在所点击位置显示
      chart.getToolTip().setCurrentXY(x, y);
      chart.getToolTip().setStyle(XEnum.DyInfoStyle.ROUNDRECT);
      chart.getToolTip().addToolTip(mDotToolTip, bData.getKey(), mPaintToolTip);
      chart.getToolTip().addToolTip("数量:" + Double.toString(bValue), mPaintToolTip);
      chart.getToolTip().getBackgroundPaint().setAlpha(100);
      chart.getToolTip().setAlign(Align.CENTER);

      chart.getToolTip().setInfoStyle(XEnum.DyInfoStyle.CIRCLE);
      // chart.getToolTip().getBackgroundPaint().setColor(Color.rgb(30, 30, 30));
      this.invalidate();
    }
  }