作成日: 2021/02/19 最終更新日: 2021/02/19
文書種別
使用方法
詳細
既定では、ツールチップにはデータポイントの座標、系列名、インデックスが表示されます。
それ以外のデータポイント関連情報を表示するには、FlexChartのToolTipContentに、表示したいプロパティ名を中括弧で囲んで指定します。
例){propertyName}
例えば、X軸に体重、Y軸に身長を表示する散布図を考えます。
データとして身長(Height)、体重(Weight)のほか、氏名(Name)、年齢(Age)が連結している場合、シンボル上のツールチップにこれらすべてを表示するには、以下のように指定します。
例)flexChart.ToolTipContent = "Name : {Name}¥nAge : {Age}¥nHeight : {Height}¥nWeight : {Weight}";
サンプルプロジェクトの全体的なコードを以下に記載します。
(MainWindow.xaml)
(MainWindow.xaml.cs)
それ以外のデータポイント関連情報を表示するには、FlexChartのToolTipContentに、表示したいプロパティ名を中括弧で囲んで指定します。
例){propertyName}
例えば、X軸に体重、Y軸に身長を表示する散布図を考えます。
データとして身長(Height)、体重(Weight)のほか、氏名(Name)、年齢(Age)が連結している場合、シンボル上のツールチップにこれらすべてを表示するには、以下のように指定します。
例)flexChart.ToolTipContent = "Name : {Name}¥nAge : {Age}¥nHeight : {Height}¥nWeight : {Weight}";
サンプルプロジェクトの全体的なコードを以下に記載します。
(MainWindow.xaml)
<Window x:Class="FlexChartCustomTooltip.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FlexChartCustomTooltip"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<c1:C1FlexChart x:Name="flexChart"></c1:C1FlexChart>
</Grid>
</Window>
(MainWindow.xaml.cs)
using C1.WPF.Chart;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FlexChartCustomTooltip
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
flexChart.ItemsSource = GetPeople();
flexChart.Series.Add(new C1.WPF.Chart.Series()
{
Binding = "Height",
BindingX = "Weight",
SeriesName = "Sample Data",
ChartType = C1.Chart.ChartType.Scatter
});
flexChart.ToolTipContent = "Name : {Name}¥nAge : {Age}¥nHeight : {Height}¥nWeight : {Weight}";
}
public List GetPeople()
{
return new List()
{
new Person(){ Name = "John", Age = 25, Height = 176, Weight = 71},
new Person(){ Name = "Mike", Age = 55, Height = 155, Weight = 68},
new Person(){ Name = "Simon", Age = 14, Height = 182, Weight = 39},
new Person(){ Name = "Riley", Age = 35, Height = 171, Weight = 70},
new Person(){ Name = "Sandra", Age = 18, Height = 165, Weight = 44},
new Person(){ Name = "Billy", Age = 26, Height = 179, Weight = 66},
};
}
}
public class Person
{
public int Age { get; set; }
public string Name { get; set; }
public double Height { get; set; }
public double Weight { get; set; }
}
}
関連情報
旧文書番号
86429