MBS Chart Director Question

Hi,

I am creating a Bar Graph and I am struggling to align the “Labels” properly on the bottom. The space between the labels are not the same. What am I missing here to acheive this?

Thank you in advance!

[code]
Private Sub mDrawWeeklyEggCountGraph(inArrayData() as Double, inDate as Date)
// The labels for the bar chart
dim labels(-1) as string = array(“Su”,“Mo”, “Tu”, “We”, “Th”, “Fr”,“Sa”,“Total”)

// Create a XYChart object of size 540 x 375 pixels
dim c as new CDXYChartMBS(276,200)
// Add Gradient BackGround
c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight,&hffffff,&hBFBFBF))
call c.setPlotArea(40, 8, 200, 106, c.linearGradientColor(0, 55, 0, 335, &hf9f9ff, &h6666ff), -1, &hffffff, &hffffff)

// Set the x axis labels
call c.xAxis.setLabels labels

// Draw the ticks between label positions (instead of at label positions)
c.xAxis.setTickOffset(0)

// Set axis label style to 8pts Arial Bold
call c.xAxis.setLabelStyle(“SF Old Republic SC”, 7)
call c.yAxis.setLabelStyle(“SF Old Republic SC”, 7)

// Set axis line width to 2 pixels
c.xAxis.setWidth(2)
c.yAxis.setWidth(2)

// Add a multi-bar layer with 3 data sets
dim layer as CDBarLayerMBS
layer=c.addBarLayer(c.kSide,2)
call layer.addDataSet(inArrayData, &h6666ff,“Egg Count”)

// Convert Month Number to String
Dim CurrentMonth as String = fConvertMonthIntToMonthString(inDate.Month)
Dim CurrentMonthLen as Integer = CurrentMonth.len *8
Dim YearString as String = Str(inDate.Year)
WeekEndDate = fFindEndOfWeek(inDate)
NextMonth = fGetNextMonthString(CurrentMonth)
PrevMonth = fGetPrevMonthString(CurrentMonth)
NumOfDaysPrevMonth = fNumOfDaysInMonth(PrevMonth)

// Show Previous month title if we go into the previous month
if WeekEndDate-7 <= 0 Then AddPrevMonTitle = True

If AddPrevMonTitle = False Then
call c.addText(Self.Width/2-CurrentMonthLen,5,CurrentMonth+" “+YearString,“SF Old Republic SC”,9,&h000000)
Elseif AddPrevMonTitle = True Then
call c.addText(Self.Width/2-CurrentMonthLen,5,PrevMonth+” / " + CurrentMonth+" "+YearString,“SF Old Republic SC”,9,&h000000)
End if

// Set bar border to transparent. Use glass lighting effect with light direction
// from left.
layer.setBorderColor(c.kTransparent, c.glassEffect(1,c.kTopLeft,4))

// Configure the bars within a group to touch each others (no gap)
//layer.setBarGap(1, c.kTouchBar)

// Output the chart
WeeklyStats_GraphPicture=c.makeChartPicture
Invalidate(False)

End Sub[/code]

Can you send me a simple project showing the problem?

Thanks for the quick response Christian.
Here is a screen shot. The Bar Graph on the bottom shows the labels “Mo Tu We” etc. They are not equally spaced apart as it is hard to see, but when I run a loop trying to iterate a drawstring label under it an even amount of space it fails to line up.

The only reason the numbers in the above screen shot look ok is because I am hard coding each of their X values due to the inconsistency between label markers.

Here is a better example. Same Code Above but Ill also show the Drawstring I am using.


This is in the Paint Event of my Container. Notice that the screen shot shows the number labeling not in sync with the chart's label markers. You can see that I am evenly spacing out my number labels. Thanks!!

     dim startvalue as Integer = 196
    For i as integer = 0 to 6
    g.drawstring(Str(WeekEndDate),startvalue,me.Height-4)
    startvalue = startvalue - 24
    WeekEndDate = WeekEndDate - 1
    
  next i

So the 17 there is wrong?
How did you draw them?

[quote=88099:@Christian Schmitz]
This code is in my containers paint event that draws the numbers (WeekendDate).
dim startvalue as Integer = 196
For i as integer = 0 to 6
g.drawstring(Str(WeekEndDate),startvalue,me.Height-4)
startvalue = startvalue - 24
WeekEndDate = WeekEndDate - 1

next i[/quote]

[quote=88099:@Christian Schmitz]So the 17 there is wrong?
How did you draw them?[/quote]
No Worries Christian, I just made the setPlotArea a bit wider and will have to live with the misalignments. I just have spent too much time yesterday and today on it.