Home › forums › Using CanvasJS › convertPixelToValue convertValueToPixel issue
This topic contains 2 replies, has 2 voices, and was last updated by elcollie 12 months ago.
I am using convertPixelToValue and convertValueToPixel to help me synchronize mouse pointer events across two time series charts. This seems to work well when both data series have the same range of data, see http://jsfiddle.net/elcollie/4azjy2wo/ as the mouseevent is drawn on the second chart accurately.
However, if there a difference in the range of data between the two charts, things go wrong. In this example, http://jsfiddle.net/elcollie/aubxhdw3/ the second chart has less data than the first. The resulting mouseevent are off by between 30 and 45 mins.
Can you advise on how to get the second scenario working accurately?
In the code you have shared, you are trying to trigger mouse event in the second chart based on the value coordinates of the first chart. Instead you can trigger mouse event in the second chart based on the pixel coordinates of the first chart as shown in this updated JSFiddle.
Priyanka M S
I think I need to do it that way because I want the tooltip to appear on the second chart for the same (or very close) timestamp as I mouseover on the first. The pixel location on the first chart is not relevant because of the different y-axis scales of the two charts.
I have worked around the issue for now by padding missing series data with nulls, which gives both charts the same y-axis scale and works well.
You must be logged in to reply to this topic.