I have a dotnetcharting chart that I want to display as a Stacked Bar chart, but when it actually displays it shows up as a regular bar chart with the bars next to each other.
I have Chart.YAxis.Scale = Scale.Stacked; and I checked and it is getting set properly. Does anyone know why it isn't working properly?
I found that if you create a new Axis for a Series you have to change the Series's Axis and not the Chart's Axis. So what I needed to do was: timeLossStackedBarChart.SeriesCollection[0].YAxis.Scale = Scale.Stacked;
Related
Actually my chart is looking like that:
As you can see the labels are overlapped with the other series. How can I set the label for series2 (=columns) to the bottom above the x-axis? It seems there is no property for that?
Thanks
You can show the y-values of one series at one axis. This can be the primary axis (at the bottom), but then the x-values won't show. Or it can be the secondary axis; for this here is what you can do:
First enable the second x-axis :
chart.ChartAreas[0].AxisX2.Enabled = AxisEnabled.True;
Then associate the series you want to this secondary axis:
yourSeries.XAxisType = AxisType.Secondary;
Finally tell the series to display its y-values on its axis labels:
yourSeries.AxisLabel = "#VAL";
If your other series shows its values close to the points:
yourOtherSeries.IsValueShownAsLabel = true;
..this could be the result :
Here I have colored the axis labels to go with their series:
chart.ChartAreas[0].AxisX2.LabelStyle.ForeColor = yourSeries.Color;
I create a chart with MSchart but for some charts I wanna to make data values of each column to be vertical. There is no much space for labels to be horizontal. I see some similar question but none of them works for me.
To turn the DataPoint labels you need to first turn off the SmartLabelStyle:
chart1.Series[0].SmartLabelStyle.Enabled = false;
Now you can set the LabelAngle :
chart1.Series[0].LabelAngle = 90;
I am programming in C# on VB2010 and I am wanting to shade under the line that is made on my chart. I have a chart with 7 separate values on the X-axis and adjust them with a trackbar for the height on the Y-axis. First I would like to know how to have my line (I'm currently using the Spline type Series chart) display shading under where the line is to the bottom of my chart; and to also have my chart display the new value on the chart immediately after moving the trackbar so that I don't have to click on the chart to update the display.
I am able to create bar chart and displaying strip line through MS Chart below snap:
Same chart I am trying to create in C# at run time feel like to export the chart in excel. Can anyone guide me how can draw the Strip line on bar chart OR can combine bar chart line chart so line chart seems displaying the strip line.
one possible approach is to add a new series like this:
add a new series to the bar chart, using 2 cells equal to the value where you want to have vertical line (x column in illustration)
select the new series bars and change chart type to X Y (Scatter) - the one with both markers and lines so you can then select it again
edit data range for the new series, so x-values point to your value and y-values to 0 and 1
change the right axis to Minimum: Fixed 0,0, Maximum: Fixed 1,0 and change major tick lines and axis labels to None
remove markers and change line style
I have made bar diagram with horizontal lines, it works fine, and a combobox where the users can change to a pie chart, with sort of work, when the user change to pie chart it works fine, but when change back from the pie chart to the bar chart, only the bars come, not the title, the x-asis tick, they axis tick nor the custom labels for the y axis.
I have search the net, and tried the following lines
myPane.YAxis.Scale.IsVisible=true;
myPane.XAxis.Scale.IsVisible=true;
myPane.XAxis.Scale.Min = 0;
myPane.XAxis.Scale.Max = 30;
myPane.YAxis.Scale.Min = 0;
myPane.YAxis.Scale.Max = 9;
myPane.Legend.IsVisible = true;
but it only shows the bars there and nothing else. it works fine, if the bars diagram is made before, and without shift to the pie-chart
Found a solution, finally.
Making a rectangle for prooper size
RectangleF rc=new RectangleF();
rc.X=0;
rc.Y=0;
rc.Width=zgc.Width;
rc.Height=zgc.Height;
Make a new graph rather than a new masterpane
zgc.GraphPane=new GraphPane(rc,"title","x - axis","y-axis");
Link the new pane
myPane=zgc.GraphPane;
That worked for me, now I get the corect size, and all values and ticks.