I have a line chart with a numeric data series (1,5) (2,1.5)(3,1.5)(4,1.5) as the data source.
The chart is rendered fine but I want to see 0 in x axis and y axis. I added a numeric datapoint(0,"0")
so it shows up on the chart. But I do not want this datapoint to be included in the line. Is there anyway to
have 0,0 or zero aligned axes but chart plots only for the data values. Any help is appreciated.
Try setting chart.Data.ZeroAligned = true
No, that doesnt work. I am assuming it will work only with datatable/dataset as data source?
I tried that before and did not work. But I figured out why. I was adding the series to the linechart setting null handling of spline chart. Anyways now it is working as needed. Thank you for your help.
NullHandling is chart type specific. When you use properties under chart.LineChart it will only affect line charts. Use chart.SplineChart.NullHandling instead for spline charts.
That worked! Thanks...I changed the chart type to spline chart and then it plots the point again.
Any reason? Clients want a smooth curve.....
Setting ZeroAligned to true will only affect numeric axes. Since your X axis is string based, ZeroAligned will have no effect on it. However, you can still use one empty point as long as you set NullHandling to DontPlot. Here's an example:protected void Page_Load(object sender, EventArgs e){ NumericSeries numLineChart = new NumericSeries(); numLineChart.Points.Add(new NumericDataPoint(0, "0", true));
for(int i=1; i<5;i++) { numLineChart.Points.Add(new NumericDataPoint((double)i, i.ToString(), false)); }
//Display the line chart UltraChart ucLineChart = (UltraChart)this.FindControl("UltraChart_Line"); ucLineChart.Series.Add(numLineChart); //ucLineChart.Data.ZeroAligned = true; ucLineChart.LineChart.NullHandling = NullHandling.DontPlot;}
I am using a line chart and not a composite chart. The Line chart is taking a numeric data series.
Following is the code:
NumericSeries numLineChart = new NumericSeries();//data source for the line chart
//Add a datapoint for (0,0) numLineChart.Points.Add(new NumericDataPoint(0,"0", true)); int i = 1;
foreach(DataRow dr in childRows) { numLineChart.Points.Add(new NumericDataPoint((double)dr["Value"], i.ToString(), false)); i++; }
//Display the line chart UltraChart ucLineChart = (UltraChart)scc.FindControl("UltraChart_Line"); ucLineChart.LineChart.ChartComponent.Series.Add(numLineChart);