We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

how to show dates with fancytooltip

i have a chart which is using a datattable to access the values x and y values. x values are dates. if i use fancy tool tip the date part comes up wierd. is there a special way to handle dates in sycnfusion for fancytooltip to display.


below is the src code for the chart
ChartSeries series = this._viewControl.Model.NewSeries("Time Line Chart");// , ChartSeriesType.StepLine);
ChartDataBindModel model = new ChartDataBindModel(ds, "dat1");
this._viewControl.model = model;
model.XName = "Date";
model.YNames = new string[] { "values" };
series.SeriesModelImpl = model;
series.Type = ChartSeriesType.StepLine;
this._viewControl.Indexed = false;
this._viewControl.Series.Add(series);
this._viewControl.PrimaryXAxis.DrawGrid = true; ;
this._viewControl.PrimaryYAxis.DrawGrid = true;
this._viewControl.PrimaryXAxis.AutoValueType = false;
this._viewControl.PrimaryXAxis.ValueType = ChartValueType.DateTime;
this._viewControl.PrimaryXAxis.DateTimeFormat = "MM/dd/yyyy";
this._viewControl.PrimaryXAxis.LabelIntersectAction = ChartLabelIntersectAction.MultipleRows;
//set Chart Axis Range
this._viewControl.ChartArea.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
this._viewControl.ChartArea.PrimaryYAxis.Range.Min = 0;
this._viewControl.ChartArea.PrimaryYAxis.Range.Max = 191875553;
this._viewControl.Legend.Visible = true;
this._viewControl.Series3D = true;
// The Primary Axes are set with DateTime values.
this._viewControl.PrimaryXAxis.IntervalType = ChartDateTimeIntervalType.Days;

// Avoids overlapping of Axes labels.
this._viewControl.PrimaryXAxis.LabelIntersectAction = ChartLabelIntersectAction.Rotate;
//information abt chart labels
this._viewControl.Text = "TIme Line Chart";
this._viewControl.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

//zooming for chart
this._viewControl.EnableXZooming = true;
this._viewControl.ZoomFactorX = .5;
this._viewControl.EnableYZooming = true;
this._viewControl.ZoomFactorY = .5;
this._viewControl.HidePartialLabels = false;

// Display ToolBar

this._viewControl.ShowToolbar = true;
this._viewControl.ToolBar.DockingFree = true;

// Chart Area Tooltips
// this._viewControl.ShowToolTips = true;
//this._viewControl.ChartToolTip= "Chart Area";

// Series points Tooltips
//series.PointsToolTipFormat = "Notional:{{4}";
series.FancyToolTip.Visible = true;
series.FancyToolTip.Alignment = TabAlignment.Top;


//implement InteractiveCursor in a chart
// ChartInteractiveCursor Icursor = new ChartInteractiveCursor(_viewControl.Model.Series[0]);
//this._viewControl.ChartArea.InteractiveCursors.Add(Icursor);

// Set the range for the Axes.
DateTime date1;
date1 = DateTime.Now;
this._viewControl.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
this._viewControl.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(date1, date1.AddMonths(150), 15, ChartDateTimeIntervalType.Months);
//this._viewControl.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(date1, date1.AddYears(20), 1, ChartDateTimeIntervalType.Years);


3 Replies

J. J.Nagarajan Syncfusion Team June 16, 2008 12:30 PM UTC

Hi Warude ,

If your intention is to show the tooltip of DateTime values of X axis when hovering the series, then you have to handle ChartRegionMouseHover event and have to find the correct series value by getting corresponding Chart point from mouse coordinate. Then you have to display its using external tooltip. Please refer to the attached sample that demonstrates this completely.

http://help.syncfusion.com/samples/Chart.Windows/F74318/main.htm

Please let me know if this helps.

Thanks,
Nagaraj



WE Wen July 17, 2013 12:36 AM UTC

Hi,
   I have the same problem. I couldn't open the sample url. Can you provide me the new link to that sample? Thank you.


Best,
Wen


AT Anandaraj T Syncfusion Team October 7, 2013 06:20 AM UTC

Hi Wen,

Thanks for using Syncfusion products.

The sample url link is currently not available, so we have created a simple sample for displaying date time values in tooltip.

Please refer the following code snippet to achieve this:

<code>

[CS]

 

        void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)

        {

            ChartSeries series = sender as ChartSeries;

            args.Style.ToolTip = "XValue: " + series.Points[args.Index].DateX + "YValue: " + series.Points[args.Index].YValues[0];

        }

<code>

For more information about tooltip, please refer our online documentation in the following link:

ToolTip

Please let us know if you have any concern.

Regards,

Anand



FancyTooltip_d55a64b4.zip

Loader.
Live Chat Icon For mobile
Up arrow icon