Hi thereI am using 12.1.20121.2054 of the UltraChart and am having troubles with my chart's legend. The chart is a composite chart made up of a ColumnChart and a Line chart1/ I have assigned the Legend.Location = LegendLocation.Bottom but it still appears at the top right hand side of the chart. How can I affect this location? ultraChart1.Legend.DataAssociation = ChartTypeData.SplitData; // Add a Legend CompositeLegend chartLegend = new CompositeLegend(); columnLayer.LegendItem = LegendItemType.Series; lineLayer.LegendItem = LegendItemType.Series; chartLegend.ChartLayers.Add(columnLayer); chartLegend.ChartLayers.Add(lineLayer); ultraChart1.CompositeChart.Legends.Add(chartLegend); this.ultraChart1.Legend.Location = LegendLocation.Bottom;2/ You will notice under the X axis it has the term "Monthly". I do not want to display this value, in fact I want to hide that value, but if I set the Series.Label to string.Empty or modify the label the legend text is also affected. How can hide the series label but leave the legend label as :Monthly" ?
Regards
geoffhop
Hello geoffhop,
geoffhop said:1/ I have assigned the Legend.Location = LegendLocation.Bottom but it still appears at the top right hand side of the chart. How can I affect this location?
Looking at the provided code, the mentioned behavior is expected, because:
- this.ultraChart1.Legend.Location - this property could be use for default legend, but when you are using Composite Legend you should specify the size and location of the legend using for example :
CompositeLegend m_ChartLegend = new CompositeLegend();
ColumnLayer.LegendItem = LegendItemType.Series;
LineLayer.LegendItem = LegendItemType.Series;
m_ChartLegend.ChartLayers.Add(ColumnLayer);
m_ChartLegend.ChartLayers.Add(LineLayer);
m_ChartLegend.BoundsMeasureType = MeasureType.Percentage;
m_ChartLegend.Bounds = new Rectangle(1, 10, 18, 20);
geoffhop said: 2/ You will notice under the X axis it has the term "Monthly". I do not want to display this value, in fact I want to hide that value, but if I set the Series.Label to string.Empty or modify the label the legend text is also affected. How can hide the series label but leave the legend label as :Monthly" ?
Could you please zip and upload again your screenshot, because we didn`t received it, but looking at the provided information, I think that you are using wrong property, because X axis lables could be hidden when using a :
AxisItem xAxis = new AxisItem();
xAxis.DataType = AxisDataType.String;
......
xAxis.OrientationType = AxisNumber.X_Axis;
xAxis.Labels.Visible = false;
Let me know if you have any questions.
Hi Georgi
Thanks a lot for your help on this.
1/ I have been playing around with the rectangle for the legend location but was hoping for more friendly and less risky means of positioning.
2/ I have attached a copy of the C# code and a screenshot of the application. You will notice the term "Monthly" along the XAxis near the bottom, that is the text I want to hide but I still want to display the term "Monthly" in the legend, just remove from the XAxis is all I am after.
I cannot seem to attach a zip file to these posts, no toolbar item and Firefox will not let me paste in a zip file. How do you guys do it.
private void Attempt7() { this.ultraChart1.Visible = true; this.ultraChart1.CompositeChart.ChartAreas.Clear(); this.ultraChart1.CompositeChart.ChartLayers.Clear(); ultraChart1.ChartType = ChartType.Composite; ultraChart1.BackColor = Color.White; ultraChart1.Data.ZeroAligned = true; ultraChart1.TitleTop.Text = "Cost Report"; ultraChart1.TitleTop.FontColor = Color.Black; ultraChart1.TitleTop.Font = new Font("Arial", 14.0F, FontStyle.Bold); ultraChart1.TitleTop.HorizontalAlign = StringAlignment.Center; this.ultraChart1.Tooltips.FormatString = "<DATA_VALUE:#,0.####>"; // Create the Chart Area ChartArea chartArea = new ChartArea(); chartArea.BoundsMeasureType = MeasureType.Percentage; chartArea.Bounds = new Rectangle(25, 10, 74, 90); chartArea.Border.Thickness = 0; NumericSeries columnSeries = new NumericSeries(); foreach (OLAPReportingDS.DTReportChartDataRow dataRow in this.TypedDataSource.DTReportChartData) { columnSeries.Points.Add(new NumericDataPoint((double)dataRow.Cost, dataRow.PerStartDate.ToString("MMM-yy", CultureInfo.CurrentCulture), false)); columnSeries.PEs.Add(new PaintElement(Color.CornflowerBlue)); } columnSeries.Label = "Monthly"; // if you change this to something else then the NumericSeries lineSeries = new NumericSeries(); foreach (OLAPReportingDS.DTReportChartDataRow dataRow in this.TypedDataSource.DTReportChartData) { lineSeries.Points.Add(new NumericDataPoint((double)dataRow.CumulativeCost, dataRow.PerStartDate.ToString("MMM-yy", CultureInfo.CurrentCulture), false)); lineSeries.PEs.Add(new PaintElement(Color.Orange)); } lineSeries.Label = "Cumulative"; AxisItem xAxis = new AxisItem(); xAxis.OrientationType = AxisNumber.X_Axis; xAxis.DataType = AxisDataType.String; xAxis.SetLabelAxisType = SetLabelAxisType.GroupBySeries; xAxis.LineColor = Color.White; xAxis.Labels.FontColor = Color.Black; xAxis.Labels.ItemFormatString = "<ITEM_LABEL>"; xAxis.Labels.Layout.Behavior = AxisLabelLayoutBehaviors.Auto; xAxis.Labels.VerticalAlign = StringAlignment.Far; xAxis.Labels.HorizontalAlign = StringAlignment.Near; xAxis.Labels.Orientation = TextOrientation.Horizontal; xAxis.MajorGridLines.Visible = false; xAxis.Labels.Visible = false; AxisItem x2Axis = new AxisItem(); x2Axis.OrientationType = AxisNumber.X_Axis; x2Axis.DataType = AxisDataType.String; x2Axis.LineColor = Color.Transparent; x2Axis.SetLabelAxisType = SetLabelAxisType.ContinuousData; x2Axis.Labels.Visible = false; AxisItem yAxis = new AxisItem(); yAxis.OrientationType = AxisNumber.Y_Axis; yAxis.Extent = 70; yAxis.TickmarkStyle = AxisTickStyle.Smart; yAxis.DataType = AxisDataType.Numeric; yAxis.LineColor = Color.Black; yAxis.Labels.FontColor = Color.Black; yAxis.Labels.ItemFormatString = "<DATA_VALUE:#,0.####>"; yAxis.MajorGridLines.Visible = false; AxisItem y2Axis = new AxisItem(); y2Axis.OrientationType = AxisNumber.Y2_Axis; y2Axis.Extent = 70; y2Axis.TickmarkStyle = AxisTickStyle.Smart; y2Axis.MajorGridLines.Visible = false; y2Axis.DataType = AxisDataType.Numeric; y2Axis.LineColor = Color.Black; y2Axis.Labels.FontColor = Color.Black; y2Axis.Labels.ItemFormatString = "<DATA_VALUE:#,0.####>"; ChartLayerAppearance columnLayer = new ChartLayerAppearance(); columnLayer.ChartType = ChartType.ColumnChart; columnLayer.Series.Add(columnSeries); columnLayer.ChartArea = chartArea; columnLayer.AxisX = xAxis; columnLayer.AxisY = yAxis; ColumnChartAppearance columnApp = new ColumnChartAppearance();// ColumnLayer.ChartTypeAppearance, ColumnChartAppearance); columnApp.ColumnSpacing = 3; columnApp.SeriesSpacing = 4; columnLayer.ChartTypeAppearance = columnApp; ChartLayerAppearance lineLayer = new ChartLayerAppearance(); lineLayer.ChartType = ChartType.LineChart; lineLayer.Series.Add(lineSeries); lineLayer.ChartArea = chartArea; lineLayer.AxisX = x2Axis; lineLayer.AxisY = y2Axis; LineChartAppearance lineChartAppearance = new LineChartAppearance(); lineChartAppearance.DrawStyle = LineDrawStyle.Solid; lineChartAppearance.Thickness = 5; lineChartAppearance.MidPointAnchors = true; lineChartAppearance.HighLightLines = true; lineChartAppearance.NullHandling = NullHandling.DontPlot; lineLayer.ChartTypeAppearance = lineChartAppearance; chartArea.Axes.Add(xAxis); chartArea.Axes.Add(x2Axis); chartArea.Axes.Add(yAxis); chartArea.Axes.Add(y2Axis); ultraChart1.CompositeChart.ChartAreas.Add(chartArea); ultraChart1.CompositeChart.ChartLayers.Add(columnLayer); ultraChart1.CompositeChart.ChartLayers.Add(lineLayer); ultraChart1.CompositeChart.Series.Add(columnSeries); ultraChart1.CompositeChart.Series.Add(lineSeries); ultraChart1.Legend.DataAssociation = ChartTypeData.SplitData; // Add a Legend CompositeLegend chartLegend = new CompositeLegend(); columnLayer.LegendItem = LegendItemType.Series; lineLayer.LegendItem = LegendItemType.Series; chartLegend.ChartLayers.Add(columnLayer); chartLegend.ChartLayers.Add(lineLayer); chartLegend.BoundsMeasureType = MeasureType.Percentage; chartLegend.Bounds = new Rectangle(34, 96, 20, 4); chartArea.BoundsMeasureType = MeasureType.Percentage; chartArea.Bounds = new Rectangle(0, 10, 98, 100); chartLegend.PE.ElementType = PaintElementType.Gradient; chartLegend.PE.FillGradientStyle = GradientStyle.Circular; chartLegend.PE.Fill = Color.White; chartLegend.PE.FillStopColor = Color.White; chartLegend.Border.CornerRadius = 10; chartLegend.Border.Thickness = 1; chartLegend.LabelStyle.FontSizeBestFit = true; ultraChart1.CompositeChart.Legends.Add(chartLegend); this.ultraChart1.Legend.Location = LegendLocation.Bottom; this.ultraChart1.TitleLeft.VerticalAlign = StringAlignment.Center; this.ultraChart1.TitleLeft.HorizontalAlign = StringAlignment.Center; this.ultraChart1.TitleLeft.Text = "Monthly"; this.ultraChart1.TitleLeft.FontColor = Color.Black; Font font3 = new Font(this.ultraChart1.TitleLeft.Font.FontFamily, 10, FontStyle.Bold); this.ultraChart1.TitleLeft.Font = font3; this.ultraChart1.TitleLeft.Visible = true; this.ultraChart1.TitleRight.VerticalAlign = StringAlignment.Center; this.ultraChart1.TitleRight.HorizontalAlign = StringAlignment.Center; this.ultraChart1.TitleRight.Text = "Cumulative"; this.ultraChart1.TitleRight.FontColor = Color.Black; Font font4 = new Font(this.ultraChart1.TitleRight.Font.FontFamily, 10, FontStyle.Bold); this.ultraChart1.TitleRight.Font = font4; this.ultraChart1.TitleRight.Visible = true; }
Thanks Georgi that fixed it
Here is the sample
Hi
Thanks for attached code and screenshot. To acheive desired behavior you should set :
xAxis.Labels.SeriesLabels.Visible = false;
Please take a look at the sample that I create using your code and my modifications.
Let me know if you have any questions
Sorry about the confusion.
I have got the hang of the attachments now!!!
I am talking about the XAxis Label "Monthly" under the XAxis, I would like to hide it but leave the legend unaffected.
Thanks again
I`m not sure that I understand your issue, because I`m still not able to see your screenshot. Please zip your screenshot and upload it again using "Option" Tab.
Are you talking about Titles in the chart or you are talking about the axis lables ?