Page 1 of 1
Bar rect.gradient Plots
Posted: Mon Aug 29, 2011 9:12 pm
by 15059326
Hello,
We are exploring plots with bar series type. In the attachment you can see how the color of each serie goes to black with the gradient property. Using the following code:
Code: Select all
TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor = RGB-VALUE(RANDOM(0,255),RANDOM(0,255),RANDOM(0,255))
TCrart1:Series(p-SeriesIndex):asBar:Gradient:MidColor = TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor
TCrart1:Series(p-SeriesIndex):asBar:Gradient:EndColor = TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor
TCrart1:Series(p-SeriesIndex):COLOR = TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor
Is it black the default color that appears on the depth and top of each bar? How can I change it?
Besides, the first bar at the left appears truncated, it does not have the same width as the others. The same comment is valid for the extreme right serie but with the depth side of the bar, as is clearly seen in the image. Is there a command that we are missing?
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Mon Aug 29, 2011 9:21 pm
by 15059326
Hello again,
We almost forgot that any time that the plot is exported to PDF format, the bars appear completely black.
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Tue Aug 30, 2011 8:27 am
by yeray
Hello JAV,
JAV wrote:We are exploring plots with bar series type. In the attachment you can see how the color of each serie goes to black with the gradient property. Using the following code:
Code: Select all
TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor = RGB-VALUE(RANDOM(0,255),RANDOM(0,255),RANDOM(0,255))
TCrart1:Series(p-SeriesIndex):asBar:Gradient:MidColor = TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor
TCrart1:Series(p-SeriesIndex):asBar:Gradient:EndColor = TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor
TCrart1:Series(p-SeriesIndex):COLOR = TCrart1:Series(p-SeriesIndex):asBar:Gradient:StartColor
Is it black the default color that appears on the depth and top of each bar? How can I change it?
In the code above you set the same color as Gradient.StarColor, MidColor, EndColor and Color, right? I don't see how any gradient can be drawn. Are you sure this is the right code? I've tried to translate it to a complete vb6 example and I can't see any gradient:
Code: Select all
TChart1.Aspect.View3D = True
TChart1.Legend.Visible = False
Dim i As Integer
For i = 0 To 1
TChart1.AddSeries scBar
With TChart1.Series(i)
.FillSampleValues
.asBar.MultiBar = mbNone
.asBar.BarStyle = bsRectGradient
.asBar.Gradient.StartColor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
.asBar.Gradient.MidColor = .asBar.Gradient.StartColor
.asBar.Gradient.EndColor = .asBar.Gradient.StartColor
.Color = .asBar.Gradient.StartColor
End With
Next i
JAV wrote:Besides, the first bar at the left appears truncated, it does not have the same width as the others. The same comment is valid for the extreme right serie but with the depth side of the bar, as is clearly seen in the image. Is there a command that we are missing?
I can't see this either. If you are setting the bottom axis manually, keep in mind that you'll have to add some offset both for bottom minimum and maximum for the first and last bars not to be cut.
JAV wrote:We almost forgot that any time that the plot is exported to PDF format, the bars appear completely black.
The gradients aren't exported to pdf, this is a known issue already in the wish list to be revised for further releases. In the meanwhile you could try using a virtual pdf printer.
If you still have problems with any of the above, please try to arrange a simple example project we can run as-is to reproduce the problem(s) here.
Re: Bar rect.gradient Plots
Posted: Wed Aug 31, 2011 1:24 am
by 15059326
Hello Yeray:
The complete code is:
Code: Select all
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = TRUE
TChart1.Legend.CheckBoxes = TRUE
TChart1.Legend.LegendStyle = 0
Dim i As Integer
Dim icolor AS INTEGER
For i = 0 To 1
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.FillSampleValues
.asBar.MultiBar = mbNone
.asBar.BarStyle = bsRectGradient
.asBar.DepthPercent = 80
.asBar.BarWidthPercent = 40
.asBar.Gradient.VISIBLE = TRUE
.asBar.Gradient.Direction = 1
.asBar.Gradient.Dark3D = FALSE
.asBar.Gradient.StartColor = icolor
.asBar.Gradient.MidColor = icolor
.asBar.Gradient.EndColor = icolor
.Color = icolor
End With
Next i
I'm not setting any axis manually.
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Wed Aug 31, 2011 8:26 am
by yeray
Hello JAV,
You are using TeeChart Ax v8, right? I've tried your code with the latest v8 available in the download area (v8.0.1.1). I had to change icolor type from Integer to Long, and I had to comment the Dark3D line. With this two changes I get this:

- test.png (15.85 KiB) Viewed 20600 times
Code: Select all
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = True
TChart1.Legend.CheckBoxes = True
TChart1.Legend.LegendStyle = 0
Dim i As Integer
Dim icolor As Long
For i = 0 To 1
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.FillSampleValues
.asBar.MultiBar = mbNone
.asBar.BarStyle = bsRectGradient
.asBar.DepthPercent = 80
.asBar.BarWidthPercent = 40
.asBar.Gradient.Visible = True
.asBar.Gradient.Direction = 1
'.asBar.Gradient.Dark3D = False
.asBar.Gradient.StartColor = icolor
.asBar.Gradient.MidColor = icolor
.asBar.Gradient.EndColor = icolor
.Color = icolor
End With
Next i
Re: Bar rect.gradient Plots
Posted: Wed Aug 31, 2011 10:28 pm
by 15059326
Hello, thanks a lot for your help.
We realized that the problem was not with the bars color settings but the command used to create the series (ADD). The third parameter in this instruction was setting as zero, and this parameter is the default color, in this case, black.
Now this is working correctly (we changed to rectangle type instead of gradient bars as you suggested), but we have to reconfigurate the OnClickSeries event: this is used to change the color just in case the user want to:
Code: Select all
TChart1.Series(p-SeriesIndex).COLOR = RGB-VALUE(RANDOM(0,255),RANDOM(0,255),RANDOM(0,255))
What extra code we need for change
no just the legend color but also the bars color? (attachments)
Please, we still have the truncating issue with edge bars. We are not setting axis manually. We're using the following code:
Code: Select all
TChart1.Axis.Left.Visible = TRUE
TChart1.Axis.Left.Automatic = TRUE
TChart1.Axis.Bottom.Visible = TRUE
TChart1.Axis.Bottom.Automatic = TRUE
TChart1.Axis.Depth.VISIBLE = TRUE
TChart1.Axis.Depth.Automatic = TRUE
TChart1.Axis.RIGHT.Visible = FALSE
TChart1.Axis.TOP.Visible = FALSE
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Thu Sep 01, 2011 3:18 pm
by yeray
Hello JAV,
I'm still not sure to understand if you want gradients or not. If you want gradients, assigning the same color for each series color, startcolor, midcolor and endcolor is the same than not using gradients.
Anyway, both with gradients or without, I see how both the bars and the respective legend symbols change in a simple application:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = True
TChart1.Legend.CheckBoxes = True
TChart1.Legend.Alignment = laBottom
Dim i As Integer
Dim icolor As Long
For i = 0 To 2
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.FillSampleValues
.asBar.BarWidthPercent = 40
.asBar.MultiBar = mbNone
'.asBar.BarStyle = bsRectGradient
.Color = icolor
End With
Next i
End Sub
Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If SeriesIndex > -1 Then
TChart1.Series(SeriesIndex).Color = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
End If
End Sub
JAV wrote:Please, we still have the truncating issue with edge bars. We are not setting axis manually. We're using the following code:
If you still have problems with the gradients or with the bars positioning, please, try to arrange a simple example project we can run as-is to reproduce the problem here.
Re: Bar rect.gradient Plots
Posted: Mon Sep 05, 2011 5:10 pm
by 15059326
Thank you very much. Actually we were using the gradient option because we didnĀ“t know how to color the rectangle-type bars. Erroneously we were using the ADD command to add each serie without knowing that the last parameter was for the color and it was set as zero. Now the last parameter in ADD command is set as ramdom color because we need a different color for each serie, this works very well, but in the event OnClickSeries when you use the COLOR property only changes the legend (using ADD instead of FillSampleValues). What command alter the third parameter of the ADD or what command should I use instead of ADD to add a serie (I do not use FillSampleValues in my application).
Please note that the only change that we have made in the previous code is in this line:
We use this:
Code: Select all
TChart1.Series(i).Add(tabla1.valor, tabla1.nombre, RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255))
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Tue Sep 06, 2011 10:24 am
by yeray
Hello JAV,
Let me try to explain. When a series value hasn't a color assigned, the color of the series is used to draw it. However, as soon as you add your values with color, this color is used to draw the point.
So you have two options here:
1. Add your values without color (using clTeeColor as color parameter) so the series color will be used to draw its points. Then, changing the series color will modify both the series points and the series legend symbol. Example:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = True
TChart1.Legend.CheckBoxes = True
TChart1.Legend.Alignment = laBottom
Dim i As Integer
Dim icolor As Long
For i = 0 To 2
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.Add 10, "first", clTeeColor
.Add 20, "second", clTeeColor
.Add 30, "third", clTeeColor
.Add 40, "fourth", clTeeColor
.asBar.BarWidthPercent = 40
.asBar.MultiBar = mbNone
.Color = icolor
End With
Next i
End Sub
Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
If SeriesIndex > -1 Then
TChart1.Series(SeriesIndex).Color = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
End If
End Sub
2. Add your values with color. Then, if you want to change the colors of all the points in a series, you'll have to loop them. Example:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = True
TChart1.Aspect.Chart3DPercent = 50
TChart1.Legend.Visible = True
TChart1.Legend.CheckBoxes = True
TChart1.Legend.Alignment = laBottom
Dim i As Integer
Dim icolor As Long
For i = 0 To 2
icolor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
TChart1.AddSeries scBar
With TChart1.Series(i)
.Add 10, "first", icolor
.Add 20, "second", icolor
.Add 30, "third", icolor
.Add 40, "fourth", icolor
.asBar.BarWidthPercent = 40
.asBar.MultiBar = mbNone
.Color = icolor
End With
Next i
End Sub
Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim i As Integer
If SeriesIndex > -1 Then
With TChart1.Series(SeriesIndex)
.Color = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255)
For i = 0 To .Count - 1
.PointColor(i) = .Color
Next i
End With
End If
End Sub
Re: Bar rect.gradient Plots
Posted: Tue Sep 06, 2011 3:01 pm
by 15059326
Thanks a lot Yeray! once again you have solved my problem
Have a great day!
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Wed Sep 07, 2011 7:16 am
by yeray
Hi JAV,
You're welcome!

Re: Bar rect.gradient Plots
Posted: Wed Sep 07, 2011 6:39 pm
by 15059326
Hello!
The graphic is wonderful, but we have two issues:
1. Still have problems with the truncation of the series at the edge.
2. We add the rotation of the graph as a new function, but the ClickOnSeries event is not working properly, it seems like the program misses the original position of the series. We are not sure how come it back to the original position so we could change the color or how we could change de color in the new position of the graphic.
Best regards,
JAV
Re: Bar rect.gradient Plots
Posted: Thu Sep 08, 2011 12:31 pm
by yeray
Hello JAV,
JAV wrote:1. Still have problems with the truncation of the series at the edge.
You could try with a bottom axis SetMinMax call with some extra space both for the minimum and maximum.
JAV wrote:2. We add the rotation of the graph as a new function, but the ClickOnSeries event is not working properly, it seems like the program misses the original position of the series. We are not sure how come it back to the original position so we could change the color or how we could change de color in the new position of the graphic.
This is a known issue already in the wish list to be implemented in future releases (TV52015700).
If you want to come back to the "original" position, you can set it to be orthogonal:
Re: Bar rect.gradient Plots
Posted: Thu Sep 08, 2011 2:42 pm
by 15059326
Thanks a lot Yeray! The graphic is wonderful!
Have a great day!
Best regards,
JAV