New to Telerik Reporting? Download free 30-day trial

How to Create Graph with Column and Line Series

In this how-to article we will show you how to create a graph with both column and line series, showing the maximum and the average amount of sales on a monthly basis using the AdventureWorks sample database.

How to create a Graph with Column and Line Series

  1. Start the Graph Wizard:

    • If you use Standalone Telerik Report Designer

      From the Insert menu select Column and then Clustered Column. This will bring up the Graph Wizard which will help you create the first series.

      select Column

    • If you use the Visual Studio Report Designer

      Initiate the Graph Wizard from the Visual Studio toolbox. Then select Clustered Column chart type and click OK. This will bring up the Graph Wizard which will help you create the first series.

  2. Click 'Add New Data Source...' button and select SQL Data Source :

    1. Set the connection string to the demo AdventureWorks database.

    2. Set the query to the following one:

      SELECT SOD.LineTotal, SOH.OrderDate
      Sales.SalesPerson S
      INNER JOIN Sales.SalesOrderHeader SOH ON SOH.SalesPersonID = S.SalesPersonID
      INNER JOIN Sales.SalesOrderDetail SOD ON SOH.SalesOrderID = SOD.SalesOrderID
      WHERE SOH.OrderDate between cast('2003-01-01' as datetime) and cast('2003-12-31' as datetime)
      and S.SalesPersonId = 283
    3. You can click on Execute Query... just to check if everything is OK with the database connection. Click Finish when you are ready.
  3. In the Available data sources list you should see the datasource you've already created. Select it and click Next.

  4. In the next page you should select the fields which will be used to build the chart. Since the report will display aggregated sums of the order lines by month, you need only two fields: LineTotal and OrderDate. Select OrderDate field and drag it to Categories box. Select LineTotal field and drag it to Values box. It will be shown as Sum(LineTotal), as the Sum is the default aggregate function, but in this example we will display the maximum amount of sales in the column series and the average amount of sales in the line series, so you should choose the Max function from the drop-down menu. Click Next once you are ready.

  5. The Wizard has detected that the field used as Category is of type DateTime, and this page will let you configure the scale for the graph. In most cases the 'Auto' option will work fine, so we will leave it like this. Complete the Wizard by clicking Finish.

  6. The graph will display the column series and it should look like this:

    Graph Layout 1

  7. The graph is displaying the date-time values on its X-axis, and the 'Auto' scale option divides each column into one column per month. To make the label for the X-axis easier to read, first select the X-axis, and in the Property Browser set a proper LabelFormat (i.e. {0:Y}) and LabelAngle to 90º.

  8. To add another series to the graph, you can right-click on the graph and select Add Graph Series… from the context menu. This will bring up a dialog window with all the chart types to select from. Select Line, Line with Markers and click OK. The Graph wizard will be displayed again. Repeat step 4 for choosing and dragging the data source fields to Categories and Values boxes, but this time choose Avg as an aggregate function for the LineTotal field. Click Next and Finish when you are ready.

    When adding a new Series, a new Category group is also created. In this guide we are using a field of type DateTime for category. This will set the scale of the X-axis to DateTime Scale which will correctly display the two series on top of each other. With any other type, like Numerical Scale, Logarithmic Scale or Category Scale, the two Series will be displayed next to each other and not overlapping correctly. To fix this, select the newly created series and change the CategoryGroup to the group used by the first series.

    Change Category Group

  9. Name the series’ legend items accordingly using the property LegendItem. Value of both of your series. Finally your graph should look like the one shown below:

    Graph Layout 3

See Also

In this article