Create a new Column Chart and click Chart Attribute - Style > Analytical Line > Trend Linebutton in the chart maker to add a trend line and set trend line name, type and line type as shown below:

Trend line name is shown in the legend.

Save the template and click preview to see the effect above.

Trend line forecasting is to derive past and future trends based on existing trend, and its unit is period, i.e. number of category.

In the above trend line, define past trend forecasting as 2 periods and future trend forecasting as 3 periods, then preview to see the following effect:

Trend line is a form of graphical representation of data trend and can be used to analyze and forecast question. Such analysis is also known as regression analysis. Regression analysis allows user to extend the trend line in the chart beyond factual data and forecast future value. Then here comes the question: Is it reliable? The answer is connected to a concept called R-squared value. In this case, R-squared value is between 0 and 1.

When R-squared value of trend line is 1 or approximate to 1, it is most reliable. If you use trend line for data fitting, then Javascript Charts VanCharts will automatically calculate R-squared value based on equation. Note that data of specific type corresponds to trend line of specific type. Choice of most appropriate trend line is very important to get accurate forecasting results.

The calculation equation of R-squared value is listed below, in which SSE and SST is a mathematical optimization technology using least square method. It can minimize the quadratic sum of difference and locate the optimal function matching for data. Least square method enables easy evaluation of unknown data and minimizes the quadratic sum of difference between the forecasted data and actual data. Least square method can also be used in curve fitting. Other optimization problems can also be calculated by expression of minimum energy or maximum entropy in least square method.

An expression of least square method is to calculate the constants in the equation of each trend line (a0 and a1 correspond to constants appeared in the equation):

**· Linearity**

Calculate the straight line with the minimum variance derived from the following equation:

In which m stands for slope and b for intercept.

**· Polynomial**

The equation below is used to calculate the minimum variance of data point:

In which b and are constants.

**· Logarithm**

The equation below is used to calculate the minimum variance of data point:

In which c and b are constants and function ln is natural logarithm.

Due to arithmetic reasons, when fitting equation is logarithm, data point with negative X axis value will be ignored.

**· Exponent**

The equation below is used to calculate the minimum variance of data point:

In which c and b are constants and e is the base of natural logarithm.

Due to arithmetic reasons, when fitting equation is logarithm, data point with negative Y axis value will be ignored.

**· Power**

The equation below is used to calculate the minimum variance of data point:

In which c and b are constants.

Due to arithmetic reasons, when fitting equation is logarithm, data point with negative X and Y axis values will be ignored. Meanwhile, an X axis value may correspond to a number of Y axis values in scatter chart, likely to result in a large error for fitting equation.

Linearity trend line: suitable for best fitting straight-line of simple linearity data set. If the trend composed by the data points approximate to a straight line, then the data approximates to linearity. Linearity trend line is generally used to express the constant increase or decrease of event. The rate for increase or decrease is stable.

Logarithmic trend line: If the data starts to increase or decrease very quickly, and then change to level quickly, then logarithmic trend line is the best fitting curve, with rapid increase or decrease speed at the beginning and gradually stable increase or decrease speed later.

Polynomial trend line: a curve line used in case of major data fluctuations. The order of polynomial is determined by the number of data fluctuation or the number of inflection points on the curve. Another easy way to determine is based on the peak or trough of the curve. Second-order polynomial is a parabola, and the corresponding trend line usually have only one peak or trough; third-order polynomial trend line usually have one or two peaks or troughs; while fourth-order polynomial trend line have up to 3 peaks or troughs. The indefinite integral equation of polynomial is pretty easy, and we can easily evaluate the area under the curve, and there a number of fluctuations of increase or decrease.

Power trend line: a curve suitable for data set with constant increase or decrease acceleration. If zero or negative numbers exist in the data, then power trend line cannot be created. Data increases or decreases with constant acceleration.

Exponent trend line: suitable for data set with growing increase speed. Similarly, if zero or negative numbers exist in the data, then power trend line cannot be created. Data increases or decreases with constant acceleration.