Hello. I am using an UltraWebChart.UltraChart bar chart control. I show only ten items in the chart at a time and my Y axis labels show up fine and I concatenate them on my own if they are to long. I run into issues when the chart shows less than 10 items.
I have tried using the Axis.Y.Extent property so the distance between the left edge of the control and the right edge of the y axis stays the same, but the distance still shrinks when there are less than 10 items shown in the chart.
I would rather keep the distance the same so my concatenation code can work correctly, rather than concatenate the labels variably based on the number of items I display in the chart.
Any help would be greatly appreciated.
Thanks
Can you send us your code, so we can look closer at it?
Thanks for the reply. Please find below the code. This code generally works fine. It starts to fail when there are less than 10 items displayed in the chart. I can rewrite the code so it sets the max length of the string based on the number of items in the chart, but it seems like there should be a better way to do this.
/////////////////////////////////////////////////////////////////Initialize DataTable for the chart/////////////////////////////////////////////////////
_graphTable =
new DataTable();
_graphTable.Columns.Add(
"FileName", Type.GetType("System.String"));
"File Size", Type.GetType("System.Double"));
"FullFileName", Type.GetType("System.String"));
////////////////////////Fill the chart datatable during datagrid databind event//////////////////////////////////////////////////////////
switch(i)
{
case 0:
graphDataRow[
"FullFileName"] = cellValue; // We use this one so we can display the full name in the tooltip
if (cellValue.Length > 19)
"FileName"] = Utility.TruncateString(cellValue, 16);
else
"FileName"] = cellValue;
break;
case 1:
cellValue =
Math.Round(Double.Parse(cellValue), MidpointRounding.AwayFromZero).ToString("N0");
e.Item.Cells[i].HorizontalAlign =
HorizontalAlign.Right;
"File Size"] = cellValue;
case 2:
case 3:
///////////////////////////Function for truncating the strings so they fit in the chart label
public static string TruncateString(string theString, int theMaxLength)
retVal = theString.Substring(0, theMaxLength - 3) +
"..."; //in this case we have at least 2 characters to identify the string
}
retVal = theString.Substring(0, theMaxLength);
//if it's that short, we're skipping the ellipses.
retVal = theString;
//////////////////////////////////////////////////////////////////Chart Markup/////////////////////////////////////////////////////////////////////////////////////////
<igchart:ultrachart id="ctlChart" runat="server" Width="460px" Version="6.1" Height="300px" CrossHairColor="Blue" EmptyChartText="Data Not Available." ChartType="BarChart3D" ForeColor="Black" BackColor="#F4F4F4" EnableCrossHair="False" Transform3D-Perspective="50" Transform3D-ZRotation="1" Transform3D-Scale="70" Transform3D-XRotation="120" Transform3D-YRotation="30">
<Data SwapRowsAndColumns="True" ZeroAligned="True">
<EmptyStyle>
<LineStyle DrawStyle="Dash"></LineStyle>
</EmptyStyle>
</Data>
<TitleLeft Location="Left">
</TitleLeft>
<ColorModel ModelStyle="CustomSkin" AlphaLevel="255"></ColorModel>
<Axis>
<X2 Visible="False" TickmarkInterval="0">
<Labels ItemFormatString="<DATA_VALUE:00.##>" VerticalAlign="Center"
Visible="False" HorizontalAlign="Far" Orientation="VerticalLeftFacing">
<SeriesLabels VerticalAlign="Center" HorizontalAlign="Far" Orientation
="VerticalLeftFacing" FormatString=""></SeriesLabels>
</Labels>
<MajorGridLines AlphaLevel="255" DrawStyle="Dot" Color="Gainsboro" Visible="True" Thickness="1"></MajorGridLines>
<MinorGridLines AlphaLevel="255" DrawStyle="Dot" Color="LightGray" Visible="False" Thickness="1"></MinorGridLines>
</X2>
<Z Visible="False" TickmarkInterval="0">
<Labels ItemFormatString="<DATA_VALUE:00.##>"
VerticalAlign="Center" HorizontalAlign="Far" Orientation="Horizontal">
<SeriesLabels VerticalAlign="Center" HorizontalAlign="Far" Orientation="Horizontal"></SeriesLabels>
<MajorGridLines AlphaLevel="255" DrawStyle="Dot" Color="LightGray" Visible="False" Thickness="1"></MinorGridLines>
</Z>
<Z2 Visible="False" TickmarkInterval="0">
<Labels ItemFormatString="" VerticalAlign="Center"
Visible="False" HorizontalAlign="Near" Orientation="Horizontal">
<SeriesLabels VerticalAlign="Center" HorizontalAlign="Near" Orientation="Horizontal"></SeriesLabels>
</Z2>
<X Visible="True" TickmarkInterval="20" LineThickness="1" Extent="30" TickmarkStyle="Smart">
<Labels ItemFormatString="<DATA_VALUE:0.##>" VerticalAlign="Near" HorizontalAlign="Center" Font="Tahoma, 8pt" Orientation="Custom">
<SeriesLabels VerticalAlign="Far" HorizontalAlign="Near" Orientation="Horizontal" Visible="False" FormatString=""></SeriesLabels>
</X>
<Y Visible="True" TickmarkInterval="2" LineThickness="1" Extent="100" TickmarkStyle="Smart">
<Labels ItemFormatString="<ITEM_LABEL>" VerticalAlign="Center" HorizontalAlign="Near" Font="Tahoma, 8pt" Orientation="Horizontal">
<SeriesLabels VerticalAlign="Near" HorizontalAlign="Near" Orientation="Horizontal" FormatString=""></SeriesLabels>
<MajorGridLines AlphaLevel="255" DrawStyle="Dot" Color="DarkGray" Visible="False" Thickness="1"></MajorGridLines>
<Margin>
<Near Value="5"></Near>
<Far Value="5"></Far>
</Margin>
</Y>
<Y2 Visible="False" TickmarkInterval="0">
<Labels ItemFormatString="<ITEM_LABEL>" VerticalAlign="Center" Visible="False" HorizontalAlign="Near" Orientation="Horizontal">
<SeriesLabels VerticalAlign="Center" HorizontalAlign="Near" Orientation="Horizontal" FormatString=""></SeriesLabels>
</Y2>
<PE ElementType="None" Fill="WhiteSmoke"></PE>
</Axis>
<TitleRight Location="Right">
</TitleRight>
<TitleBottom Visible="False" HorizontalAlign="Far" Location="Bottom">
</TitleBottom>
<TitleTop Text="Total Space" HorizontalAlign="Center" Visible="False">
</TitleTop>
<Tooltips FormatString="<DATA_VALUE:0,000.##> MB" Font-Size="X-Small" Font-Names="Tahoma"></Tooltips>