format chart control by code
Hello,
I would like to format a ChartControl from code.
With this code:
Private Sub BtAggiorna_Click(sender As Object, e As System.EventArgs) Handles BtAggiorna.Click
Me.ChartControl1.Series.Clear()
Me.ChartControl1.Legends.Clear()
Me.ChartControl1.Title.Text = String.Empty
Dim seriesHOCCUPATE As ChartSeries = Me.ChartControl1.Model.NewSeries("Series1")
seriesHOCCUPATE.Points.Add(1, CInt(Me.TextHOCCUPATE.Text))
Me.ChartControl1.Series.Add(seriesHOCCUPATE)
Dim seriesHLIBERE As ChartSeries = Me.ChartControl1.Model.NewSeries("Series2")
seriesHLIBERE.Points.Add(1, CInt(Me.TextHLIBERE.Text))
Me.ChartControl1.Series.Add(seriesHLIBERE)
Dim seriesHOFFERTE As ChartSeries = Me.ChartControl1.Model.NewSeries("Series3")
seriesHOFFERTE.Points.Add(1, CInt(Me.TextHOFFERTE.Text))
Me.ChartControl1.Series.Add(seriesHOFFERTE)
Dim seriesHANTICIPATE As ChartSeries = Me.ChartControl1.Model.NewSeries("Series4")
seriesHANTICIPATE.Points.Add(1, CInt(Me.TextHANTICIPATE.Text))
Me.ChartControl1.Series.Add(seriesHANTICIPATE)
End Sub
I get this:
I would like to get this:
It's possible?
Thank you very much.
Beppe
SIGN IN To post a reply.
3 Replies
AT
Anandaraj T
Syncfusion Team
June 21, 2018 03:21 PM UTC
Hi Beppe Salvaderi,
Thanks for using Syncfusion products.
We suggest you to use the Interior property of chart series style to customize the color of bars. The DisplayText and TextOrientation properties of series style can be used to display the data labels at the bottom of data points. The TickLabelsDrawingMode property can be used to hide all the labels in x-axis.
We have also prepared a simple sample for your requirement and it can be downloaded from the following link
Please refer the following code snippet to achieve this
|
[VB]
For i As Integer = 0 To 4
Dim series As ChartSeries = New ChartSeries()
series.Points.Add(1, random.Next(10, 20))
Dim r As Integer = random.Next(1, 253)
Dim g As Integer = random.Next(1, 255)
Dim b As Integer = random.Next(1, 254)
'Display data labels at the bottom of points
series.Style.DisplayText = True
series.Style.TextOrientation = Syncfusion.Windows.Forms.Chart.ChartTextOrientation.RegionDown
series.Style.Font.Bold = True
'Apply color to series
series.Style.Interior = New Syncfusion.Drawing.BrushInfo(Color.FromArgb(r, g, b))
Me.ChartControl1.Series.Add(series)
Next
'Disable the x-axis labels
Me.ChartControl1.PrimaryXAxis.TickLabelsDrawingMode = Syncfusion.Windows.Forms.Chart.ChartAxisTickLabelDrawingMode.UserMode
|
[Screenshot]
Please let us know if you have any concern.
Regards,
Anand
BS
BEPPE SALVADERI
June 22, 2018 05:27 AM UTC
Hi Anandaraj T,
it's perfect!
Thank you very much.
Beppe
PN
Preethi Nesakkan Gnanadurai
Syncfusion Team
June 25, 2018 04:17 AM UTC
Hi Beppe,
Most welcome, please let us know if you need any assistance.
Regards,
Preethi
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
BS BEPPE SALVADERI
- Jun 20, 2018 06:15 PM UTC
- Jun 25, 2018 04:17 AM UTC