Since there is a layer between the data source and the actual chart, the data often needs to be summarized before it can be plotted; however, the data to be plotted sometimes may already be available in a data view or another data source object. And therefore, you can bind the chart directly to the data source object in such cases.
To bind the FlexChart control directly to the data source, you first need to set the DataSource property to the data source object, for instance, the data view, data table, or binding source. Next, you need to bind individual series of the chart to the fields present in the data source object by using the BindingX and the Binding property.
Let's use a case study of a food chain restaurant that specializes in a variety of foods and beverages. They hold special deals/discounts for their regular customers twice a month. Recently, they've decided to give out discounts on every food item purchased if the customer has bought at least five food items. However, the discounts to be given are decided on the basis of the quantities of the items purchased.
A customer, which is basically an organization by the name of QUICK-Stop, has ordered a couple of items in considerable quantities. The customer is billed the requisite amount on the order (order id: 10273) and is provided with the computer generated invoice that comprises the following details:
Product | Unit Price ($) | Quantity | Discount (%) |
---|---|---|---|
Chang | 15.20 | 25 | 20 |
Queso Cabrales | 16.80 | 50 | 20 |
Nord-Ost Matjeshering | 20.70 | 35 | 20 |
Escargots de Bourgogne | 10.60 | 30 | 20 |
Let us now visualize the invoice data by using FlexChart and interpret the data appropriately for all the products.
Here, we are using the Order Details data table in the C1NWind.mdb database.
Use the below-mentioned code to implement the case study:
Following is the output: