Welcome Guest Search | Active Topics |

axisLabelCreating event
mattti
#1 Posted : Monday, August 11, 2014 6:25:51 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/6/2014(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

I have one problem with displaying custom labels in chart on horizontal(bottom) axis. If I change the text from original value to my custom value, which is a string with much more characters than original value string, then this new label is padded from the left to fit in the visible chart area. It happens to the first label on bottom axis if the original value is close enough to the zero value. It has something to do with the fact that the graph is computed before the change to the labels is made. Is there anything i can do to make it work?

Code:
.bind('axisLabelCreating', function (e, data) {

         if (data.context.axis.location === 'bottom') {
           
               data.text += "*******************************************";                         
            }
         }
      })
Ivan
#2 Posted : Monday, August 11, 2014 10:25:12 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 try:
Code:
axis.LinearAxis(Location.Bottom).Labels(el => el.HorizontalAlignment(HorizontalAlignment.Right));

or:
Code:
axis.LinearAxis(Location.Bottom).Labels(el => el.ShowFirstLabel(false));
Best,
Ivan Petrov
jqChart Inc.
geotruck
#3 Posted : Tuesday, August 12, 2014 3:28:41 AM(UTC)
Rank: Newbie

Groups: MvcChart, Registered
Joined: 8/11/2014(UTC)
Posts: 5

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
mattti is geotruck from now on :).

I always need to display first and last label. So I cannot use .ShowFirstLabel(false) nor can i use .HorizontalAlignment(HorizontalAlignment.Right)) because in this case the last label would be padded. What you suggest would be possible if label had property attached, something like this:

Code:
.Labels(l => l.HorizontalAlignment(l.IsFirst? HorizontalAlignment.Right : l.IsLast ? HorizontalAlignment.Left : HorizontalAlignment.Center))
Ivan
#4 Posted : Tuesday, August 12, 2014 3:41:40 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)
Is it possible to send us your exact sample to support@jqchart.com, so we can try adapting it?
Best,
Ivan Petrov
jqChart Inc.
geotruck
#5 Posted : Tuesday, August 12, 2014 5:46:36 AM(UTC)
Rank: Newbie

Groups: MvcChart, Registered
Joined: 8/11/2014(UTC)
Posts: 5

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I used your sample here
http://www.jqchart.com/a...rtTypes/StackedBarChart

just add the script to catch the event
Code:
$(function () {

      $('#jqChart')
         .bind('axisLabelCreating', function (e, data) {
            if (data.context.axis.location === 'bottom') {

               data.text += " - label is padded";
            }
         });
   });


and play with razor, change horizontal alingment from Left to Right
Code:
axis.LinearAxis(Location.Bottom)
      .ExtendRangeToOrigin(true)
      .Labels(l => l.HorizontalAlignment(HorizontalAlignment.Left))
      .CustomTickMarks(new int[] { 0, 184 }); //the highest data value is 184
      //.ZoomEnabled(true);
Ivan
#6 Posted : Thursday, August 14, 2014 12:53:42 PM(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)
We haven't been able to find a solution for your issue. You can try using rotated labels:
http://www.jqchart.com/aspnetmvc/chart/ChartAxes/AxisLabelsRotation

This is the best approach we can think of.
Best,
Ivan Petrov
jqChart Inc.
Users browsing this topic
Guest (3)
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.099 seconds.