Jump to content

 

Photo

Clipping in Column chart when labelstyle is outside


  • Please log in to reply
3 replies to this topic

#1 sunmuk

sunmuk

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 24 February 2012 - 09:44 AM

Hi

I have my columnchart with labels outside set on dataseries, but I see that in this mode the axis values gets clipped.
Please let me know if there is a way to avoid this.

Refer to the below sample code.

<UserControl x:Class="Linecharterror.MainPage"
xmlns="http://schemas.micro...l/presentation"
xmlns:x="http://schemas.micro...infx/2006/xaml"
xmlns:d="http://schemas.micro...ion/blend/2008"
xmlns:mc="http://schemas.openx...atibility/2006"
xmlns:c1="http://schemas.compo...infx/2006/xaml"
mc:Ignorable="d" d:DesignHeight="340" d:DesignWidth="400">


<Grid x:Name="LayoutRoot" Background="White" >
<vc:Chart Name="MyChart" IndicatorEnabled="True" Theme="Theme1" Height="400" Width="340" xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts" ScrollingEnabled="False">
<vc:Chart.Titles>

</vc:Chart.Titles>
<vc:Chart.AxesX>
<vc:Axis IntervalType="Years" ValueFormatString ="yyyy" Interval="1"></vc:Axis>
</vc:Chart.AxesX>
<vc:Chart.Series>
<vc:DataSeries RenderAs="Column" LabelEnabled="True" LabelStyle="Outside" LabelText="" XValueType="Date" ToolTipText="Year:#XValue\nGross:#YValue">
<vc:DataSeries.DataPoints>
<vc:DataPoint XValue="2006-01-01 00:00:00.000" YValue="18.3"/>
<vc:DataPoint XValue="2007-01-01 00:00:00.000" YValue="10.1"/>
<vc:DataPoint XValue="2008-01-01 00:00:00.000" YValue="-6.7"/>
<vc:DataPoint XValue="2009-01-01 00:00:00.000" YValue="19.3"/>
<vc:DataPoint XValue="2010-01-01 00:00:00.000" YValue="-4.2"/>
<vc:DataPoint XValue="2011-01-01 00:00:00.000" YValue="-14.5"/>
<vc:DataPoint XValue="2012-01-01 00:00:00.000" YValue="8.7"/>

</vc:DataSeries.DataPoints>
</vc:DataSeries>

</vc:Chart.Series>
</vc:Chart>
</Grid>
</UserControl>

Attached Files



#2 sharmila

sharmila

    Advanced Member

  • Administrators
  • PipPipPip
  • 697 posts
  • Gender:Female

Posted 24 February 2012 - 10:39 AM

Hi sunmuk,

You are forcing all labels to be displayed on the top of column by setting LabelStyle ="OutSide". So DataPoint labels are clipped as it is going out of the region of PlotArea.

I suggest you not to set LabelStyle property in DataPoints/DataSeries and let the Chart decide whether to display the label inside or outside.

If you really need to force the labels to be displayed Outside then you can set suitable AxisMinimum and AxisMaximum in y-axis so that space is available at the top and bottom to accommodate labels.

Regards,
Sharmila

#3 sunmuk

sunmuk

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 24 February 2012 - 12:03 PM

The data I am feeding my chart is dynamic and is from the database. So I cannot set the axismaximum and axisminumum or iterval.
It would be nice if the chart can adjust those internally rather than me setting it as it varying.

#4 sharmila

sharmila

    Advanced Member

  • Administrators
  • PipPipPip
  • 697 posts
  • Gender:Female

Posted 24 February 2012 - 01:09 PM

Sunmuk,

First I suggest you not to set LabelStyle proeprty in DataSeries. If you really want to set LabelStyle property in DataSeries then you can try the workaround below.

Once the chart is rendered you will have the ActualAxisMaximum, ActualAxisMinimum and ActualInterval of the axis. In the Rendered event of the chart you can add ActualInterval to ActualAxisMaximum and subtract ActualInterval by ActualAxisMinimum in order to get appropriate axis limits. Please check out the code below.

void MyChart_Rendered(object sender, EventArgs e)
{
  Axis axisY = (sender as Chart).AxesY[0];

  MyChart.AxesY[0].AxisMaximum = (Double)axisY.ActualAxisMaximum + (axisY.ActualInterval);
  MyChart.AxesY[0].AxisMinimum = (Double)axisY.ActualAxisMinimum - (axisY.ActualInterval);           
}

Regards,
Sharmila




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users