ASP.net chart control - XValueMembers Count - asp.net

This is the first time I use chart control in ASP.net
I did the binding between the chart and a datatable to show the stats of revenue per date
Although,
When the selected dates are more than 9, the chart stops displaying them all on the X axis
It displays only 5
What is the reason?
Any workaround?
Any help would be appreciated

Similar problem was found here, and people there recommends to set up some properties, like this:
Try setting the AxisX Interval property to 1
Chart1.ChartAreas[0].AxisX.Interval = 1
note that you may then also want to change the angle of the labels
And after that, as you'll get a lot of values at axis X, you should change the angle for them. like this:
Chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 45
Note that Chart1 is a Id of your chart, and can be different.

Related

asp.net chart: final series getting cut off when setting .AxisX.Maximum

I'm trying to bind a data table like,
month value
5 345
10 1300
12 450
to an ASP.NET Chart control. My problem is that the data table only contain months that have values while in the chart i want to show the full month range from 1st to the 12th.
So i used
Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 1;
Chart1.ChartAreas["ChartArea1"].AxisX.Maximum = 12;
But when i do this, a part of the final series gets cut off in the middle like this.
I can avoid this issue by making the maximum 13 but that would not be appropriate since i just need to show the months of the year. Please help.
Yes but look at how the x-axis is measured; it is not just 12, then 13. It is 12.2, 12.4, 12.6, 12.8 and then 13.0. So you see if you make 12.0 the maximum you are not going to get the entire bar for the final month. Also your x-axis shouldn't even be on that interval in the 1st place. It should be in whole numbers only since you are measuring months.
An example of using the "Interval" property on an Axis in a bar chart:
<axisx Title="MyValue" Interval="1" IsMarginVisible="false">
I use ASP.NET charts a lot, and the best site is the one below. I highly recommend downloading the FULL .NET project and look at the samples and code. These types of bar charts are trivial, as you will see after looking at some of the examples in the .aspx sample pages.
Samples Environment for Microsoft Chart Controls:
http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418
this is about aligning the series position and controlling the width of series
check links
http://asp-net-example.blogspot.com/2010/09/how-to-use-chart-backimagealignment.html
MS Chart with ASP.NET chart type "column" not showing axis x label if there are more than 9 bar in the chart
http://forums.asp.net/p/1516836/3636476.aspx
also generally useful
http://betterdashboards.wordpress.com/2009/02/11/align-multiple-chart-areas/
http://www.ezzylearning.com/tutorial.aspx?tid=4337488

How to change the X Axis labels programatically on ASP.Net chart control?

I have a line chart that I am building from a SQL Data Reader which is filled from stored procedure with begin and end date parameters.
When the chart is drawn the X axis lables are the day part of the date and time string that are returned. What I would like to do is change that to the hours portion when the range is less than 24 hours.
How do I go about changing the X Axis labels?
TIA
John
I don't have the code right in front of me but you should be able to do this via something like:
chart.ChartArea(0).AxisX.CustomLabels.Add

Zedgraph- Force curve graph to start from y-axis for datetime x points

In Zedgraph (asp.net) I have a datapoint list where the x values are of datetime. When the curve is drawn, the start of the graph does not begin from the y-axis. There's a gap between the y-axis and the first point. I am using XAxis.Scale.MajorUnit = DateUnit.Day.
I see a date tic label at the y-axis level which is a day before the day of the first point. Basically ZedGraph is inserting a new point, a day before, (no value for y) before the first point, creating the gap. Is there a Zedgraph setting to stop this?
When I use textlabels (XAxis.Type = AxisType.Text) instead of datetime labels (XAxis.Type = AxisType.Date), it works fine but I want to use the date type.
Any ideas?
Have a look at these properties:
XAxis.Scale.MinAuto = false;
XAxis.Scale.MinGrace = 0;
XAxis.Scale.Min = (whatever your minimum DateTime is);
Chances are, MinGrace is what you're looking for, and the associated property XAxis.Scale.MaxGrace should control any gap on the maximum side.

Flex LineChart advanced horiztonal axis?

I want to make a line chart that allows the user to select a date range for the data. For example if the date range span is more than 1 month, I want to to have a bar that shows the months, also if the date range is around 30 days or less I want it to show the dates for each day as well. Something like that.
Does anyone have any suggestions?
Thanks!
I would suggest using a DateTimeAxis, and setting the labelUnits property to "days" or "months" as appropriate. The axis will then do all the hard work of grouping your data accordingly.
In your particular case, when the user makes a choice from the combo box, you should have a handler that computes how granular to make the x-axis based on the user's date selections.

FLEX: Make LineChart DATATIP constrain to vertical axis

When making a line chart, Lets say its for business sales for different depts and horizontally is days and vertically is dollars. When you hover over a line it tells a dataTip tells you the sales for that dept. on that day. I want it to show all the depts at the same time, so say you hover over day 3, I want the dataTips for all depts on day 3 to display so you can compare the values for all the sales on the same day. I set the mouseSensitivity for the dataTips to display all the lines at once but I end up getting day 2 for one dept and day 3 for another which is not wanted. This is actually posted as a bug and explained better here: http://bugs.adobe.com/jira/browse/FLEXDMV-1853
I am wondering if anyone can come up with a work-around for this?
Thanks!
I ran into a similar problem to this recently and came up with a solution that also applies to your problem. I had a step LineChart and wanted to display a data tip when the user hovered anywhere on the line instead of just at defined data points.
You can read about the solution I wrote for that problem here: Flex: Customizing data tip location and behavior in a LineChart
You'll have to modify my solution slightly to fit your problem:
On line 47 you can remove the Math.abs(last.y - mouseLoc.y) < 50 check. This constrains the data tips to lines that are within 50 pixels vertically of the mouse.
I'm assuming that you're using the default segment line chart which just draws lines directly between data points. You'll need to modify the code that calculates the line value at a given x-coordinate to work with that chart type. I already find the closest data point to the left of the mouse with lines 33-41 and store it in last. Just get the next data point (which will be the one closest to the right of the mouse) and use something like this to get the value at the mouse:
var slope:Number = (nextPoint.y - last.y) / (nextPoint.x - last.x);
var lineYAtMouse:Number = (slope * (last.x - mouseLoc.x)) + last.y;
var lineValue:Array = line.localToData(new Point(mouseLoc.x, lineYAtMouse));
Then replace lines 69 through 72 with:
hitPoint.x = mouseLoc.x;
hitPoint.y = lineYAtMouse;
hitPoint.xValue = lineValue[0];
hitPoint.yValue = lineValue[1];
I haven't tested these modifications so there could be a bug or 2 but the general idea is there. I hope maybe this is still useful to someone. This question is getting pretty old. :)
Not an answer, but a poor alternative:
You could create your own DataTip renderer that [ahem] mapped the location of every point and drew the tip for each one there.
Basically, you would be duplicating a lot of the code inside the charting classes.
I have the same problem but working on column charts. Was thinking that I could enable the vertical gridLines using backgroundElements and then add a chart event listener for mouse over (which fires when mouse passes over a vertical gridline). Using the localX value, i could compare it to the closest datapoint, maybe.
Brian

Resources