Microsoft Chart. Legend Appears on Top of X Axis - charts

I created an Microsoft Chart in C# and added the following legend:
Legend legend = new Legend {
Alignment = StringAlignment.Center,
Docking = Docking.Bottom,
Enabled = true,
IsDockedInsideChartArea = false,
TableStyle = LegendTableStyle.Wide,
};
Part of the legend appears on top of the X axis ... Any idea why?
How can I solve this? Can I add a top margin to the legend?
Thank You,
Miguel

In my code I let the Chart create the legend object itself, this is the VB code, but maybe it's useful to you:
aChart.Legends.Clear()
aChart.Legends.Add("Default")
aChart.Legends(0).BorderColor = Color.Black
aChart.Legends(0).Docking = Docking.Bottom
aChart.Legends(0).IsDockedInsideChartArea = False
aChart.Legends(0).TableStyle = LegendTableStyle.Wide
aChart.Legends(0).Alignment = StringAlignment.Center

you need to create a chart area:
p_Chart.ChartAreas.Add(new ChartArea(MAIN_CHART_AREA));
then set both your series and you legend to this area:
legend.DockedToChartArea = MAIN_CHART_AREA;
series.ChartArea = MAIN_CHART_AREA;

Related

Transparent overlapping bar plots

I want to have two transparent bar plots that overlape in one figure. I tried this way:
bar(list2(:,1),list2(:,2),'r','FaceAlpha',0.5)
hold on
bar(list1(:,1),list1(:,2),'g','FaceAlpha',0.5)
but the output is:
Why the second plot is not transparent and has these strange strips?
I use matlab 2016a
your approach is correct, and it works for a few bars:
[list1(:,2),list1(:,1)] = hist(randn(200,1));
[list2(:,2),list2(:,1)] = hist([randn(100,1)-0.5 ; randn(100,1)+0.5]);
bar(list2(:,1),list2(:,2),'r','FaceAlpha',0.5)
hold on
bar(list1(:,1),list1(:,2),'g','FaceAlpha',0.5)
However, you can notice that there are black lines contouring each bar. As the bar number increases, the black contours will cover everything:
[list1(:,2),list1(:,1)] = hist(randn(3000,1), 300);
[list2(:,2),list2(:,1)] = hist([randn(1500,1)-2 ; randn(1500,1)+2], 300);
h1 = bar(list2(:,1),list2(:,2),'r','FaceAlpha',0.5)
hold on
h2 = bar(list1(:,1),list1(:,2),'g','FaceAlpha',0.5)
(The result will depend on the Matlab version. In 2016b it appears that the problem is automatically corrected).
The solution: remove the black contours:
h1.EdgeColor = 'none';
h2.EdgeColor = 'none';

How do I complete remove the draw value on bar chart using iOS charts with swift 3

I am trying to remove the bottom draw values (in black) on my X axis. I tried self.chartActual.drawValueAboveBarEnabled = false but all that does is move the values to below the top of the bar. I also tried self.chartActual.xAxis.drawLabelsEnabled = false but that hides my top labels.
How do I remove the drawvalue on the X axis using ios-charts?
let datamore = BarChartData()
let ds12 = BarChartDataSet(values: dataEntries, label: nil)
datamore.addDataSet(ds12)
datamore.setDrawValues(false)
I needed the last line AFTER adding the data.

D3.js AreaChart alignment issues

I'm in need of a little assistance. I have a stacked area chart in d3.js using ordinal for the x axis (and likely for the y as well but haven't implemented that yet) and while it's rendering, it's not quite right. I need to figure out how to shift the chart (not the axis) so that the left most border is lined up vertically with the first tickmark and the rightmost is even with the last tickmark.
I've tried several variations and can't seem to figure out the starting x value.
Any help would be appreciated.
My x code
var x = d3.scale.ordinal().rangeRoundBands([0, width]);
x.domain(['Dec','Jan','Feb']); // Hard coded for now
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
A js fiddle of the entire chart (with data):
http://jsfiddle.net/adeaver/FRNbq/6/
Have you tried:
var x = d3.scale.ordinal()
.rangePoints([0, width]);
That may be what you are looking for.
This also works:
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], 1, 0);

How to put show an outline for each chart series in a RadChart?

I'm trying to customize the appearance of an ASP Web Forms RadChart where the series have FillType = Solid while still allowing visibility of the lesser point values behind larger ones. What I really want is each series to have an outline placed on top of all the fills (basically the effect of having a ChartSeriesType.Line on top of a ChartSeriesType.Area).
I've experimented with setting LineAppearance.Shadow, color transparency, and combinations of those but it's still too difficult to discern background series values.
Is there not a simple way to turn on an outline for each series when using a solid fill? OR to set the transparency of the background fill only, not the edges?
Note the transparency in the above image. I'm afraid allowing more transparency improves the visibility of background values but results in a horrible collection of pastel colors.
I suggest you to go through telerik documentation page RadControls for ASP.NET AJAX Documentation -Styling Chart Elements and this nice example Creating RadChart Programmatically - more complex example.
Code snippet:
// Define chart and titleRadChart radChart = new RadChart();
radChart.ChartTitle.TextBlock.Text = "My RadChart";
radChart.ChartTitle.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Blue;
// Define chart series
ChartSeries chartSeries = new ChartSeries();
chartSeries.Appearance.LabelAppearance.Visible = false;
chartSeries.Name = "GDP";
chartSeries.Type = ChartSeriesType.Line;
chartSeries.Appearance.LineSeriesAppearance.Color = System.Drawing.Color.BlueViolet;
// Define the items in the series
chartSeries.AddItem(1);
chartSeries.AddItem(1.5);
chartSeries.AddItem(2.0);
chartSeries.AddItem(2.5);
chartSeries.AddItem(3.5);
// visually enhance the datapoints
chartSeries.Appearance.PointMark.Dimensions.AutoSize = false;
chartSeries.Appearance.PointMark.Dimensions.Width = 5;
chartSeries.Appearance.PointMark.Dimensions.Height = 5;
chartSeries.Appearance.PointMark.FillStyle.MainColor = System.Drawing.Color.Black;
chartSeries.Appearance.PointMark.Visible = true;
// Define chart series
ChartSeries chartSeries2 = new ChartSeries();
chartSeries2.Appearance.LabelAppearance.Visible = false;
chartSeries2.Name = "GNP";
chartSeries2.Type = ChartSeriesType.Line;
chartSeries2.Appearance.LineSeriesAppearance.Color = System.Drawing.Color.Green;
// Define the items in the series
chartSeries2.AddItem(2);
chartSeries2.AddItem(3);
chartSeries2.AddItem(3.5);
chartSeries2.AddItem(4);
chartSeries2.AddItem(4.5);
// visually enhance the data points
chartSeries2.Appearance.PointMark.Dimensions.AutoSize = false;
chartSeries2.Appearance.PointMark.Dimensions.Width = 5;
chartSeries2.Appearance.PointMark.Dimensions.Height = 5;
chartSeries2.Appearance.PointMark.FillStyle.MainColor = System.Drawing.Color.Black;
chartSeries2.Appearance.PointMark.Visible = true;
// set the plot area gradient background fill
radChart.PlotArea.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Gradient;
radChart.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.FromArgb(65, 201, 254);
radChart.PlotArea.Appearance.FillStyle.SecondColor = System.Drawing.Color.FromArgb(0, 107, 186);
// Set text and line for X axis
radChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Years";
radChart.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red;
radChart.PlotArea.XAxis.Appearance.Width = 3;
radChart.PlotArea.XAxis.Appearance.Color = System.Drawing.Color.Red;
// Set text and line for Y axis
radChart.PlotArea.YAxis.AxisLabel.TextBlock.Text = "%";
radChart.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red;
radChart.PlotArea.YAxis.Appearance.Width = 3;
radChart.PlotArea.YAxis.Appearance.Color = System.Drawing.Color.Red;
// Add the series to the chart, chart to page.radChart.Series.Add(chartSeries);radChart.Series.Add(chartSeries2);this.Page.Controls.Add(radChart)
Hope this help..

How to show all legends in google Visualization: Pie Chart

i am using Google visualization pie chart for showing my vote details.But the chart didn't showing the zero values and legends.
How to show all legends in Google Visualization: Pie Chart
You can simply set the sliceVisibilityThreshold option to 0. This will force all the legends to show.
var options = {
sliceVisibilityThreshold: 0
};
var data = /* ... */;
var chart = new google.visualization.PieChart(/* ... */);
chart.draw(data, options);
What I did was to add a small value (0.005) to each of the values. When setting the sliceVisibilityThreshold: 1/25000, (1/25000 = 0.004) the slice/legend will be shown but the value will still be 0% due to rounding.