Manish
Manish

Reputation: 31

How to display Axis Labels for Stacked Column chart ( Asp.net chart control )?

I'm using ASP.NET Chart Controls for displaying some data. I'm not pulling any data from the database through a dataset. I'm adding them manually. I don't know how to add AxisLabels to X-axis or Y-axis. I've tried using Axis.title, customlabels.Add() etc.. but I couldn't display anything.

And I've this stacked column chart which has columns added through a for loop. How to add different AxisLabels to it?

for (int i= 0; i< 10; i++)

{

     Chart1.Series["1"].Points.AddY(5);

     Chart1.Series["2"].Points.AddY(8);

}

How do I add AxisLabels to these 10 columns ?

Thanks, Manish

Upvotes: 0

Views: 7789

Answers (2)

Manish
Manish

Reputation: 31

Chart1.Series(1).Points(i).AxisLabel = val;

This itself is the answer for the question. I was writing AxisX.Enabled = false; that's why I wasn't able to display axis labels for AxisX.

Upvotes: 1

Precious Roy
Precious Roy

Reputation: 1086

I'd have to know the schema for the chart to know exactly how to iterate through it and assign values. But an example syntax could be doing something like:

for (int i = 0; i < Chart1.Series(1).Points.Count; i++)
{
    string val = "5";

    Chart1.Series(1).Points(i).AxisLabel = val;
}

then you could do the same thing for the other:

for (int i = 0; i < Chart1.Series(1).Points.Count; i++)
{
    string val = "8";

    Chart1.Series(2).Points(i).AxisLabel = val;
}

Upvotes: 0

Related Questions