Resizing ToolTip

In this topic, we are going to show how to resize the ToolTip inside the chart. Lets explore it using an example.

 

Below is the code for the chart.

 

 

// Create a new instance of Chart
Chart chart = new Chart();

// Set the chart width and height
chart.Width = 500;
chart.Height = 300;

// Create Title
Title title = new Title();

// Set title property
title.Text = "Visifire Sample Chart";

// Add title to Titles collection
chart.Titles.Add(title);

// Create axisX

Axis axisX = new Axis();

 

// Set axis title
axisX.Title = "AxisX Title";

 

// Add axis to AxesX collection
chart.AxesX.Add(axisX);

// Create
axisY
Axis axisY = new Axis();

 

// Set axis title
axisY.Title = "AxisY Title";

 

// Add axis to AxesY collection
chart.AxesY.Add(axisY);

// Create DataSeries
DataSeries dataSeries = new DataSeries();

// Set ToolTipText
dataSeries.ToolTipText = "XAxis:#AxisXLabel \n YAxis:#YValue";


// Set DataSeries property
dataSeries.RenderAs = RenderAs.Column;

// Create a DataPoint
DataPoint dataPoint;

// Create a random class variable
Random rand = new Random(DateTime.Now.Millisecond);

for (int i = 0; i < 5; i++)
{
// Create a new instance of DataPoint
dataPoint = new DataPoint();

dataPoint.AxisXLabel = "AxisXLabel" + i.ToString();

// Set YValue for a DataPoint
dataPoint.YValue = rand.Next(10, 100);

// Add dataPoint to DataPoints collection
dataSeries.DataPoints.Add(dataPoint);
}

// Add dataSeries to Series collection.
chart.Series.Add(dataSeries);

// Add chart to LayoutRoot
LayoutRoot.Children.Add(chart);

 

 

Using the above code, chart will appear with a default ToolTip size as shown below:

 

 

Now if you want to resize the ToolTip, you can do so by setting the FontSize property for ToolTip.

 

 

Visifire.Charts.ToolTip tt = new Visifire.Charts.ToolTip();
tt.FontSize = 10;
chart.ToolTips.Add(tt);

 

 

If you add the above code inside the chart, the chart will appear as shown below:

 

 

As you can see, the ToolTip size is changed.