logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Aruna  
#1 Posted : Tuesday, November 17, 2015 1:00:46 PM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Hi epf,

I am working with NVD3 line chart. My x-axis is time and y-axis is amount. I am trying to add '$' as prefix to y-axis values and to tooltip text.

Please find the code snippet as below

chart.xAxis.axisLabel('Time Periods');
chart.yAxis.axisLabel('Amount($)').tickFormat(d3.format('$,'));
chart.margin({left: 100});

Above code snippet gives caption for axis, but "tickFormat(d3.format('$,'))" is not appending $ as prefix.
Please help me get the prefix to values.

Edited by user Wednesday, November 18, 2015 8:13:11 AM(UTC)  | Reason: Not specified

epf  
#2 Posted : Wednesday, November 18, 2015 8:34:52 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Yes I had a try with this:
Code:
//Axis format
chart.xAxis.axisLabel('Time Periods');
chart.yAxis.axisLabel('Amount($)');
chart.margin({left: 100});

YPrimaryValueFormatter = function(value) {
	return d3.format(',')(value).valueFormat();
}

if (chart.xAxis != null && chart.xAxis.tickFormat != null) chart.xAxis.tickFormat(XValueFormatter);
if (chart.yAxis != null && chart.yAxis.tickFormat != null) chart.yAxis.tickFormat(YPrimaryValueFormatter);


But it looks like the d3.format('$,') does not work...it should be a bug in the d3 library currently in use in Seal Report.
Perhaps you can find a workaround, otherwise wait for the next update of SR if the nvd3 library is updated...
thanks 1 user thanked epf for this useful post.
Aruna on 11/18/2015(UTC)
Aruna  
#3 Posted : Wednesday, November 18, 2015 12:01:34 PM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Thanks a lot!

To have $ as prefix, before returning pre-appended the '$' it worked fine for me.


YPrimaryValueFormatter = function(value) {
varible = d3.format(',')(value);
return '$'+varible;
}
thanks 1 user thanked Aruna for this useful post.
epf on 11/18/2015(UTC)
Aruna  
#4 Posted : Thursday, November 19, 2015 10:04:02 AM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Sorry,i need one more info; how can i get the $ amounts on summary table? In summary table of the charts, $ symbol is not displayed. Is there any property to customize the format of the data table content?

Aruna  
#5 Posted : Thursday, November 19, 2015 12:16:11 PM(UTC)
Aruna

Rank: Member

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 17
India

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
I got the answer for my question;We can format the value by writing "Cell script".
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.