Hi,
In the examples provided in SamplesBrowser project, the same data is being assigned to both xAxis and series. So, for each dataItem in series, there is a corresponding label in xAxis.
(in your example a value is randomly generated for each month)
public CategoryDataSample() { double curr = 100; double curr2 = 300; String[] months = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; for (int i = 0; i < 12; i++) { curr += Math.random() * 4 - 2; curr2 += Math.random() * 4 - 2; CategoryDataItem newItem = new CategoryDataItem(); newItem.label = months[i]; newItem.setValue(Math.min(curr, curr2)); newItem.highValue = Math.max(curr, curr2); add(newItem); } }
testData = new CategoryDataSample(); testData2 = new CategoryDataSample();
xAxis.setDataSource(testData);
series2.setDataSource(testData2);
Is it possible to have a graph with a 12 month xAxis scale but dataitem for only a couple of the months.
e.g. "Jan": 25, "Mar": 60, "Jul": 42, "Nov": 50
Hello Elton,
You can add points to your underlying data source with a value of Double.NaN in order to create “blank” spaces in the chart which will result in the Labels being added without any data points. For example:
public TestData() {
double curr = 10.0;
double curr2 = 20.0;
String[] months = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
for (int i = 0; i < 12; i++) {
curr += Math.random() * 4.0 - 2.0;
curr2 += Math.random() * 4.0 - 2.0;
TestDataItem newItem = new TestDataItem();
newItem.setLabel(months[i]);
if (i>6 && i < 9)
{
newItem.setValue(Double.NaN);
add(newItem);
}
else
newItem.setValue(Math.min(curr, curr2));
By default the series will stop at the last point value and then continue again when a new value is discovered.
As a side note, if you were missing points in your data but wanted the series to continue over those points, you could set the UnknownValuePlotting property on the series to LinearInterpolate:
lineSeries.setUnknownValuePlotting(UnknownValuePlotting.LINEARINTERPOLATE);
Please let me know if you have any questions.
Sincerely,
Valerie
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support