Welcome Guest Search | Active Topics |

Format Date in Data point label
Krupa
#1 Posted : Wednesday, November 7, 2012 1:39:34 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/30/2012(UTC)
Posts: 26

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
How to format the date in data point label. I need the date in 'mm/dd HH:MM' format.

My Code for tooltip and data point lable:

$('#graph').bind('tooltipFormat', function (e, data)
{
return "<b>" + data.series.title + "</b></br>" +
"X = " + data.y + "</br>" +
"Y = " + data.chart.stringFormat(data.x, "mm/dd HH:MM");
});

$('#graph').bind('dataPointLabelCreating', function (event, data) {
data.text = data.x;
});

Currently I am displaying the formatted date in tool tip. I wish to display the formatted date in Data point label.

Please help.

Ivan
#2 Posted : Wednesday, November 7, 2012 6:50:20 AM(UTC)
Rank: Administration

Groups: Administrators, Moderator, Registered
Joined: 11/5/2012(UTC)
Posts: 131

Thanks: 0 times
Was thanked: 15 time(s) in 15 post(s)
You can do this with using the following code:


Code:
$('#graph').bind('dataPointLabelCreating', function (e, data) {

                var context = data.context;
                var date = context.chart.stringFormat(context.dataItem[0], "mm/dd HH:MM");
                data.text = date;
            });

$('#graph').jqChart({


Just make sure you're handling the 'dataPointLabelCreating' event before the jqChart declaration.
Best,
Ivan Petrov
jqChart Inc.
Krupa
#3 Posted : Wednesday, November 7, 2012 7:25:20 AM(UTC)
Rank: Member

Groups: Registered
Joined: 10/30/2012(UTC)
Posts: 26

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I am actually using a graph with Date Time Axis.

My Y - Axis is Date Time Axis and X - axis is numeric.

Can I add this date format to the Y- Axis value alone and my X- axis value should be displayed as such.

Please give me a sample code.

Thanks in advance.
Ivan
#4 Posted : Saturday, November 10, 2012 4:48:27 AM(UTC)
Rank: Administration

Groups: Administrators, Moderator, Registered
Joined: 11/5/2012(UTC)
Posts: 131

Thanks: 0 times
Was thanked: 15 time(s) in 15 post(s)
You can modify the code to:

Code:
$('#graph').bind('dataPointLabelCreating', function (e, data) {

                var context = data.context;
                var date = context.chart.stringFormat(context.dataItem[0], "mm/dd HH:MM");
                data.text = date + "  " + data.text;
            });

$('#graph').jqChart({
Best,
Ivan Petrov
jqChart Inc.
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.086 seconds.