This section provides instructions for building a Line Chart with symbols which is the default chart type. A Line chart is another simple way to show the relationship of the data.
In this example we will create a Line chart with symbols. There will be only one line so we will use one data series. The line will display the company's profit growth over time. The horizontal axis, in this example, Axis X, represents years and the vertical axis, in this example, AxisY, represents profit in thousands of dollars.
Once you complete the following steps your chart will appear like the following line chart with symbols:
To create a Line Chart with Symbols at design time
The first step in configuring a chart through the Chart Properties designer is to select a gallery type from the available chart types.
The default Line chart will add two data series which will create two lines.
A preview image of the updated chart appears in the lower left pane of the Chart Properties designer.
Next we will modify the X and Y axis default title and we will also change the axes font style using the Chart Properties designer. Select AxisX from the treeveiw pane, then select the annotation tab.
Congratulations! You created a Line symbol chart using the Chart Properties designer.
To create a Line Chart with Symbols programmatically
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Imports C1.Win.C1Chart; |
To write code in C#
C# |
Copy Code
|
---|---|
using C1.Win.C1Chart; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'create data for the chart Dim xdata() As Double = {2004, 2005, 2006, 2007} Dim ydata() As Double = {50, 100, 150, 200} 'clear previous series C1Chart1.ChartGroups(0).ChartData.SeriesList.Clear() 'add one series to the chart Dim ds As C1.Win.C1Chart.ChartDataSeries = _ C1Chart1.ChartGroups(0).ChartData.SeriesList.AddNewSeries() 'copy the x and y data ds.X.CopyDataIn(xdata) ds.Y.CopyDataIn(ydata) 'set the chart type C1Chart1.ChartGroups(0).ChartType = C1.Win.C1Chart.Chart2DTypeEnum.XYPlot 'create new font for the X and Y axes Dim f As Font = New Font("Arial", 10, FontStyle.Bold) C1Chart1.ChartArea.Style.ForeColor = Color.DarkGray C1Chart1.ChartArea.AxisX.Font = f C1Chart1.ChartArea.AxisX.Text = "Year" C1Chart1.ChartArea.AxisX.GridMajor.Visible = True C1Chart1.ChartArea.AxisX.GridMajor.Color = Color.LightGray C1Chart1.ChartArea.AxisY.Font = f C1Chart1.ChartArea.AxisY.Text = "Profit (thousands of dollars)" C1Chart1.ChartArea.AxisY.GridMajor.Visible = True C1Chart1.ChartArea.AxisY.GridMajor.Color = Color.LightGray 'change the default line style appearance ds.LineStyle.Color = Color.LightPink ds.LineStyle.Pattern = LinePatternEnum.Solid ds.LineStyle.Thickness = 1 'change the default symbol style appearance ds.SymbolStyle.Shape = SymbolShapeEnum.Box ds.SymbolStyle.Color = Color.LightPink ds.SymbolStyle.OutlineColor = Color.Black ds.SymbolStyle.Size = 5 ds.SymbolStyle.OutlineWidth = 1 'set the backcolor for the plot area C1Chart1.ChartArea.PlotArea.BackColor = Color.White End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void Form1_Load(object sender, EventArgs e) { //create data for the chart double[] xdata = { 2004, 2005, 2006, 2007 }; double[] ydata = { 50, 100, 150, 200 }; //clear previous series c1Chart1.ChartGroups[0].ChartData.SeriesList.Clear(); //add one series to the chart C1.Win.C1Chart.ChartDataSeries ds = c1Chart1.ChartGroups[0].ChartData.SeriesList.AddNewSeries(); //copy the x and y data ds.X.CopyDataIn(xdata); ds.Y.CopyDataIn(ydata); //set the chart type c1Chart1.ChartGroups[0].ChartType = C1.Win.C1Chart.Chart2DTypeEnum.XYPlot; //create new font for the X and Y axes Font f = new Font("Arial", 10, FontStyle.Bold); c1Chart1.ChartArea.Style.ForeColor = Color.DarkGray; c1Chart1.ChartArea.AxisX.Font = f; c1Chart1.ChartArea.AxisX.Text = "Year"; c1Chart1.ChartArea.AxisX.GridMajor.Visible = true; c1Chart1.ChartArea.AxisX.GridMajor.Color = Color.LightGray; c1Chart1.ChartArea.AxisY.Font = f; c1Chart1.ChartArea.AxisY.Text = "Profit (thousands of dollars)"; c1Chart1.ChartArea.AxisY.GridMajor.Visible = true; c1Chart1.ChartArea.AxisY.GridMajor.Color = Color.LightGray; //modify line style appearance ds.LineStyle.Color = Color.LightPink; ds.LineStyle.Pattern = LinePatternEnum.Solid; ds.LineStyle.Thickness = 1; //modify the symbol style appearance ds.SymbolStyle.Shape = SymbolShapeEnum.Box; ds.SymbolStyle.Color = Color.LightPink; ds.SymbolStyle.OutlineColor = Color.Black; ds.SymbolStyle.Size = 5; ds.SymbolStyle.OutlineWidth = 1; c1Chart1.ChartArea.PlotArea.BackColor = Color.White; } |