Data Driven Labeling

The most basic means of customizing X Axis labeling is accomplished by passing string values to the chart. This method is effective, however, does not allow Chart FX to play much of a role in determining labeling dynamically. To improve the label handling for Chart FX, the Data Driven Labeling feature has been implemented. Please note this feature is only available for the X Axis and for chart galleries that do not normally support an X value (Bars, Gantt, etc.).

Using this feature in conjunction with the Smart Labeling implementation, developers may create charts with categorical axes charts that include dynamic labeling functionality. By simply passing X Values to chart galleries types that do not normally accept an X Value, developers can configure Chart FX to dynamically label the X Axis.

Lets say that you wish to display a Bar chart and display dates in the X Axis as labels. Previously, developers would need to pass the data and then set the desired string as the label. However, with the data driven feature implemented, simply passing an X Value will instruct Chart FX to use that value as a label and dynamically paint 'nice' labels.

The following code may be used to pass an X Value to a categorical bar chart, utilizing the Data Driven Labeling feature:


Date dateTime = new Date(2005,1,12);

chart1.getAxisX().getLabelsFormat().setFormat(AxisFormat.DATE);
chart1.getAxisX().setLabelAngle((short)90);

chart1.openData(COD.VALUES, 1, 365);
chart1.openData(COD.XVALUES, 1, 365);

for (int i = 0; i < 365; i++)
{
chart1.setValue(0,i) = i * i;
chart1.setXValue(0,i) = dateTime.AddDays(i).ToADate();
}

chart1.closeData(COD.XVALUES);
chart1.closeData(COD.VALUES);