super_user
Posts: 62
Joined: Wed May 04, 2016 7:18 am

Trend line

hi
i want to show trend line in highchart
check this jsfiddle

http://jsfiddle.net/0o99Ldd3/



as you see that MV is in may is decrease then june & july increasing deceasing and then in august is decrease so how i want to show line

and same for other series

how i do this?

e.g.
henrikskar
Posts: 3
Joined: Fri Aug 05, 2016 8:18 am

Re: Trend line

Hi, super_user,

Here's a plugin that might help you: http://www.highcharts.com/plugin-regist ... regression
The plugin will calculate the regression for your trendline.
Let us know if this is helpful.

Best regards,
Henrik Skar
Highcharts Developer
super_user
Posts: 62
Joined: Wed May 04, 2016 7:18 am

Re: Trend line

henrikskar wrote:Hi, super_user,

Here's a plugin that might help you: http://www.highcharts.com/plugin-regist ... regression
The plugin will calculate the regression for your trendline.
Let us know if this is helpful.

Best regards,
ok now i try this but not works


series: data2,
regression: true ,
regressionSettings: {
type: 'linear',
color: 'rgba(223, 83, 83, .9)'
},
henrikskar
Posts: 3
Joined: Fri Aug 05, 2016 8:18 am

Re: Trend line

You need to organize your series and data differently.
If you look at this example you can see how the creator of the plugin uses series and data to present his regression: http://jsfiddle.net/3g4ryLc9/5/
Henrik Skar
Highcharts Developer
super_user
Posts: 62
Joined: Wed May 04, 2016 7:18 am

Re: Trend line

henrikskar wrote:You need to organize your series and data differently.
If you look at this example you can see how the creator of the plugin uses series and data to present his regression: http://jsfiddle.net/3g4ryLc9/5/

where are bars in your js fiddle?
henrikskar
Posts: 3
Joined: Fri Aug 05, 2016 8:18 am

Re: Trend line

There is a type property under chart that you can change into the chart type you want like this:
http://jsfiddle.net/o5fzLLy3/
Henrik Skar
Highcharts Developer
super_user
Posts: 62
Joined: Wed May 04, 2016 7:18 am

Re: Trend line

henrikskar wrote:There is a type property under chart that you can change into the chart type you want like this:
http://jsfiddle.net/o5fzLLy3/

i try this
series: eval(data2),
regresson: true,
regressionSettings: {
name: 'Type any name of the series..',
type: 'polynomial',
color: 'rgba(223, 183, 83, .9)',
dashStyle: 'dash'
},
color: 'rgba(223, 83, 83, .5)',


and line not display
User avatar
KacperMadej
Posts: 4632
Joined: Mon Sep 15, 2014 12:43 pm

Re: Trend line

Hi,

Some crucial parts of you code are missing and it's not possible to recreate the problem.
Please show you issue in a JSFiddle demo.

Kind Regards.
Kacper Madej
Highcharts Developer
DivyaYandra
Posts: 2
Joined: Fri Sep 21, 2018 10:11 am

Re: Trend line

Hi,
I want to format tooltip of regression line.
formatterfUN = function () {
var s = '<b>' + this.x + '</b>';

$.each(this.points, function () {
s += '<br/>' + this.series.name + ': ' +
Math.round(this.y * 100) / 100 + 'Bcf/d';
});

return s;
},

scatter = {
regression: true,
regressionSettings: {
name: source.observationName + ' Trend',
type: 'polynomial',
color: colors[colorIndex],
tooltip: {
formatter: formatterfUN
}
},
type: 'scatter',
name: source.observationName,
data: scatterData,
color: colors[colorIndex],
marker: {
radius: 4
},
tooltip: {
valueSuffix: 'Bcf/d',
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} degree, {point.y}'
}
};
This is not working for me

Is there any other way to format the tooltip of the regression line.

http://jsfiddle.net/DivyaYandra/j7pk1uxa/3/
rafalS
Posts: 2665
Joined: Thu Jun 14, 2018 11:40 am

Re: Trend line

Hi, DivyaYandra

You can format tooltip in the main tooltip object:

Code: Select all

tooltip: {
      pointFormatter: function() {
        var s = '<b>' + this.x + '</b>';
	console.log(this);
        return s;
      }
    },
And then, if you want to format other series, you can do this in plotOptions.scatter.tooltip object.

jsFiddle: http://jsfiddle.net/BlackLabel/fmwhaogt/

Best regards,
Rafał
Rafal Sebestjanski,
Highcharts Team Lead
DivyaYandra
Posts: 2
Joined: Fri Sep 21, 2018 10:11 am

Re: Trend line

Thanks Rafal Sebestjanski.

Return to “Highcharts Usage”