传奇盒系列标题,如何突出LightningChart中的其他图表系列?

时间:2016-05-21 15:04:18

标签: wpf graph charts mouseevent legend

我可以看到,当在ViewXY的LegendBox中将鼠标移动到系列标题上时,系列会突出显示。

我正在使用WPF图表。我有几个系列,我想在同一时间强调。

如何实现这一目标?

1 个答案:

答案 0 :(得分:1)

LegendBox类有 SeriesTitle * 事件。你可以像这样使用它:

m_chart.BeginUpdate();


ViewXY viewXY = m_chart.ViewXY;
viewXY.XAxes[0].ValueType = AxisValueType.Number; 

int seriesCount = 10; 

//Create series that will highlight the other series 

for (int i = 0; i < seriesCount; i++)
{
   PointLineSeries s = new PointLineSeries(viewXY, viewXY.XAxes[0], viewXY.YAxes[0]);
   s.LineStyle.Color = DefaultColors.SeriesForBlackBackgroundWpf[i]; 
   s.Points = GenerateSomeRandomData((i+1) * 20);
   s.Title.Text = "Series " + i.ToString(); 
   viewXY.PointLineSeries.Add(s);
}
viewXY.LegendBox.MoveFromSeriesTitle = false;
viewXY.LegendBox.SeriesTitleMouseClick += LegendBox_SeriesTitleMouseClick;
viewXY.LegendBox.Layout = LegendBoxLayout.Vertical; 

m_chart.EndUpdate();

并像这样定义事件处理程序:

void LegendBox_SeriesTitleMouseClick(object sender, System.Windows.RoutedEventArgs e)
    {
        m_chart.BeginUpdate(); 

        foreach (PointLineSeries s in m_chart.ViewXY.PointLineSeries)
        {
            s.SetHighlight();

            //s.RemoveHighlight(); //To remove highlight, use this 
        }
        m_chart.EndUpdate(); 
    }

然后点击任何系列标题,所有系列都会突出显示。基于series.MouseHighlight属性设置,它变为更亮的粗线,从亮到暗的动画颜色,或保持原始颜色。

All the series get highlighted when you move mouse over any series title in the Legend box

希望这有助于:-)