Page 1 of 1
Hover support in .net version.
Posted: Tue Jun 14, 2016 5:44 pm
by 15678498
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
- 1.PNG (18.92 KiB) Viewed 9471 times
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.
- 1b.png (5.14 KiB) Viewed 9462 times
I would like to achieve the same in .net version, please advice how to do this.
Thankyou
Re: Hover support in .net version.
Posted: Tue Jun 14, 2016 5:50 pm
by 15678498
i am using TeeChartNET2016_4.1.2016.05120.
Re: Hover support in .net version.
Posted: Wed Jun 15, 2016 1:27 pm
by Christopher
netdeveloper wrote:i am using TeeChartNET2016_4.1.2016.05120.
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:
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;
}
}
Re: Hover support in .net version.
Posted: Wed Jun 15, 2016 9:37 pm
by 15678498
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
- Untitled-1.png (8.85 KiB) Viewed 9422 times
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..
Re: Hover support in .net version.
Posted: Wed Jun 15, 2016 11:41 pm
by 15678498
hi also i am using following code to create 12 series in chart
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);
//now it is not working with that series...
Re: Hover support in .net version.
Posted: Thu Jun 16, 2016 7:49 am
by Christopher
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..
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.