setting minimum level of chart in asp.net - asp.net

By default, minimum level of ASP.NET chart control is 0, I want to set this level to -1. So that 0 value on y-axis can be shown correctly...

This should work.
var chart = new Chart();
//
// Code to define chart areas etc...
//
chart.ChartAreas[0].AxisY.Minimum = -1;

Related

ChartControl: how to disable axis labels when no related series points?

Take a look at the screenshot: there are a few labels on both axis even though there is no related chart points. Can i configure chart control to show labels only when there is some data on chart (see second picture)?
Actual
Desired
If you want to customize the label with a specific axis value then you should handle the ChartControl.CustomDrawAxisLabel event. Please refer to the sample code snippet in the CustomDrawAxisLabel documentation article.
private void chartControl1_CustomDrawAxisLabel(object sender, CustomDrawAxisLabelEventArgs e)
{
AxisBase axis = e.Item.Axis;
if (axis is AxisY || axis is AxisY3D || axis is RadarAxisY)
{
//Put your condition at below two lines..
double axisValue = (double)e.Item.AxisValue;
if (axisValue == 0)
{
e.Item.Text = string.Empty;
}
}
}
Refer these for more information with change of point values:
Conditionally change a chart axis label not based on axis value

.NET Chart Box Plot Bleeding outside chart area

I see that when a Box crosses max and min limit on the Y-axis the box bleeds outside the chart area. Is there a solution/Tweak for this?
Are you setting the Min and Max values yourself or letting the control decide? Try setting them to auto.
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
Try the following:
chart1.ChartAreas[0].AxisY.Crossing = 0;
chart1.ChartAreas[0].AxisX.Crossing = 0;

Telerik RadChart Alternating Background StripLines On ASP Ajax control

I want to show an alternating background colour for the X axis on a line chart on the ASP.Net Ajax RadChart control.
I have found this article that shows the StripLine property for Silverlight and WPF chart control but I cannot find this property on the Ajax control. Maybe I'm just not seeing it - how can I set the background colour to stripe vertically in line with the X axis columns?
In the article mentioned the "AlternateStripLineStyle" is located here:
RadChart1.DefaultView.ChartArea.AxisY.AxisStyles.AlternateStripLineStyle
However the Ajax control does not have an AxisStyles property.
Thanks.
UPDATE: I think this may be possible using the MarkedZones property of the PlotArea but that's not a very elegant solution if indeed it does work.
Telerik themselves provided the following solution which as I suspected uses MarkedZones:
public void GenerateStripLines(RadChart chart, int minValue, int maxValue, int step)
{
for (int i = minValue; i <= maxValue + step; i+=step)
{
Color zoneColor;
if (i % 2 == 0)
zoneColor = Color.White;
else
zoneColor = Color.WhiteSmoke;
var item = new ChartMarkedZone() { ValueStartY = i, ValueEndY = i + step };
item.Appearance.FillStyle.MainColor = zoneColor;
chart.PlotArea.MarkedZones.Add(item);
}
}

How to Force a Flex Chart to Redraw During Runtime

I have a column chart that uses a label function to format the vertical axis. I added a button and want the axis (or chart) to redraw when the button is clicked. Right now, the chart axis renders OK only when initially added to the view state.
I have a function that sets various properties after the chart is initially created. In there, I have tried all these:
myChart.verticalAxis.dataChanged();
myChart.validateNow();
myChart.validateDisplayList();
myChart.validateProperties();
myChart.invalidateDisplayList();
myChart.invalidateProperties();
But they do not change the axis formatting. How can I do this?
The MXML code for the axis is:
< mx:LinearAxis id="verticalAxis" labelFunction="vAxisFormat"/>
The label function is:
private function vAxisFormat(labelValue:Number, previousValue:Object, axis:IAxis):String {
axis.getLabelEstimate();
if (_scale == 1){
return currencyFormatter.format(labelValue/_scale);
}else {
return numberFormatter.format(labelValue/_scale);
}
}
Try updating the data provider. This redraws the graph, so all the components.
Example:
ArrayCollection
arr.refresh ();
XML
char.dataprovider = xmlData
regars

Hide ColumnSeries in Flex Chart

I have a clustered chart with 2 column series. The problem is that sometimes one column's values are so large, the other column is dwarfed. So I added checkboxes to show/hide a given column, and set the visibility of the ColumnSeries as such:
visible="{checkbox.selected}" includeInLayout="{checkbox.selected}"
This shows/hides the given column correctly, the problem is that it does not reset the Y-Axis, so the other column never actually grows in height (when the column with the larger values is hidden). I've tried resetting the data provider, validating/invalidating the chart, and nothing seems to work.
Anyone have any ideas?
Thanks!
I would imagine from your description that you actually need to remove the series from the chart. So
public function onToggle(){
var newSeries:Array = [];
if(bigSeries.selected) {
newSeries.push(bigSeries);
}
if(smallSeries.selected) {
newSeries.push(smallSeries);
}
chart.series = newSeries;
}

Resources