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
tkMapColor
A list of named constants for some of the well-known colors.
Definition: Enumerations.cs:951
tkChartType
The available types of chart.
Definition: Enumerations.cs:200
Represents a single bar or sector of the chart.
Definition: ChartField.cs:69
int Index
Gets or sets the index of field from attribute table (.dbf) to take values from.
Definition: ChartField.cs:84
uint Color
Gets or sets the colour of the bar or sector.
Definition: ChartField.cs:75
Provides functionality for generation and managing the charts on the map.
Definition: Charts.cs:100
int NumFields
Gets the number of fields which correspond to the bars of sectors depending on chart type.
Definition: Charts.cs:393
bool AddField(ChartField Field)
Adds a field to the chart.
Definition: Charts.cs:108
void AddField2(int FieldIndex, uint Color)
Adds a field to the chart.
Definition: Charts.cs:118
ChartField get_Field(int FieldIndex)
Gets a reference to the field of the chart with the specified index.
Definition: Charts.cs:692
tkChartType ChartType
Gets or sets the type of the charts.
Definition: Charts.cs:171
void ClearFields()
Removes all fields which define bars or sectors of the chart.
Definition: Charts.cs:189
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
Charts Charts
Gets or sets an instance of Charts class associated with the shapefile.
Definition: Shapefile.cs:195
A utils object provides access to a set of utility functions to perform a variety of tasks on other o...
Definition: Utils.cs:20
uint ColorByName(tkMapColor Name)
Returns the numeric representation for the specified color.
Definition: Utils.cs:40
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.