Hi I am migrating an old software written in Delphi to .net Winform application. Every things works perfectly well except I could not find a chart hover functionality in .net version. Please see attached image
Hover option in Delphi version
In Delphi version when I hover the mouse over the series, it highlights the line with red color and this was built in functionality in Delphi chart. see attached image
Following is the effect.
I would like to achieve the same in .net version, please advice how to do this.
Thankyou
Hover support in .net version.
-
- Newbie
- Posts: 5
- Joined: Fri Jun 10, 2016 12:00 am
Re: Hover support in .net version.
i am using TeeChartNET2016_4.1.2016.05120.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Hover support in .net version.
This functionality is not presently available in TeeChart.NET, but some of it can be replicated using the current public API with code similar to the following:netdeveloper wrote:i am using TeeChartNET2016_4.1.2016.05120.
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Line line = new Line(tChart1.Chart);
line.FillSampleValues();
tChart1.Legend.ResizeChart = false;
tChart1.Legend.Left = tChart1.Width - 70;
tChart1.Legend.Top = 100;
tChart1.Legend.CustomPosition = true;
tChart1.Panel.MarginRight = 10;
tChart1.MouseMove += TChart1_MouseMove;
}
private int seriesIndex = -1;
private int legendIndex = -1;
private string legendItem = null;
private void TChart1_MouseMove(object sender, MouseEventArgs e)
{
ChartClickedPart chartPart = tChart1.Chart.CalcClickedPart(e.Location);
Action<Series, int> DoIndSeries = (ASeries, AIndex) =>
{
if (seriesIndex > -1)
ASeries[seriesIndex + 1].Color = ASeries.Color;
seriesIndex = AIndex;
ASeries[seriesIndex + 1].Color = Color.Red;
};
Action<Series> DoSeries = (ASeries) =>
{
if (seriesIndex > -1)
ASeries[seriesIndex + 1].Color = ASeries.Color;
seriesIndex = ASeries.Clicked(e.Location);
ASeries[seriesIndex + 1].Color = Color.Red;
};
Action DoLegend = () =>
{
LegendItem item;
if(legendItem != null)
{
item = tChart1.Legend.Items[legendIndex];
item.Text = legendItem;
}
legendIndex = tChart1.Legend.Clicked(e.X, e.Y);
legendItem = tChart1.Legend.Items[legendIndex].Text;
tChart1.Legend.Items[legendIndex].Text = "*" + legendItem + "*";
};
Action<int> DoIndLegend = (AIndex) =>
{
LegendItem item;
if (legendItem != null)
{
item = tChart1.Legend.Items[legendIndex];
item.Text = legendItem;
}
legendIndex = AIndex;
legendItem = tChart1.Legend.Items[legendIndex].Text;
tChart1.Legend.Items[legendIndex].Text = "*" + legendItem + "*";
};
Action<Series> Reset = (ASeries) =>
{
if (seriesIndex > -1)
ASeries[seriesIndex + 1].Color = ASeries.Color;
if (legendItem != null)
{
LegendItem item = tChart1.Legend.Items[legendIndex];
item.Text = legendItem;
}
};
switch (chartPart.Part)
{
//case ChartClickedPartStyle.None:
// break;
case ChartClickedPartStyle.Legend:
DoLegend();
DoIndSeries(tChart1[0], legendIndex);
break;
//case ChartClickedPartStyle.Axis:
// break;
case ChartClickedPartStyle.Series:
DoSeries(chartPart.ASeries);
DoIndLegend(seriesIndex);
break;
//case ChartClickedPartStyle.Header:
// break;
//case ChartClickedPartStyle.Foot:
// break;
//case ChartClickedPartStyle.ChartRect:
// break;
//case ChartClickedPartStyle.SeriesMarks:
// break;
//case ChartClickedPartStyle.SeriesPointer:
// break;
//case ChartClickedPartStyle.SubHeader:
// break;
//case ChartClickedPartStyle.SubFoot:
// break;
//case ChartClickedPartStyle.AxisTitle:
// break;
default:
Reset(tChart1[0]);
break;
}
}
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 5
- Joined: Fri Jun 10, 2016 12:00 am
Re: Hover support in .net version.
Thankyou Christopher.
this is exactly what i was looking to implement. but one problem when mouse leaves the series it should re apply series color on the line instead of red. Currently when mouse leaves the series it left the line red. please see attached image
can you tell me how to reset the color when mouse leaves the series...?? so as per example if mouse leaves the series it should be green..
this is exactly what i was looking to implement. but one problem when mouse leaves the series it should re apply series color on the line instead of red. Currently when mouse leaves the series it left the line red. please see attached image
can you tell me how to reset the color when mouse leaves the series...?? so as per example if mouse leaves the series it should be green..
-
- Newbie
- Posts: 5
- Joined: Fri Jun 10, 2016 12:00 am
Re: Hover support in .net version.
hi also i am using following code to create 12 series in chart
//now it is not working with that series...
Code: Select all
tChart1.Aspect.View3D = false;
tChart1.Panel.Bevel.Inner = BevelStyles.None;
tChart1.Panel.Bevel.Outer = BevelStyles.None;
Graphics3DDirect2D D2D = new Graphics3DDirect2D(tChart1.Chart);
D2D.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
D2D.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
tChart1.Graphics3D = D2D;
tChart1.Graphics3D.BufferStyle = BufferStyle.None;
tChart1.Axes.Bottom.Grid.Visible = false;
for( w = 0; w<12;w++)
{
series = tChart.Series.Add(new Steema.TeeChart.Styles.FastLine() { LinePen = p, Color=Color.Black });
series.Color= Color.Black;
series.Tag = w;
}
/// some where in code adding points like this
///
chartControl.Chart.Series[w].Add(x, y);
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Hover support in .net version.
The code I posted does this, but only does so if there is one series in the chart. You will need to modify the code so it keeps a record of the last series, in a similar way my code snippet keeps a record of the last seriesIndex.netdeveloper wrote:can you tell me how to reset the color when mouse leaves the series...?? so as per example if mouse leaves the series it should be green..
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |