To reproduce: - Set the position like this: this.radChartView1.ChartElement.LegendElement.Alignment = ContentAlignment.TopCenter; - Export the chart to an image, the position is not the same as in the application. Workaround: - Set the position manually: this.radChartView1.ChartElement.LegendPosition = LegendPosition.Float; this.radChartView1.ChartElement.LegendOffset = new Point(400, 0);
Public Class RadForm2
Public Sub New()
InitializeComponent()
AddHandler Me.RadChartView1.CreateRenderer, AddressOf radChartView1_CreateRenderer
Me.RadChartView1.ShowSmartLabels = True
Me.RadChartView1.ShowPanZoom = True
Dim barSeries As New BarSeries()
Dim barSeries1 As New BarSeries()
Dim barSeries2 As New BarSeries()
Dim rand As New Random()
barSeries.DataPoints.Add(New CategoricalDataPoint(101, 0))
barSeries1.DataPoints.Add(New CategoricalDataPoint(101, 0))
barSeries2.DataPoints.Add(New CategoricalDataPoint(101, 0))
For i As Integer = 1 To 9
barSeries.DataPoints.Add(New CategoricalDataPoint(rand.[Next](100), i))
barSeries1.DataPoints.Add(New CategoricalDataPoint(rand.[Next](100), i))
barSeries2.DataPoints.Add(New CategoricalDataPoint(rand.[Next](100), i))
Next
barSeries.ShowLabels = True
barSeries.DrawLinesToLabels = True
barSeries1.ShowLabels = True
barSeries1.DrawLinesToLabels = True
barSeries2.ShowLabels = True
barSeries2.DrawLinesToLabels = True
Me.RadChartView1.Series.Add(barSeries)
Me.RadChartView1.Series.Add(barSeries1)
Me.RadChartView1.Series.Add(barSeries2)
End Sub
Private Sub radChartView1_CreateRenderer(sender As Object, e As ChartViewCreateRendererEventArgs)
'e.Renderer = New CustomCartesianRenderer(TryCast(e.Area, CartesianArea))
End Sub
End Class
Workaround: Create a custom renderer
Public Class CustomCartesianRenderer
Inherits CartesianRenderer
Public Sub New(area As CartesianArea)
MyBase.New(area)
End Sub
Protected Overrides Sub Initialize()
MyBase.Initialize()
For i As Integer = 0 To Me.DrawParts.Count - 1
Dim labelPart As BarLabelElementDrawPart = TryCast(Me.DrawParts(i), BarLabelElementDrawPart)
If labelPart IsNot Nothing Then
Me.DrawParts(i) = New CustomBarLabelElementDrawPart(DirectCast(labelPart.Element, BarSeries), Me)
End If
Next
End Sub
End Class
Public Class CustomBarLabelElementDrawPart
Inherits BarLabelElementDrawPart
Public Sub New(owner As ChartSeries, renderer As IChartRenderer)
MyBase.New(owner, renderer)
End Sub
Public Overrides Sub Draw()
Dim graphics As Graphics = TryCast(Me.Renderer.Surface, Graphics)
Dim cartesianSeries As CartesianSeries = TryCast(Me.Element, CartesianSeries)
If cartesianSeries IsNot Nothing Then
Dim area As CartesianArea = DirectCast(cartesianSeries.[GetType]().GetField("area", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(cartesianSeries), CartesianArea)
Dim clipRect As RectangleF = DirectCast(area.[GetType]().GetMethod("GetCartesianClipRect", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(area, New Object() {}), RectangleF)
graphics.SetClip(clipRect)
End If
MyBase.Draw()
graphics.ResetClip()
End Sub
Protected Overrides Function GetLineStart(label As LabelElement, point As DataPointElement, isSmartLabel As Boolean) As PointF
Dim lineStart As PointF = MyBase.GetLineStart(label, point, isSmartLabel)
Dim x As Single = CSng(TryCast(Me.Element.View, IChartView).PlotOriginX)
Dim y As Single = CSng(TryCast(Me.Element.View, IChartView).PlotOriginY)
lineStart.X += x
lineStart.Y += y
Return lineStart
End Function
Protected Overrides Function GetLineEnd(label As LabelElement, point As DataPointElement, isSmartLabel As Boolean) As PointF
Dim lineEnd As PointF = MyBase.GetLineEnd(label, point, isSmartLabel)
If Not isSmartLabel Then
Dim x As Single = CSng(TryCast(Me.Element.View, IChartView).PlotOriginX)
Dim y As Single = CSng(TryCast(Me.Element.View, IChartView).PlotOriginY)
lineEnd.X += x
lineEnd.Y += y
End If
Return lineEnd
End Function
End Class
Note: similar to the axis, the series should also have ClipLabels property which will control whether the labels will be clipped or not.
How to reproduce: zoom and pan along the chart
public Form1()
{
InitializeComponent();
this.radChartView1.CreateRenderer += radChartView1_CreateRenderer;
this.radChartView1.ShowPanZoom = true;
BarSeries barSeries = new BarSeries();
Random rand = new Random();
for (int i = 1; i < 10; i++)
{
barSeries.DataPoints.Add(new CategoricalDataPoint(rand.Next(100), i));
}
barSeries.ShowLabels = true;
this.radChartView1.Series.Add(barSeries);
}
Workaround:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radChartView1.CreateRenderer += radChartView1_CreateRenderer;
this.radChartView1.ShowPanZoom = true;
BarSeries barSeries = new BarSeries();
Random rand = new Random();
for (int i = 1; i < 10; i++)
{
barSeries.DataPoints.Add(new CategoricalDataPoint(rand.Next(100), i));
}
barSeries.ShowLabels = true;
this.radChartView1.Series.Add(barSeries);
}
private void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
{
e.Renderer = new CustomCartesianRenderer(e.Area as CartesianArea);
}
}
public class CustomCartesianRenderer : CartesianRenderer
{
public CustomCartesianRenderer(CartesianArea area)
: base(area)
{ }
protected override void Initialize()
{
base.Initialize();
for (int i = 0; i < this.DrawParts.Count; i++)
{
BarLabelElementDrawPart labelPart = this.DrawParts[i] as BarLabelElementDrawPart;
if (labelPart != null)
{
this.DrawParts[i] = new CustomLabelElementDrawPart((BarSeries)labelPart.Element, this);
}
}
}
}
public class CustomLabelElementDrawPart : BarLabelElementDrawPart
{
public CustomLabelElementDrawPart(ChartSeries owner, IChartRenderer renderer)
: base(owner, renderer)
{ }
public override void Draw()
{
Graphics graphics = this.Renderer.Surface as Graphics;
CartesianSeries cartesianSeries = this.Element as CartesianSeries;
if (cartesianSeries != null)
{
CartesianArea area = (CartesianArea)cartesianSeries.GetType().GetField("area", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cartesianSeries);
RectangleF clipRect = (RectangleF)area.GetType().GetMethod("GetCartesianClipRect", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(area, new object[] { });//.GetCartesianClipRect();
graphics.SetClip(clipRect);
}
base.Draw();
graphics.ResetClip();
}
}
How can I achieve the same behaviour as with the obsolete RadChart plotting the area between the maxima of a sine.
To reproduce: - Add at least two series and zoom the chart so the point from one of the series are visible only - Move the TrackBall - The Track ball is not shown for some of the points.
How to reproduce:
Dim table As New DataTable()
table.Columns.Add("Name", GetType(String))
table.Columns.Add("X", GetType(Integer))
For i As Integer = 0 To 99
table.Rows.Add($"User {i}", i)
Next
Dim series As New BarSeries()
series.DataSource = table
series.CategoryMember = "Name"
series.ValueMember = "X"
RadChartView1.Series.Add(series)
CType(RadChartView1.Area, CartesianArea).Orientation = Orientation.Horizontal
Dim panZoomController As New ChartPanZoomController()
panZoomController.PanZoomMode = ChartPanZoomMode.Vertical
RadChartView1.Controllers.Add(panZoomController)
RadChartView1.Zoom(1, 8)
Workaround: create a custom ChartPanZoomController
Dim panZoomController As New MyChartPanZoomController()
panZoomController.PanZoomMode = ChartPanZoomMode.Vertical
RadChartView1.Controllers.Add(panZoomController)
Public Class MyChartPanZoomController
Inherits ChartPanZoomController
Protected Overrides Function OnMouseMove(e As MouseEventArgs) As ActionResult
Dim cartesianArea As CartesianArea = TryCast(Me.Area, CartesianArea)
If cartesianArea Is Nothing Then
Return MyBase.OnMouseMove(e)
End If
Dim panPoint As Point? = Me.GetType().BaseType.GetField("panPoint", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me)
If e.Button = MouseButtons.Left AndAlso panPoint.HasValue Then
Dim offsetX As Double = Me.GetType().BaseType.GetField("offsetX", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me)
Dim currentOffsetX As Double = offsetX
Dim defaultAxis As Axis = If(cartesianArea.Orientation = Orientation.Horizontal,
Me.Area.GetType().GetMethod("GetDefaultFirstAxis", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me.Area, New Object() {}),
Me.Area.GetType().GetMethod("GetDefaultSecondAxis", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me.Area, New Object() {}))
If Me.PanZoomMode = ChartPanZoomMode.Horizontal OrElse Me.PanZoomMode = ChartPanZoomMode.Both Then
currentOffsetX += (panPoint.Value.X - e.Location.X) * -1
If currentOffsetX > 0 Then
currentOffsetX = 0
End If
If currentOffsetX < defaultAxis.Model.LayoutSlot.Width * (DirectCast(cartesianArea.View, IChartView).ZoomWidth - 1) Then
currentOffsetX = -defaultAxis.Model.LayoutSlot.Width * (DirectCast(cartesianArea.View, IChartView).ZoomWidth - 1)
End If
End If
Dim offsetY As Double = Me.GetType().BaseType.GetField("offsetY", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me)
Dim currentOffsetY As Double = offsetY
If Me.PanZoomMode = ChartPanZoomMode.Vertical OrElse Me.PanZoomMode = ChartPanZoomMode.Both Then
currentOffsetY += (panPoint.Value.Y - e.Location.Y) * -1
If currentOffsetY > 0 Then
currentOffsetY = 0
End If
If currentOffsetY < -defaultAxis.Model.LayoutSlot.Height * (DirectCast(cartesianArea.View, IChartView).ZoomHeight - 1) Then
currentOffsetY = -defaultAxis.Model.LayoutSlot.Height * (DirectCast(cartesianArea.View, IChartView).ZoomHeight - 1)
End If
End If
cartesianArea.View.Pan(currentOffsetX, currentOffsetY)
End If
Return Controller.Empty
End Function
End Class
To reproduce: populate RadChartView with data and try to export it to Emf
using (MemoryStream ms = new MemoryStream())
{
this.radChartView1.ExportToImage(ms, this.radChartView1.Size, System.Drawing.Imaging.ImageFormat.Emf);
}
Workaround: use some of the other ImageFormats.
The event should not be triggered when moving the mouse over the same data point, as we already asked for data for it. We can cache it and reuse it.
Introduce gantt like series as in RadChart: http://docs.telerik.com/devtools/winforms/chart/understanding-radchart-types/gantt-charts
Steps to reproduce:
1. Add RadChartView with two BarSeries
2. Set the Name property of series
3. Set the SelectionMode property to SingleDataPoint
4. Subscribe to the SelectedPointChanging/SelectedPointChanged events.
5. Run the form and select points from different series. The OldSelectedSeries/NewSelectedSeries properties always return the name of the first series now matter which series is selected.
Workaround:
void radChartView1_SelectedPointChanged(object sender, ChartViewSelectedPointChangedEventArgs e)
{
BarSeries series = (e.NewSelectedPoint).Presenter as BarSeries;
if (series.Name == "Q1")
{
Console.WriteLine(series.Name);
}
else if (series.Name == "Q2")
{
Console.WriteLine(series.Name);
}
}
To reproduce:
Public Sub New()
InitializeComponent()
Me.RadChartView1.ShowTitle = True
Me.RadChartView1.ChartElement.TitleElement.TextWrap = True
Me.RadChartView1.Title = "This is a very long chart title that can't fit in a single line"
Dim barSeries As New BarSeries("Performance", "RepresentativeName")
barSeries.Name = "Q1"
barSeries.DataPoints.Add(New CategoricalDataPoint(177, "Harley"))
barSeries.DataPoints.Add(New CategoricalDataPoint(128, "White"))
barSeries.DataPoints.Add(New CategoricalDataPoint(143, "Smith"))
barSeries.DataPoints.Add(New CategoricalDataPoint(111, "Jones"))
barSeries.DataPoints.Add(New CategoricalDataPoint(118, "Marshall"))
Me.RadChartView1.Series.Add(barSeries)
End Sub
Private Sub radButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim filePath As String = "..\..\..\exprtedChart.png"
Me.RadChartView1.ExportToImage(filePath, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Png)
Process.Start(filePath)
End Sub
Workaround: titleSize must consider the chart's width
Public Sub New()
InitializeComponent()
AddHandler Me.RadChartView1.CreateRenderer, AddressOf CreateRenderer
Me.RadChartView1.ShowTitle = True
Me.RadChartView1.ChartElement.TitleElement.TextWrap = True
Me.RadChartView1.Title = "This is a very long chart title that can't fit in a single line"
Dim barSeries As New BarSeries("Performance", "RepresentativeName")
barSeries.Name = "Q1"
barSeries.DataPoints.Add(New CategoricalDataPoint(177, "Harley"))
barSeries.DataPoints.Add(New CategoricalDataPoint(128, "White"))
barSeries.DataPoints.Add(New CategoricalDataPoint(143, "Smith"))
barSeries.DataPoints.Add(New CategoricalDataPoint(111, "Jones"))
barSeries.DataPoints.Add(New CategoricalDataPoint(118, "Marshall"))
Me.RadChartView1.Series.Add(barSeries)
End Sub
Private Sub radButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim filePath As String = "..\..\..\exprtedChart.png"
Using fs As New FileStream(filePath, FileMode.Create, FileAccess.Write)
ExportToImage(Me.RadChartView1, fs, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Png)
End Using
Process.Start(filePath)
End Sub
Public Sub ExportToImage(chart As RadChartView, stream As Stream, size As Size, imageFormat As ImageFormat)
If Not chart.IsLoaded Then
chart.LoadElementTree()
End If
Dim bmp As New Bitmap(size.Width, size.Height)
Dim graphics__1 As Graphics = Graphics.FromImage(bmp)
graphics__1.Clear(Color.White)
Dim titleSize As SizeF = graphics__1.MeasureString(chart.Title, chart.ChartElement.TitleElement.Font, chart.Width)
If chart.ChartElement.TitleElement.TextOrientation = Orientation.Vertical Then
Dim swap As Single = titleSize.Height
titleSize.Height = titleSize.Width
titleSize.Width = swap
End If
Dim titleRect As New RadRect(0, 0, titleSize.Width, titleSize.Height)
Dim legendRect As New RadRect(0, 0, size.Width, size.Height)
Dim chartRect As RadRect = legendRect
Select Case chart.ChartElement.TitlePosition
Case TitlePosition.Top, TitlePosition.Bottom
titleRect.Width = size.Width
Exit Select
Case TitlePosition.Right, TitlePosition.Left
titleRect.Height = size.Height
Exit Select
End Select
chartRect.X += chart.View.Margin.Left
chartRect.Y += chart.View.Margin.Top
chartRect.Width -= chart.View.Margin.Horizontal
chartRect.Height -= chart.View.Margin.Vertical
If chart.ShowTitle Then
Select Case chart.ChartElement.TitlePosition
Case TitlePosition.Top
legendRect.Y += titleRect.Height
chartRect.Y += titleRect.Height
legendRect.Height -= titleRect.Height
chartRect.Height -= titleRect.Height
Exit Select
Case TitlePosition.Right
titleRect.X = size.Width - chart.ChartElement.TitleElement.Size.Width
titleRect.Height = size.Height
legendRect.Width -= titleRect.Width
chartRect.Width -= titleRect.Width
Exit Select
Case TitlePosition.Bottom
titleRect.Y = size.Height - chart.ChartElement.TitleElement.Size.Height
titleRect.Width = size.Width
legendRect.Height -= titleRect.Height
chartRect.Height -= titleRect.Height
Exit Select
Case TitlePosition.Left
titleRect.Height = size.Height
legendRect.X += titleRect.Width
chartRect.X += titleRect.Width
legendRect.Width -= titleRect.Width
chartRect.Width -= titleRect.Width
Exit Select
End Select
End If
If chart.ShowLegend Then
Select Case chart.ChartElement.LegendPosition
Case LegendPosition.Right
If chart.ChartElement.TitlePosition = TitlePosition.Right Then
legendRect.X = titleRect.X - chart.ChartElement.LegendElement.Size.Width
Else
legendRect.X = size.Width - chart.ChartElement.LegendElement.Size.Width
End If
legendRect.Width = chart.ChartElement.LegendElement.Size.Width
chartRect.Width -= legendRect.Width + chart.View.Margin.Right
Exit Select
Case LegendPosition.Bottom
If chart.ChartElement.TitlePosition = TitlePosition.Bottom Then
legendRect.Y = titleRect.Y - chart.ChartElement.LegendElement.Size.Height
Else
legendRect.Y = size.Height - chart.ChartElement.LegendElement.Size.Height
End If
legendRect.Height = chart.ChartElement.LegendElement.Size.Height
chartRect.Height -= legendRect.Height
Exit Select
Case LegendPosition.Left
legendRect.Width = chart.ChartElement.LegendElement.Size.Width
chartRect.X += legendRect.Width + chart.View.Margin.Left
chartRect.Width -= legendRect.Width + chart.View.Margin.Left
Exit Select
Case LegendPosition.Top
legendRect.Height = chart.ChartElement.LegendElement.Size.Height
chartRect.Y += legendRect.Height
chartRect.Height -= legendRect.Height
Exit Select
Case LegendPosition.Float
legendRect.Width = chart.ChartElement.LegendElement.Size.Width
legendRect.Height = chart.ChartElement.LegendElement.Size.Height
Dim xRatio As Double = size.Width / Me.Size.Width
Dim yRatio As Double = size.Height / Me.Size.Height
legendRect.X = (chart.ChartElement.LegendOffset.X * xRatio) + (If((chart.ChartElement.TitlePosition = TitlePosition.Left), titleRect.Right, 0.0))
legendRect.Y = (chart.ChartElement.LegendOffset.Y * yRatio) + (If((chart.ChartElement.TitlePosition = TitlePosition.Top), titleRect.Bottom, 0.0F))
Exit Select
End Select
End If
If chart.ShowLegend Then
Dim xTransform As Single = CSng(legendRect.X) - chart.ChartElement.LegendElement.ControlBoundingRectangle.X + _
(CSng(legendRect.Width) - chart.ChartElement.LegendElement.ControlBoundingRectangle.Width) / 2.0F
Dim yTransform As Single = CSng(legendRect.Y) - chart.ChartElement.LegendElement.ControlBoundingRectangle.Y + _
(CSng(legendRect.Height) - chart.ChartElement.LegendElement.ControlBoundingRectangle.Height) / 2.0F
graphics__1.TranslateTransform(xTransform, yTransform)
chart.ChartElement.LegendElement.Paint(New RadGdiGraphics(graphics__1), _
chart.ChartElement.LegendElement.ControlBoundingRectangle, 0.0F, New SizeF(1.0F, 1.0F), True)
graphics__1.ResetTransform()
End If
Dim radGraphics As New RadGdiGraphics(graphics__1)
If chart.ShowTitle Then
radGraphics.DrawString(chart.Title, GetTitleDrawRectangle(ChartRenderer.ToRectangleF(titleRect), _
titleSize, chart.ChartElement.TitleElement.TextAlignment), chart.ChartElement.TitleElement.Font, _
chart.ChartElement.TitleElement.ForeColor, chart.ChartElement.TitleElement.TextParams.CreateStringFormat(), _
chart.ChartElement.TitleElement.TextOrientation, _
chart.ChartElement.TitleElement.FlipText)
End If
chart.View.Layout(chartRect)
renderer.Draw(graphics__1)
bmp.Save(stream, imageFormat)
chart.View.Layout()
End Sub
Private Function GetTitleDrawRectangle(drawArea As RectangleF, textRect As SizeF, textAlignment As ContentAlignment) As RectangleF
Select Case textAlignment
Case ContentAlignment.BottomCenter
Return New RectangleF(New PointF(drawArea.X + (drawArea.Width - textRect.Width) / 2.0F, drawArea.Bottom - textRect.Height), textRect)
Case ContentAlignment.BottomLeft
Return New RectangleF(New PointF(drawArea.X, drawArea.Bottom - textRect.Height), textRect)
Case ContentAlignment.BottomRight
Return New RectangleF(New PointF(drawArea.Right - textRect.Width, drawArea.Bottom - textRect.Height), textRect)
Case ContentAlignment.MiddleCenter
Return New RectangleF(New PointF(drawArea.X + (drawArea.Width - textRect.Width) / 2.0F, drawArea.Y + (drawArea.Height - textRect.Height) / 2.0F), textRect)
Case ContentAlignment.MiddleLeft
Return New RectangleF(New PointF(drawArea.X, drawArea.Y + (drawArea.Height - textRect.Height) / 2.0F), textRect)
Case ContentAlignment.MiddleRight
Return New RectangleF(New PointF(drawArea.Right - textRect.Width, drawArea.Y + (drawArea.Height - textRect.Height) / 2.0F), textRect)
Case ContentAlignment.TopCenter
Return New RectangleF(New PointF(drawArea.X + (drawArea.Width - textRect.Width) / 2, drawArea.Y), textRect)
Case ContentAlignment.TopLeft
Return New RectangleF(drawArea.Location, textRect)
Case ContentAlignment.TopRight
Return New RectangleF(New PointF(drawArea.Right - textRect.Width, drawArea.Y), textRect)
Case Else
Return New RectangleF(drawArea.Location, textRect)
End Select
End Function
Dim renderer As CartesianRenderer
Private Sub CreateRenderer(sender As Object, e As ChartViewCreateRendererEventArgs)
e.Renderer = New CartesianRenderer(DirectCast(e.Area, CartesianArea))
renderer = e.Renderer
End Sub
Note: when you apply a palette the series doesn't have hover and selection indication.
To reproduce:
LegendItem item = new LegendItem();
item.Element.BorderColor = Color.Black;
item.Element.BackColor = Color.Yellow;
item.Title = "Custom item";
this.radChartView1.ChartElement.LegendElement.Items.Add(item);
Workaround:
class MyLegendItem : LegendItem
{
string title = "";
protected override void SetLegendTitle(string title)
{
base.SetLegendTitle(title);
if (this.Element is LegendItemStyleElement)
{
this.title = title;
}
}
protected override string GetLegendTitle()
{
if (this.Element is LegendItemStyleElement)
{
return title;
}
return base.GetLegendTitle();
}
}
To reproduce: LineSeries lineSeries = new LineSeries(); lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan")); lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr")); lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul")); lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct")); lineSeries.LegendTitle = "Series A asdafsafasfd fgsdfg sdfs dfg dafsvsd"; this.radChartView1.Series.Add(lineSeries); LineSeries lineSeries2 = new LineSeries(); lineSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Jan")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Apr")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(17, "Jul")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(22, "Oct")); lineSeries2.LegendTitle = "Series B sdf asdf adfasdfas dfadsf asdf sadf awef"; this.radChartView1.Series.Add(lineSeries2); LineSeries lineSeries3 = new LineSeries(); lineSeries3.DataPoints.Add(new CategoricalDataPoint(13, "Jan")); lineSeries3.DataPoints.Add(new CategoricalDataPoint(14, "Apr")); lineSeries3.DataPoints.Add(new CategoricalDataPoint(12, "Jul")); lineSeries3.DataPoints.Add(new CategoricalDataPoint(25, "Oct")); lineSeries3.LegendTitle = "Series C sdf asdf adfasdfas dfadsf asdf sadf awef"; this.radChartView1.Series.Add(lineSeries3); this.radChartView1.ShowLegend = true; this.radChartView1.ChartElement.LegendPosition = Telerik.WinControls.UI.LegendPosition.Bottom; radChartView1.ChartElement.LegendElement.StackElement.Orientation = Orientation.Horizontal; Workaround: specify minimum height for the legend radChartView1.ChartElement.LegendElement.MinSize = new Size(0, 50);
Why exists the Crosshair feature only for the WPF version of the RadChartView and not for the WinForms implementation? Is there a plan to release that feature for WinForms too? Thx in advance Uli
To reproduce:
- Localize the palette names with the localization provider.
- Change the palette with the context menu.
Workaround:
class MyChartDataPointElementController : ChartDataPointElementController
{
protected override RadContextMenu CreatePaletteMenu()
{
RadContextMenu menu = new RadContextMenu();
RadChartLocalizationProvider localizationProvider = RadChartLocalizationProvider.CurrentProvider;
RadMenuItem paletteItem = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.Palette));
menu.Items.Add(paletteItem);
RadMenuItem item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteArctic));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Arctic";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteAutumn));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Autumn";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteCold));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Gold";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteFlower));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Flower";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteForest));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Forest";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteGrayscale));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Grayscale";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteGround));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Ground";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteLilac));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Lilac";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteMetro));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Metro";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteNatural));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Natural";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PalettePastel));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Pastel";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteRainbow));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Rainbow";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteSpring));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Spring";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteSummer));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Summer";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteWarm));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Warm";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteWindows8));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Windows8";
paletteItem.Items.Add(item);
item = new RadMenuItem(localizationProvider.GetLocalizedString(RadChartStringId.PaletteSun));
item.Click += new System.EventHandler(item_Click);
item.Tag = "Sun";
paletteItem.Items.Add(item);
return menu;
}
void item_Click(object sender, System.EventArgs e)
{
RadMenuItem item = sender as RadMenuItem;
if (item != null)
{
this.Area.View.Palette = ChartPalette.FromKnownPalette(item.Tag.ToString());
}
}
}
// change the controller
this.radChartView1.Controllers.Add(new MyChartDataPointElementController());
Use the attached project to reproduce. Workaround: Hide the panel after the form is shown.
Gets the range that is actually visible on the plot area when the chart is zoomed in.
To reproduce:
- Add two donut series and set their RadiusFactor so both series can be seen.
- Add ChartSelectionController.
- You will be able to select points from the firs series only.
Workaround:
class MyPieRenderer : PieRenderer
{
public MyPieRenderer(PieArea area) : base(area)
{
}
public override DataPoint HitTest(int x, int y)
{
if (this.DrawParts.Count > 0)
{
foreach (var item in this.DrawParts)
{
if (item is PieSeriesDrawPart)
{
Dictionary<PieDataPoint, GraphicsPath> paths = ((PieSeriesDrawPart)item).PointPaths;
foreach (PieDataPoint point in paths.Keys)
{
GraphicsPath path = new GraphicsPath();
paths.TryGetValue(point, out path);
if (path != null)
{
if (path.IsVisible(x, y))
{
return point;
}
}
}
}
}
}
return null;
}
}
private void RadChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e)
{
e.Renderer = new MyPieRenderer((PieArea)e.Area);
}
To reproduce: AreaSeries areaSeries = new AreaSeries(); areaSeries.DataPoints.Add(new CategoricalDataPoint(13, "Jan")); areaSeries.DataPoints.Add(new CategoricalDataPoint(20, "Apr")); areaSeries.DataPoints.Add(new CategoricalDataPoint(15, "Jul")); areaSeries.DataPoints.Add(new CategoricalDataPoint(16, "Oct")); this.radChartView1.Series.Add(areaSeries); areaSeries.BackColor = Color.Transparent; areaSeries.CombineMode = ChartSeriesCombineMode.Stack; AreaSeries areaSeries2 = new AreaSeries(); areaSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Jan")); areaSeries2.DataPoints.Add(new CategoricalDataPoint(25, "Apr")); areaSeries2.DataPoints.Add(new CategoricalDataPoint(27, "Jul")); areaSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Oct")); this.radChartView1.Series.Add(areaSeries2); areaSeries2.CombineMode = ChartSeriesCombineMode.Stack; The area underneath the transparent one shouldn't be displayed in this case because they are stacked. There is no area underneath the bottom layer to display. They are each STACKED on top of each other, they should not be layered in front of each other.