This is a migrated thread and some comments may be shown as answers.

Customizing Axes

5 Answers 41 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 12 Aug 2010, 12:00 PM
Hi
Is it possible to customize Y Axis for a Gantt (or rather any chart type) Chart like the images attached?

Thanks

Any Update?

5 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 16 Aug 2010, 05:58 PM
Hello Vikas,

RadChart supports only a single level/layer of axis item labels and it would not be possible to achieve the desired axis item label "grouping".


Greetings,
Freddie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vikas
Top achievements
Rank 1
answered on 17 Aug 2010, 06:39 AM
Thanks for the reply.
But it is not a good news for me. :(
Ok. Can you please let me know if I can at least display y axis (or any axis) item's labels to appear between two major ticks? Currently they are appearing just above the Major tick. I need to show them between the current and next Major tick.

Hope this can be done at least!!! :)
0
Giuseppe
Telerik team
answered on 19 Aug 2010, 04:37 PM
Hi Vikas,

You can customize the axis item label position manually like this:

ASPX
<telerik:RadChart ID="RadChart1" runat="server" SeriesOrientation="Horizontal" OnBeforeLayout="RadChart1_BeforeLayout">
    <Series>
        <telerik:ChartSeries Type="Bar">
            <Items>
                <telerik:ChartSeriesItem YValue="10" />
                <telerik:ChartSeriesItem YValue="20" />
                <telerik:ChartSeriesItem YValue="30" />
                <telerik:ChartSeriesItem YValue="40" />
                <telerik:ChartSeriesItem YValue="50" />
                <telerik:ChartSeriesItem YValue="60" />
                <telerik:ChartSeriesItem YValue="70" />
            </Items>
        </telerik:ChartSeries>
    </Series>
</telerik:RadChart>

C#
protected void RadChart1_BeforeLayout(object sender, EventArgs e)
{
    for (int i=0; i < RadChart1.PlotArea.YAxis.Items.Count; i++)
    {
        ChartAxisItem axisItem = RadChart1.PlotArea.YAxis.Items[i];
        axisItem.Appearance.Position.Auto = false;
        axisItem.Appearance.Position.X = 52 + i * 37;
        axisItem.Appearance.Position.Y = 270;
 
        if (i == RadChart1.PlotArea.YAxis.Items.Count - 1)
            axisItem.TextBlock.Visible = false;
    }
}




Sincerely yours,
Freddie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vikas
Top achievements
Rank 1
answered on 19 Aug 2010, 06:00 PM
Thanks. I will give it a try. But I am not able to understand what are the factors used in following expressions.

52 + i * 37


I mean how do I calculate value in place of 52 and 37. I think these values will change according to the width and height of the graph and number of item shown on the axis. So, can you please provide me that relation?
0
Giuseppe
Telerik team
answered on 24 Aug 2010, 01:38 PM
Hello Vikas,

Here is a sample code snippet that demonstrates the relation:
protected void RadChart1_BeforeLayout(object sender, EventArgs e)
{
    double chartWidth = RadChart1.Width.Value;
 
    double leftMarginPercent = RadChart1.PlotArea.Appearance.Dimensions.Margins.Left.Value;
    double leftMarginPixel = chartWidth * leftMarginPercent / 100;
 
    double rightMarginPercent = RadChart1.PlotArea.Appearance.Dimensions.Margins.Right.Value;
    double rightMarginPixel = chartWidth * rightMarginPercent / 100;
 
    double plotAreaWidth = chartWidth - (leftMarginPixel + rightMarginPixel);
 
    double axisItemWidth = plotAreaWidth / RadChart1.PlotArea.XAxis.Items.Count;
    double halfAxisItemWidth = axisItemWidth / 2;
 
    for (int i = 0; i < RadChart1.PlotArea.YAxis.Items.Count; i++)
    {
        ChartAxisItem axisItem = RadChart1.PlotArea.YAxis.Items[i];
        axisItem.Appearance.Position.Auto = false;
        axisItem.Appearance.Position.X = (float)((leftMarginPixel + halfAxisItemWidth - 10) + i * axisItemWidth);
        axisItem.Appearance.Position.Y = 270;
 
        if (i == RadChart1.PlotArea.YAxis.Items.Count - 1)
            axisItem.TextBlock.Visible = false;
    }
}



Sincerely yours,
Freddie
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart (Obsolete)
Asked by
Vikas
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Vikas
Top achievements
Rank 1
Share this question
or