Microsoft Chart Controls: Label multiple y values and variable y axis? - c#

I am currently using Microsoft Chart Controls to generate a box plot chart. I have enabled the IsValueShownAsLabel property of the chart's series, but only the first y-value(lower whisker) value is being labeled. Is there a way to enable the labeling of all y-values in the chart?
Also, is there a way to get a different axis for each data point? The different data points of the chart are not related when it comes to value ranges, so many data points with small y-values are difficult to read on the chart. I have currently enabled scrolling as a workaround, but am not satisfied with the result. I would instead like to have a different y-axis for each data point, so that the y-values for each data point take up the full height of the chart, with the min and max whisker values serving as the y-axis minimum and maximum points. Is this possible?

To get different axis you will need to look into the properties under ScaleBreakStyle under AxisY
Set something like
Chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = true;
Chart1.ChartAreas[0].AxisY.ScaleBreakStyle.BreakLineStyle = Charting.BreakLineStyle.Wave;
// set this to an even lower value if required
Chart1.ChartAreas[0].AxisY.ScaleBreakStyle.CollapsibleSpaceThreshold = 15;
Not sure on how to get multiple values but can you try setting those values specifically to the labels in these format #VALY1,#VALY2 depending on the number of Y values available.

Related

Fit as much on the x axis as possible in chart control

I have a chart that has times on X axes. How can I remove the gaps in between the points on the X axes? I think that it might be called interval or scale or something but I'm not sure where in the properties I can find it.
I assume that you are using Microsoft Chart controls and you are trying to fit the "time" labels within the XAxis length.
You can set the LabeAutoFitStyle property of the ChartArea's XAxis as fitted for your requirement. See this MSDN link for different LabelAutoFitStyles.
chart1.ChartAreas[ChartName].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep45;
If you want to change the intervals and number of intervals used in display, use AxisX.Interval and AxisX.IntervalAutoMode property.

Asp.Net ReportViewer Line Chart background

I pass a dataset to my report, which renders a line chart showing a sprint burn down chart. One of the fiends in the dataset is 'PeriodType', which can be either 'Planning, 'Burning' or 'Retrospective'.
The chart shows dates along x axis, and the y axis holds hours.
What I would like to do, is grey the background, where the x axis has a value that is not a 'Burning' period. So the object that is used to create the chart, as mentioned, has a type field I can use.
Is there a way to change the background colour of the x 'columns' based on the flag? Some sort of conditional background colouring? I have searched, but can't seem to find such a handy thing.
Yes, that is possible.
Open the Properties pane, in the BackgroundColor or Color (whichever is relevant) property of the chart, enter an IFF statement like:
=IIF(Str(Fields!PeriodType.Value) <> "Burning", "Gray", "SomeOtherColor")
Hope that helps

using logarithmic scale in Ms chart control

Im trying to create a chart the has a base 10 logarithmic scale for the x axis with a range from 1 to 1000. I seem to be able create the axis during design time but whenever the form is loaded I get an error message saying "Chart Area Axes - A logarithmic scale cannot be used for this axis.
Is this a limitation on the MSChart control? why am I not able to create a log scale on the X Axis?
It is because for a logarithm scale, the values must be greater than zero. Charting.CHart treats empty chart as being consisting of zeros (I know it is weird). This error can be very difficulty to debug. Therefore, it mean that the graph cannot be EMPTY if any of the axis is a logarithm scale. What I normally do is set the axis as linear and the change it immediately after plot on the graph (and checking no zeros or negative values on the logarithm scale). Also, remember to change the axis to linear before clearing the axis and plotting. Hope this helps someone.
I propose to use SuppressExceptions property which allows to ignore some exceptions, also that one connected with zeros in axis with logarithmic scale. I think this is the best solution for that situation instead manipulating data.
chart.SuppressExceptions = true;
It's not just about zeroes but also about having your values in the right datatype. Suppose you're populating the chart with values form a DataTable. If you haven't specified the type, .NET will automatically assume they are strings and thus not be able to plot a logarithmic scale.
incomplete specification of the datatable:
PP = New DataTable
PP.Columns.Add("X-value")
PP.Columns.Add("Y-value")
complete specification:
PP = New DataTable
PP.Columns.Add("X-value", Type.GetType("System.Double"))
PP.Columns.Add("Y-value", Type.GetType("System.Double"))
In the first example the exception will be thrown. In the second it won't.
Not all chart types support logarithmic scales; try changing the chart type e.g. to Line Chart.
Chart types: http://msdn.microsoft.com/en-us/library/dd489233.aspx
ChartType property: http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.series.charttype.aspx

how to change default values of axis to user values

I have created multiple Y-axis in chart and individual scales for each axis by default. Now if user(i) wants to change those default values. I have created one form with textbox for entering scale min and max values.
I have attached an image please have a loot at the image.
now i want to get that text box value and assign to min and max scale of each axis.
Can anyone have the idea how to do it . please help me.
You can modify axis scales using SetMinMax method, for example:
tChart1.Axes.Custom[0].SetMinMax(min, max);
For more information about axis settins please read tutorial 4. Tutorials can be found at TeeChart's program group. For multiple custom axis you may be interested in reading this question.

Display unsorted data in SL3 line chart

I'm having trouble with my Silverlight Chart. My model is unsorted, that is, the sorting is done on the server side. It needs to support year transitions, but as you can see from the screenshot the charting control automatically sorts the model and fills in the gaps. The line sort be ever increasing and not taking a dip on new year.
How can I make the chart display the data in the order specified in the grid control to the left?
Btw, using SL3
alt text http://img705.imageshack.us/img705/7602/unsortedsilverlightchar.png
The line chart is not designed to do the task you seem to be asking. After all the purpose of a line chart is to help the user trace a trend or even visually interpolate an interim value. However if the interval between horizontal points is not linear and always traveling in the same direction such lines meaningless.
I would therefore suggest that the Line chart is not appropriate or that you have some other hidden data which should be used for the Y-axis which would make the lines meaningful.
Alternatives might be to use a Scatter graph or a Column series where the y-axis value has been converted to a string and thus cause the series to use a Category based axis instead of range based one.

Categories

Resources