使用Tee图表绘制非常多的箱形图(范围在1到10,000之间)

时间:2018-04-09 09:53:33

标签: boxplot teechart

我需要允许用户选择开始和结束数据。一旦选中,我需要获取这些日期之间的所有组数据和显示框图。如果需要显示许多箱形图,则问题是箱形图重叠。 Tee图表不会自动缩小boxplot的大小。此外,不提供滚动条以调整底部轴以容纳所有箱形图。任何解决方案?

2 个答案:

答案 0 :(得分:0)

您可以根据需要计算合适的盒子宽度 这是一个简单的例子,有100个盒子,可在Zoom& amp; UnZoom活动。

在C#中使用TeeChart .NET

Box

这里是代码:

private void testBoxPlotWidth()
{
  tChart1.Aspect.View3D = false;
  tChart1.Legend.Visible = false;
  for (int i = 0; i < 100; i++)
  {
    Box b = new Box();
    tChart1.Series.Add(b);
    b.Position = i;
    b.FillSampleValues();
    b.ColorEach = true;
  }

  tChart1.Panning.Allow = ScrollModes.Horizontal;
  tChart1.Zoom.Direction = ZoomDirections.Horizontal;

  ReCalculateBoxWidth();

  tChart1.Zoomed += TChart1_Zoomed;
  tChart1.UndoneZoom += TChart1_UndoneZoom;
}

private void TChart1_UndoneZoom(object sender, EventArgs e)
{
  ReCalculateBoxWidth();
}

private void TChart1_Zoomed(object sender, EventArgs e)
{
  ReCalculateBoxWidth();
}

public void ReCalculateBoxWidth()
{
  int boxW;
  double tmpW;

  tChart1.Draw();

  tmpW = tChart1.Chart.ChartRect.Width / (tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum) / 2;
  tmpW = tmpW * 0.7;

  boxW = (int)Math.Round(tmpW);

  foreach (CustomBox b in tChart1.Series)
  {
    b.Box.SizeUnits = PointerSizeUnits.Pixels;
    b.Box.HorizSize = boxW;
  }
}

在Delphi中使用TeeChart VCL/FMX

Box

这里是代码:

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=False;
  Chart1.Legend.Hide;

  for i:=0 to 99 do
    with Chart1.AddSeries(TBoxSeries) as TBoxSeries do
    begin
      Position:=i;
      FillSampleValues;
    end;

  Chart1.AllowPanning:=pmHorizontal;
  Chart1.Zoom.Direction:=tzdHorizontal;

  RecalcBoxWidth;
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  RecalcBoxWidth;
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  RecalcBoxWidth;
end;

procedure TForm1.RecalcBoxWidth;
var i, boxW: Integer;
    tmpW: Double;
begin
  Chart1.Draw;

  tmpW:=(Chart1.ChartRect.Right - Chart1.ChartRect.Left) / (Chart1.Axes.Bottom.Maximum - Chart1.Axes.Bottom.Minimum) / 2;
  tmpW:=tmpW*0.9;

  boxW:=Round(tmpW);
  for i:=0 to 99 do
    with Chart1[i] as TBoxSeries do
    begin
      Box.SizeUnits:=suPixels;
      Box.Size:=boxW;
    end;

  Chart1.Draw;
end; 

答案 1 :(得分:0)

我在C#中使用了你的代码,但没有调整框的宽度,它们是重叠的。

private void button3_Click_1(object sender, EventArgs e)
    {
            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;
            for(int i=0;i<100;i++)
            {
                Steema.TeeChart.Styles.Box b = new Steema.TeeChart.Styles.Box();
                tChart1.Series.Add(b);
                b.Position = i;
                b.FillSampleValues();
            }

            tChart1.Panning.Allow = ScrollModes.Horizontal;
            tChart1.Zoom.Direction = ZoomDirections.Horizontal;

            ReCalculateBoxWidth();

        }
    public void ReCalculateBoxWidth()
    {
        int boxW;
        double tmpW;

        tChart1.Draw();

        tmpW = (tChart1.Chart.ChartRect.Right - tChart1.Chart.ChartRect.Left) / (tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum) / 2;
        tmpW = tmpW * 0.9;

        boxW = (int)Math.Round(tmpW);

        foreach (Steema.TeeChart.Styles.CustomBox b in tChart1.Series)
        {
            b.Box.SizeUnits = Steema.TeeChart.Styles.PointerSizeUnits.Pixels;
            b.Box.SizeDouble = boxW;
        }

        tChart1.Draw();

    }

BoxPlot