I am new to the library and I am trying to implement a chart containing several lines where I want to hover or double-click on a line and highlight the whole line, display it's value at the point selected and highlight the value on the x axis, and, display the values at intersection of the line with Y axis.
In the examples that come with ChartDirector, it displays the "data points". A line chart is obtained by joining the data points. When you click on a line, you may not be clicking on a data point, but somewhere between two data points. In the examples in ChartDirector, we will simply snap to the nearest data point.
If you can provide more details, I can modify one of the examples to better fit your requirements.
ChartDirector charts accept data stored in array variables. For real time charts, you just need to update your data arrays in real time and redraw the chart. In this way, the chart will also update in real time. This works for all chart types, including financial charts. You can refer to the real time chart examples that come with ChartDirector as reference.
A real time chart can be always moving. The line may scroll when new data comes in, and the y-axis scale can change. I am thinking, it may not be easy to "hover" over a particular line as the line is constantly moving. So in the attached code, I use mouse click to select the line. As a line can be very thin and hard to click, the code assumes the mouse clicks on the line if it is within 3 pixels from the line.
If you look at the track cursor sample code, ChartDirector can find the data x position that is closest to the mouse x position. I simply iterate all the data sets so I can get the y position as well, and determine if the mouse is close enough to the line. Then I save the data set name.
In another part of the code, there is a subroutine that will set the line width to 3 for a data set with a given name. This can be used to highlight the line.
You can add symbols at certain place by using scatter layers. In standard financial charts, the data arrays for everything are of the same length. So if you have 100 candlesticks, the symbol array should also be 100 in size. The array can be initialized to contain Chart::NoValue, so there would be no symbol initially. Your code can then put data values at the positions that have symbols. This data array can be updated just like other data arrays in your code.
In the attached zip file, I have included two Qt examples. One is modified from the "Realtime Chart with Track Line" sample code, the other from the "Finance Chart Track Line" sample code. You can click on the line to highlight it.
Sorry for this problem. The highlightLine is a function to highlight a line. During development, I tried several highlightLine functions, then I deleted all of them except the one that works best. However, for one of the deleted highlightLine, I forgot to delete the declaration in the header file. So the code contains the declaration but not implementation of a function that should be deleted, causing this issue.
To solve the problem, go to the "trackfinance.h" header file, and delete the highlightLine method there.
I have updated the zip file as attached to contain the corrected "trackfinance.h". You may use the new download if you do not bother to delete the highlightLine function in the header file.