简体   繁体   中英

Tooltip label is wrong on MS Chart with more than one series

The original data source returns a table with columns (Timestamp, 1stValue) This chart will work when I have only one series of data (data source):

        MyChart.Series[0].ToolTip = "( #VALX{hh:mmtt}, #VALY )";

The x axis is timestamp as you can see, on the format of the X data points. When I hover the mouse on the data point I can see the tooltip displaying "( 10:20AM, 520 )"

however when I have two series using another data source that returns a table with columns: (TimeStamp, 1stValues, 2nd Values)

        MyChart.Series[0].ToolTip = "( #VALX{hh:mmtt}, #VALY )";
        MyChart.Series[1].ToolTip = "( #VALX{hh:mmtt}, #VALY )";

it only works for the first series, when I hoover the mouse over the second series I have this "( hh:mmtt, 520 )", it looks as if there's garbage on the data for the X value (which are the same values as the ones for the second series), Y values load just fine, when I use "( #VALX, #VALY )" and I hover the mouse on the data point I get "( 40826.291666, 520)"

This is how I link the data source with the Chart

        MyChart.DataBindTable(datasrc, "DateTime");

The lame solution is to overwrite the X values of the second series with the ones from the 1st series, but isn't just the purpose of the DataBindTable afterall?

I got it, for some reason the second series' values type are set back to double instead of DateTime (the type of the X axis used in DataBindTable), all you have to do is set the value type to DateTime like this:

MyChart.Series[1].XvalueType = ChartValueType.DateTime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM