Charts not displaying when Road Label is showing

I have a road network that has road names. If the road name is turned on, then when I display bar charts at points where accidents occurred, it does not display anywhere where the bar chart crosses a road name. I used lpcentroid for the road names. I have tried using AvoidCollisions on both the road names and the charts but it is not helping. Another problem is that the bar chart centers itself on the point that it applies to and I would rather have the bottom of the chart at the point. I cannot find anything to do this either. Can anyone help please?
This is the code for the Road names
’ Get the field index for the Road_Label field
fieldIndex = shpRdCentreLine.Table.FieldIndexByName(RdCentreLineLabel)
’ Set up the layers and add them to shape file
With shpRdCentreLine.Labels
.AvoidCollisions = True
.FontName = “Arial”
.FontSize = 6
.FontBold = True
.FontColor = RGB(0, 0, 0)
.FrameVisible = False
.Positioning = lpCentroid
.Visible = False
End With
shpRdCentreLine.GenerateLabels fieldIndex, tkLabelPositioning.lpLongestSegement, False

This is the code for the charts
shpAccidents.Charts.Clear
shpAccidents.Charts.ClearFields
Map1.Redraw

Set injCharts = New Charts
Set injCharts = shpAccidents.Charts
With injCharts
.ChartType = chtBarChart
.BarHeight = 150
.BarWidth = 6
.ValuesVisible = False
.Visible = True
.Thickness = 3
.Use3DMode = True
'.AvoidCollisions = True
End With
injCharts.Generate (tkLabelPositioning.lpFirstSegment)
Set chFatal = New ChartField
With chFatal
.Name = “Fatal”
.Color = utils.ColorByName(tkMapColor.Red)
.index = 4
End With
bool = shpAccidents.Charts.AddField(chFatal)

Set chSerious = New ChartField
With chSerious
.Name = “Serious”
.Color = utils.ColorByName(tkMapColor.Orange)
.index = 5
End With
bool = shpAccidents.Charts.AddField(chSerious)

Set chSlight = New ChartField
With chSlight
.Name = “Slight”
.Color = utils.ColorByName(tkMapColor.Yellow)
.index = 6
End With
bool = shpAccidents.Charts.AddField(chSlight)
Map1.Redraw

Thank you
Colleen Crawford

Hello Colleen.

I don’t have a lot of experience with Charts, and I might have to dummy-up some data in order to recreate your problem. Would you be able to (willing to) attach your Streets and Accidents shapefiles?

That said, here are a couple things you could try, although I don’t know if they’ll solve your problems.

injCharts.VerticalPosition = tkVerticalPosition.vpAboveAllLayers

which might result in drawing the charts above the streets and street labels. You can use a similar setting for the street Labels, depending upon which one you want on top.

and then, for chart positioning relative to the insertion point, consider:

injCharts.OffsetX = nn
injCharts.OffsetY = nn

If there are still issues, could you post a small screenshot of the conflicting results?

Regards,
Jerry.

Thanks so much for the help. Stangely vpAboveAllLayers did not work as no charts showed at all, but I decided to use vpAboveParentLayer and it worked perfectly. The OffsetX and OffsetY can’t really be used as the charts are all different heights depending on the number of accidents.

The dots in the image are where the accidents occurred. As you can see when there are not many accidents the chart is almost in the right place, but the tall charts are centered on the point in the middle of the chart.

I have another question about identify but will post it under a new heading

Regards

Colleen Crawford

Hello again.

I still just wonder if there’s a way to figure out the height of each bar (and therefore, the desired y offset). Are they always rendered the same height, no matter the zoom level, or do they adjust?

I’d have to dig in to the source code to know what I’m talking about, but I’m thinking that you may be able to determine the height based on the values you give it to draw the chart. You could perhaps determine a number of pixels offset based on a multiplier times the number of accidents at that point.

const pixelsPerAccident = 10
OffsetY = (numberOfAccidents at this point * pixelsPerAccident)

I may be way off base, but it’s just a thought.

Regards,
Jerry.

Thanks for the reply. I seem to be a bit stuck on how to identify the field to the accCharts fundtion
Set accCharts = New Charts
Set accCharts = shpAccidents.Charts
With accCharts
.ChartType = chtBarChart
.BarHeight = 300
.BarWidth = 6
.Visible = True
.Thickness = 3
.Use3DMode = True
.OffsetY = [NoOfAccs] * 10
End With
accCharts.Generate (tkLabelPositioning.lpFirstSegment)
fieldIndex = shpAccidents.Table.FieldIndexByName(“NoOfAccs”)
Set chAccs = New ChartField
With chAccs
.Name = “Accidents”
.Color = utils.ColorByName(tkMapColor.Navy)
.index = fieldIndex
End With
bool = shpAccidents.Charts.AddField(chAccs)

I tried putting in the fieldname [NoOfAccs] but it just ignores that.

Regards

Colleen Crawford