If the x-axis is not labelled in a XY chart, do the values along the x-axis reflect the offsets into the array holding the data?
Data AcQuisition (DAQ) recorders can record sound/noise. Sometimes while recording, a user may want to add a note/annotation to explain the data as it is being recorded such as "engine started". I think your measurement cursor may be able to help. If I have a button labelled "Add note" and a user clicks it, the code would get the value of the x-axis for the measurement cursor and prompt the user to enter a note. The x-axis value would be index into the array holding the data. The data would be saved in a file and the notes and corresponding offsets would be stored in another file.
For playback of the data, is it possible to show the data points and notes in the same XY chart? They would appear/disappear as the user scrolled along the x-axis.
If the XY chart was on the left of the screen and a list of the annotations was on the right side of the screen, clicking a note, the code would get the offset into the data and the x-axis of the XY chart would automatically scroll to reveal the note and the surrounding data points. Is this possible?
I think an annotation cursor would be a very nice feature.
What you need can certainly be done with ChartDirector.
If your code do not provide x-coordinates to the chart layers (that is, Layer.setXData is not used), ChartDirector will use the array index as the x-coordinates. Note that the array index refers to the array that is passed to ChartDirector for plotting (eg. the array used in addLineLayer or addDataSet). It is not necessarily the same as the array of your original data.
For example, for a chart that can zoom and scroll, you may have a very large array, and you only need to display a small portion of it on the chart at any instance. In our sample code, we usually only pass the visible part of the array to the chart for display. The exact code depends on your programming language. It may be by moving a pointer (in C++), or by slicing the array (eg. in C#). So the chart does not see the entire array. It only sees the visible part of the array.
For your case, if the chart can zoom and scroll, you need to keep track of the index to your full array. So if you might just create the x-coordinates as well. Just create an array and put the numbers 0, 1, 2, 3, ... in it as the x-coordinates. If you do not want the x-coordinates to appear on the x-axis, just set the x-axis label color to transparent.
In this way, when the use clicks on the chart, you can use getNearestXValue to obtain the x-value of the data point nearest to the mouse. You can then look up the value in your full array. When the chart is scrolled, you can find all annotations that are within the visible range and add them to the chart (or to just add a symbol to represent there is an annotation on the right). If you are using track cursors, you can add them in the track cursor drawing code, or you can add them directly in "drawChart" using BaseChart.addText or other methods.
When the user clicks on annotation on the right, you can programmatically scroll the chart (by adjusting the viewport) so that the annotated x-value is within the visible range.
In some of our sample code, there is a scrollbar to scroll the chart. The scrollbar is not part of ChartDirector but is an external control. When the user drags on the scrollbar, the scrollbar event handler "programmatically" adjust the viewport to scroll the chart. For your case, the button on the right can be handled similarly.