Page 1 of 1
Customizing MarksTip Tool
Posted: Wed Jan 28, 2009 9:37 am
by 13049497
Hi,
is it possible to change the text format of a markstip tool? For example there is an "Label and Value" style which show something like that "28.01.2009 5" but i want to show in multiline:
"Date: 28.01.2009
Value: 5"
A custom style would be intresting in that case. For example: "Date: %XValue \nValue: %YValue".
Thanks in advance.
Posted: Wed Jan 28, 2009 9:55 am
by narcis
Hi AIS,
Yes, you can do that using MarksTip's GetText event, for example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
line1.XValues.DateTime = true;
Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
marksTip1.Style = Steema.TeeChart.Styles.MarksStyles.XY;
marksTip1.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(marksTip1_GetText);
}
void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
{
int tmp = e.Text.IndexOf(" ");
e.Text = "Date: " + e.Text.Substring(0, tmp) + "\n" +
"Value: " + e.Text.Substring(tmp + 1);
}
Posted: Wed Jan 28, 2009 10:59 am
by 13049497
Thanks for the quick response.
What could i do, if i want to know the series title and the y value? I want only use one markstiptool for all series.
Posted: Wed Jan 28, 2009 11:09 am
by narcis
Hi AIS,
In that case you can do this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
line1.XValues.DateTime = true;
Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line2.FillSampleValues();
line2.XValues.DateTime = true;
Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
marksTip1.Style = Steema.TeeChart.Styles.MarksStyles.XY;
marksTip1.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(marksTip1_GetText);
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
}
private int SeriesIndex = -1;
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
for (int i = 0; i < tChart1.Series.Count; i++)
{
if (tChart1[0].Clicked(e.X,e.Y) != 0)
{
SeriesIndex = i;
break;
}
SeriesIndex = -1;
}
}
void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
{
int tmp = e.Text.IndexOf(" ");
e.Text = "SeriesName: " + tChart1[SeriesIndex].Title + "\n" +
"Value: " + e.Text.Substring(tmp + 1);
}
Posted: Wed Jan 28, 2009 12:21 pm
by 13049497
Hi NarcĂs,
a little correction of your code:
Code: Select all
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
for (int i = 0; i < tChart1.Series.Count; i++)
{
if (tChart1[i].Clicked(e.X, e.Y) != -1)
{
SeriesIndex = i;
break;
}
SeriesIndex = -1;
}
}
void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
{
if (SeriesIndex > -1)
{
int tmp = e.Text.IndexOf(" ");
e.Text = "SeriesName: " + tChart1[SeriesIndex].Title + "\n" +
"Value: " + e.Text.Substring(tmp + 1);
}
}
This solution works, but it is a little bit flickering :-/
Thanks anyway