Page 1 of 1

3D Chart with vertical lines

Posted: Tue Mar 15, 2016 11:23 am
by 6919481
Hi,

I am trying to achieve what is shown in the attachment (3D Chart.png).
Following are the features of the attached chart I want:
1. 3D
2. Individual vertical lines
3. Lines have color-range applied (from the legend)

I tried and found that (My Chart.png):
1. 3D - It is achievable
2. Individual vertical lines - There is no such support in the chart. There is "Point 3D", but the lines are connected. I want individual vertical lines.
3. Lines have color-range applied (from the legend) - When any type from "Point 3D" is selected, the lines do not show color-range from the legend. The lines are either a one solid color or a pre-defined gradient.

Can you please help me in this?
Looking forward to hear from you.

Thanks a lot!

Re: 3D Chart with vertical lines

Posted: Wed Mar 16, 2016 4:29 pm
by yeray
Hello,

I'm afraid there isn't a series designed to draw such a chart.
However, you could try using one of the current series (ie a TBar3DSeries or a TLineSeries) and use it to get the desired result.

This is the best I could get for the moment with a TBar3DSeries:
testVerticalLines.png
testVerticalLines.png (168.13 KiB) Viewed 9434 times

Code: Select all

uses Bar3D, TeCanvas, Math, TeePNG;

var barRow: array of TBar3DSeries;
var myGradient: TTeeGradient;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
    tmpUp, tmpDown: Double;
begin
  Chart1.Legend.Visible:=false;
  Chart1.Aspect.Orthogonal:=false;
  Chart1.Chart3DPercent:=20;
  Chart1.Aspect.Zoom:=80;
  Chart1.Axes.Depth.Visible:=true;
  Chart1.Axes.Depth.LabelStyle:=talValue;
  Chart1.Axes.Depth.Increment:=2;
  Chart1.Axes.Left.SetMinMax(-20, -120);
  Chart1.Axes.Left.Increment:=20;
  Chart1.Axes.Bottom.SetMinMax(0, 10);
  Chart1.Axes.Bottom.Increment:=2;
  Chart1.Axes.Bottom.MinimumOffset:=10;
  Chart1.Axes.Bottom.MaximumOffset:=10;

  myGradient:=TTeeGradient.Create(nil);
  with myGradient do
  begin
    Visible:=true;
    Colors.Clear;
    Colors.Add(0, RGB(0, 0, 130));
    Colors.Add(0.2, RGB(0, 0, 255));
    Colors.Add(0.4, RGB(0, 255, 255));
    Colors.Add(0.6, RGB(255, 255, 0));
    Colors.Add(0.8, RGB(255, 0, 0));
    Colors.Add(1, RGB(130, 0, 0));
  end;

  SetLength(barRow, 10);
  for i:=0 to High(barRow) do
  begin
    barRow[i]:=Chart1.AddSeries(TBar3DSeries) as TBar3DSeries;

    with barRow[i] do
    begin
      Pen.Visible:=false;
      BarWidthPercent:=0;
      Depth:=0;
      Marks.Visible:=false;
      MultiBar:=mbNone;

      OnGetBarStyle:=BarGetBarStyle;

      for j:=0 to 19 do
      begin
        tmpUp:=-25-random(25);
        tmpDown:=-70-random(30);

        AddBar(j/2, tmpUp, tmpDown);
      end;
    end;
  end;
end;

procedure TForm1.BarGetBarStyle(Sender:TCustomBarSeries; ValueIndex:Integer;
                               var TheBarStyle:TBarStyle);
var tmpGradient: TTeeGradient;
begin
  tmpGradient:=myGradient;

  if Sender is TBarSeries then
    (Sender as TBarSeries).Gradient:=tmpGradient;
end;
Here is still pending to calculate the correct tmpGradient to assign at BarGetBarStyle. This should be calculated from myGradient manually.