Hi Team,
Can you please share sample or demo code for candlestick graph (C# winform).
Thanks
To reproduce: please refer to the attached sample project and gif file illustrating the behavior on my end.
Note: similar to the axis, the series should also have ClipLabels property which will control whether the labels will be clipped or not.
Workaround: use custom renderer:
Sub New()
InitializeComponent()
AddHandler Me.RadChartView1.CreateRenderer, AddressOf RadChartView1_CreateRenderer
Dim barSeries As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName")
barSeries.Name = "Q1"
barSeries.ShowLabels = True
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)
Dim barSeries2 As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName")
barSeries2.Name = "Q2"
barSeries2.ShowLabels = True
barSeries2.DataPoints.Add(New CategoricalDataPoint(153, "Harley"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(141, "White"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(130, "Smith"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(88, "Jones"))
barSeries2.DataPoints.Add(New CategoricalDataPoint(109, "Marshall"))
Me.RadChartView1.Series.Add(barSeries2)
Dim lassoZoomController As New ChartPanZoomController()
RadChartView1.Controllers.Add(lassoZoomController)
End Sub
Public Class CustomLabelElementDrawPart
Inherits BarLabelElementDrawPart
Public Sub New(owner As ChartSeries, renderer As IChartRenderer)
MyBase.New(owner, renderer)
End Sub
Public Overrides Sub Draw()
If Not Me.Element.ShowLabels Then
Return
End If
Dim graphics As Graphics = TryCast(Me.Renderer.Surface, Graphics)
Dim radGraphics As RadGdiGraphics = New RadGdiGraphics(graphics)
Dim isSmartLabelsEnabled As Boolean = Me.Element.View.ShowSmartLabels
Dim isLineToLabelEnabled As Boolean = Me.Element.DrawLinesToLabels
For Each dataPointElement As DataPointElement In Me.Element.Children
Dim categoricalDataPoint As CategoricalDataPoint = TryCast(dataPointElement.DataPoint, CategoricalDataPoint)
For i As Integer = 0 To dataPointElement.Children.Count - 1
Dim labelElement As LabelElement = TryCast(dataPointElement.Children(i), LabelElement)
If labelElement Is Nothing Then
Continue For
End If
labelElement.OnLabelFormatting(New ChartViewLabelFormattingEventArgs(labelElement))
If Not labelElement.IsVisible OrElse String.IsNullOrEmpty(labelElement.Text) Then
Continue For
End If
Dim rect As Rectangle
Dim slot As RadRect = labelElement.GetLayoutSlot()
If isSmartLabelsEnabled AndAlso labelElement.SmartRectangle <> Rectangle.Empty Then
rect = labelElement.SmartRectangle
Else
slot = AdjustLayoutSlot(slot, labelElement.DataPointElement)
rect = ChartRenderer.ToRectangle(slot)
End If
Dim state As Object = radGraphics.SaveState()
Dim horizontalTranslate As Integer = rect.X + rect.Width / 2
Dim verticalTranslate As Integer = rect.Y + rect.Height / 2
Dim clipRect As RectangleF
If TypeOf Me.Renderer Is CartesianRenderer Then
Dim size As SizeF = graphics.MeasureString("W", Me.Element.Font)
Dim plotRect As RadRect = Me.Element.Model.LayoutSlot
plotRect.X += Me.ViewportOffsetX
plotRect.Y += Me.ViewportOffsetY
clipRect = ChartRenderer.ToRectangleF(plotRect)
clipRect.Y -= size.Height / 2.0F
clipRect.Height += size.Height
clipRect.Width += size.Width * 2.0F
graphics.SetClip(clipRect)
End If
Dim angle As Single = CSng(Me.Element.LabelRotationAngle) Mod 360.0F
If angle <> 0 Then
radGraphics.TranslateTransform(horizontalTranslate, verticalTranslate)
radGraphics.RotateTransform(angle)
radGraphics.TranslateTransform(-horizontalTranslate, -verticalTranslate)
End If
If isLineToLabelEnabled Then
Me.DrawConnectingLine(radGraphics, labelElement, dataPointElement, isSmartLabelsEnabled AndAlso labelElement.SmartRectangle <> Rectangle.Empty)
End If
If labelElement.BackgroundShape IsNot Nothing Then
labelElement.BackgroundShape.Paint(CType(radGraphics.UnderlayGraphics, Graphics), rect)
End If
Dim fill As Telerik.WinControls.Primitives.FillPrimitiveImpl = New Telerik.WinControls.Primitives.FillPrimitiveImpl(labelElement, Nothing)
fill.PaintFill(radGraphics, 0, System.Drawing.Size.Empty, rect)
Dim border As Telerik.WinControls.Primitives.BorderPrimitiveImpl = New Telerik.WinControls.Primitives.BorderPrimitiveImpl(labelElement, Nothing)
border.PaintBorder(radGraphics, 0, System.Drawing.Size.Empty, rect)
Using brush As Brush = New SolidBrush(labelElement.ForeColor)
Dim drawRectangle As RectangleF = New RectangleF()
drawRectangle.X = rect.X + labelElement.Padding.Left
drawRectangle.Y = rect.Y + labelElement.Padding.Top
drawRectangle.Width = rect.Width - labelElement.Padding.Right
drawRectangle.Height = rect.Height - labelElement.Padding.Bottom
Dim format As StringFormat = New StringFormat()
format.Alignment = ContentAlignmentToHorizontalStringAlignment(labelElement.TextAlignment)
format.LineAlignment = Me.ContentAlignmentToVerticalStringAlignment(labelElement.TextAlignment)
graphics.DrawString(labelElement.Text, labelElement.Font, brush, drawRectangle, format)
End Using
If angle <> 0 Then
radGraphics.ResetTransform()
radGraphics.RestoreState(state)
End If
graphics.ResetClip()
Next
Next
End Sub
Public Function ContentAlignmentToVerticalStringAlignment(ByVal contentAlignment As ContentAlignment) As StringAlignment
Dim result As StringAlignment
Select Case contentAlignment
Case contentAlignment.BottomCenter, contentAlignment.BottomLeft, contentAlignment.BottomRight
result = StringAlignment.Far
Case contentAlignment.TopCenter, contentAlignment.TopLeft, contentAlignment.TopRight
result = StringAlignment.Near
Case Else
result = StringAlignment.Center
End Select
Return result
End Function
Private Function ContentAlignmentToHorizontalStringAlignment(ByVal contentAlignment As ContentAlignment) As StringAlignment
Dim result As StringAlignment
Select Case contentAlignment
Case contentAlignment.BottomLeft, contentAlignment.MiddleLeft, contentAlignment.TopLeft
result = StringAlignment.Near
Case contentAlignment.BottomRight, contentAlignment.MiddleRight, contentAlignment.TopRight
result = StringAlignment.Far
Case Else
result = StringAlignment.Center
End Select
Return result
End Function
End Class
Private Sub RadChartView1_CreateRenderer(sender As Object, e As ChartViewCreateRendererEventArgs)
e.Renderer = New CustomCartesianRenderer(e.Area)
End Sub
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 label As BarLabelElementDrawPart = TryCast(Me.DrawParts(i), BarLabelElementDrawPart)
If (label IsNot Nothing) Then
Me.DrawParts(i) = New CustomLabelElementDrawPart(label.Element, Me)
End If
Next
End Sub
End Class
I have use following code to use Both Scrollbar in RadChartView While Zoom. but it not scroll my chart . radchart1.HorizontalScroll.Enabled = true; radchart1.HorizontalScroll.Visible = true; radchart1.VerticalScroll.Enabled = true; radchart1.VerticalScroll.Visible = true; Please help me. Hello Kalpesh, Currently panning in RadChartView cannot be performed using the scrollbars. We have a feature request logged here: https://feedback.telerik.com/Project/154/Feedback/Details/111013-add-radchartview-add-a-scrollbar-that-controls-the-pan-and-zoom Please subscribe to the item so that you be updated when its status changes. For the time being I can suggest using a RadRangeSelector control to zoom and pan the chart. More information is available here: https://docs.telerik.com/devtools/winforms/rangeselector/overview Regards, Hristo
Use LogarithmicAxis and set the Minimum to 0.1 Workaround is availble in the atched project.
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
when overlay a radlabel on a radchartview, chartview constantly refreshes label backcolor set to transparent tried to recreate this with a sample cs project but wouldn't reproduce! video has two instances of the same user control on the form notice that right hand instance does not update when radlabel is added attached is video of it working fine, then add label ontop , then see it misbehaving with fast refresh flicker! not only that it also prevents other items in the user controls from updating and the other user control on the form from updating have attached sample c# project (but cant reproduce)
Having issues withVS2013 & 2015 Q1 Winforms RadChartView control 1. WYSIWYG in design time does not refresh properly after changing axis collection parameters, unless close and reopen the parent winform or custom control 2. by changing an axis collection parameter , seem to end up with multiple extra axes series (originally had axisX, AxisY, and after a minor param change ended up with axis 0 thru 5 (6 in total) and all series where now using axis4 & axis5 not my original axis? 3. I can't see to toggle display on/off of series in winforms via the legend, yet in wpf web it is possible? will this feature be added later? attached is example of WYSIWYG not working improvement Suggestions: I would love to have a major and minor grid (similar to ref: http://thumbs.dreamstime.com/z/screen-digital-oscilloscope-two-types-signal-33269502.jpg) as most of my work is measurement and scientific in nature. I would like to ensure the ratio of X-Y is fixed so that on resize of the control the grid does not skew or stretch and I loose 1:1 aspect ratio I look forward to your feedback ;)
To reproduce: use the following code snippet:
Random rand = new Random();
List<LineSeries> list = new List<LineSeries>();
for (int i = 0; i < 15; i++)
{
LineSeries ls = new LineSeries();
ls.LegendTitle = "Series" + i;
list.Add(ls);
}
for (int i = 0; i < 1000; i++)
{
foreach (LineSeries s in list)
{
s.DataPoints.Add(new CategoricalDataPoint(i, rand.Next(0, rand.Next(5, 20))));
}
}
radChartView1.Series.AddRange(list.ToArray());
this.radChartView1.ChartElement.LegendPosition = LegendPosition.Bottom;
this.radChartView1.ChartElement.LegendElement.StackElement.Orientation = Orientation.Horizontal;
Resolution:
The issue is duplicated with item IMPROVE. RadChartView - ChartLegend should be able to wrap its items. From Q1 2015 when there are many items in the chart legend a scroll bar will appear so users can scroll through the items.
More info in the following feedback item http://feedback.telerik.com/Project/154/Feedback/Details/149848-add-radchartview-when-the-legend-has-many-items-a-scrollbar-should-appear
so that Y increases as you move down the screen. (Even) microsoft chart component supports this.
The Line Series cannot be clicked/selected and cannot be used in DrillDown scenarios.
ChartLegendElement is not able to wrap the LegendItems
Currently the axis data flows from left to right starting with the smallest values and increasing. There should be a way to verse this flow and the most left values to be the biggest.
Currently, ScatterSeries are able to use NumericAxes only. A good improvement will be to allow using DateTimeContinuousAxes as well.
Add null value support for RadChartView
Steps to reproduce. 1. Add a chart view to a form. 2. Create a series and add several data points. For categories use double values in the range 10 - 20 3. Create a second series and this time for categories use double values in the same range without duplication. 4. Assign one linear and one categorical axis to the series and add them to the char view. 5. Run the project and you will see that the categories from the second series are next to those from the first series, while they should be combined according their values.