ChartField Class Reference

Represents a single bar or sector of the chart. More...

Collaboration diagram for ChartField:
Collaboration graph

Properties

uint Color [get, set]
 Gets or sets the colour of the bar or sector. More...
 
int Index [get, set]
 Gets or sets the index of field from attribute table (.dbf) to take values from. More...
 
string Name [get, set]
 Gets or sets the name of the chart field. More...
 

Detailed Description

Represents a single bar or sector of the chart.

dot_inline_dotgraph_37.png

Graph description

The chart fields set mapping between bars or sectors of the chart and a fields in the attribute table of the shapefile (see Table). The visual representation of chart field, either bar or sector, depends on Charts.ChartType property.

It's necessary to distinguish the index of bar or sector in the chart and the index of field in dbf table it is bound to. For example, in case the chart contains a single bar which is mapped to the 5-th field of the dbf table, the index of bar for Charts.get_Field() property will be 0 (as there is only one bar in the chart), while ChartField.Index() will return 5 (as it is mapped to the 5 field).

Shapefile sf = some_shapefile;
Charts charts = sf.Charts;
charts.ChartType = tkChartType.chtBarChart;
charts.ClearFields();
// adds a first bar mapped to 6th field of dbf
Utils utils = new Utils();
ChartField bar = new ChartField();
bar.Index = 5;
bar.Color = utils.ColorByName(tkMapColor.Red);
charts.AddField(bar);
// adds one more bar mapped to 9th field
charts.AddField2(8, utils.ColorByName(tkMapColor.Blue)); // index of field, colour
for (int i = 0; i < charts.NumFields; i++)
{
string s = string.Format("Bar index = {0}; mapped to field index = {1}", i, charts.get_Field(i).Index);
Debug.Print(s + Environment.NewLine);
}
// the output:
// Bar index = 0; mapped to field index = 5
// Bar index = 1; mapped to field index = 8
New API 4.8:
Added in version 4.8
Examples:
IntersectionLength.cs.

Property Documentation

◆ Color

uint ChartField.Color
getset

Gets or sets the colour of the bar or sector.

◆ Index

int ChartField.Index
getset

Gets or sets the index of field from attribute table (.dbf) to take values from.

◆ Name

string ChartField.Name
getset

Gets or sets the name of the chart field.

In most cases it should be set equal to the name of the .dbf field from which the data is taken, unless some more comprehensive alias is needed.