Bartje78
Posts: 2
Joined: Fri Feb 12, 2016 7:02 pm

Newbie needs help!

Hi all,

First of all, I'm a novice in programming websites, so please bear with me for asking basic questions....

Im trying to incorporate a test highchart in a otherwise empty html page. I'm just following the steps of "Your first Highchart", but cannot get it to work :( All I get is a blank container.... When looking at the error in the browser, it seems it doesn't recognize the $ function.... What am I doing wrong? Your help would be greatly appreciated!

The code I use is below.

Many thanks in advance!!!
Bart

Code: Select all

<!DOCTYPE html>

<html>

<head>
<title>Charts</title>
<link href="site.css" rel="stylesheet">
<script src="http://code.highcharts.com/highcharts.js"></script>
</head>


<body>

<nav id="nav01"></nav>

<div id="main">
  <h1>This is a nice chart</h1>


<div id="container" style="width:100%; height:400px;"></div>

<script>

$(function () { 
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {
                text: 'Fruit eaten'
            }
        },
        series: [{
            name: 'Jane',
            data: [1, 0, 4]
        }, {
            name: 'John',
            data: [5, 7, 3]
        }]
    });
});

</script>


  
  <footer id="foot01"></footer>
</div>

<script src="script.js"></script>

</body>
</html> 
mekhatria
Posts: 176
Joined: Mon May 18, 2015 7:39 am

Re: Newbie needs help!

Hi,

Your code is ok, just don't forget to add jQuery link "<script src="http://ajax.googleapis.com/ajax/libs/jq ... "></script>" before highcharts.js:

Code: Select all

<link href="site.css" rel="stylesheet">

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

<script src="http://code.highcharts.com/highcharts.js"></script>
A "$" sign is to define/access jQuery, check the link here for more details.

Have a nice day
Mustapha Mekhatria
Highcharts community manager
Bartje78
Posts: 2
Joined: Fri Feb 12, 2016 7:02 pm

Re: Newbie needs help!

Ahhh, many thanks! It works now :) Super!
mekhatria
Posts: 176
Joined: Mon May 18, 2015 7:39 am

Re: Newbie needs help!

You are welcome :)
Mustapha Mekhatria
Highcharts community manager
russelln
Posts: 20
Joined: Fri Jul 01, 2016 9:14 pm

Re: Newbie needs help!

Hello,

I figured I'd post here because it is related to these posts, instead of creating a new topic.

I have been using a basic pie chart without any problems. I wanted to start using a 3D Chart with stacking and grouping. It looked great in jsfiddle, but when I used it on our web server it wasn't 3D. I realized that I was on Highcharts version 3.0.1, which was downloaded and loaded onto our web server under a js folder. So I downloaded the latest version and loaded that. But the 3D chart is still "flat" and doesn't look 3D like in jsfiddle. Not sure what the problem may be.

Any help would be greatly appreciated! Thank you in advance.

Below is the HTML page:

<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
colors: ["#009900", "#FF0000", "#FFFF00", "#0000FF"],
chart: {
type: 'column',
options3d: {
enabled: true,
alpha: 15,
beta: 15,
viewDistance: 25,
depth: 40
}
},

title: {
text: 'Receipt to Due Date<br>All Suppliers'
},

xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},

yAxis: {
allowDecimals: false,
min: 0,
title: {
text: 'Days Late'
}
},

tooltip: {
headerFormat: '<b>{point.key}</b><br>',
pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: {point.y} / {point.stackTotal}'
},

plotOptions: {
column: {
stacking: 'normal',
depth: 40
}
},

series: [{
name: 'On Time',
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
stack: 'days'
}, {
name: '1-5 Days Late',
data: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1],
stack: 'days'
}, {
name: '6-10 Days Late',
data: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2],
stack: 'days'
}, {
name: '> 10 Days Late',
data: [4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3],
stack: 'days'
}]
});
});

</script>
</head>
<body>
<script src="/js/highcharts.js"></script>
<script src="/js/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
User avatar
KacperMadej
Posts: 4632
Joined: Mon Sep 15, 2014 12:43 pm

Re: Newbie needs help!

Hi,

It looks like you are not loading highcharts-3d.js library required for 3D to work in Highcharts.
You can notice that this file is loaded in every 3D demos. Example:
http://jsfiddle.net/gh/get/jquery/1.9.1 ... teractive/

(Files are loaded in HTML section of JSFiddle demo.)

Let us know if you have any more questions.

Best Regards.
Kacper Madej
Highcharts Developer
russelln
Posts: 20
Joined: Fri Jul 01, 2016 9:14 pm

Re: Newbie needs help!

That did it! I can't believe I missed that. Thank you very much.
russelln
Posts: 20
Joined: Fri Jul 01, 2016 9:14 pm

Re: Newbie needs help!

Hello again,

I want to add a grid of data (numbers) to the legend of the standard "3D Column with Stacking and Grouping" chart. Not sure the best way to do this. Maybe the best way is to use a separate section of HTML code outside the charting?

Here is the chart I'm using saved in JSfiddle:

http://jsfiddle.net/58z66yns/

I have attached a picture of the highchart and a sample chart with the grid of numbers I am looking to reproduce.

Thank you in advance for your time,
Russell Nielson
Attachments
sample.jpg
sample.jpg (94.73 KiB) Viewed 3345 times
User avatar
KacperMadej
Posts: 4632
Joined: Mon Sep 15, 2014 12:43 pm

Re: Newbie needs help!

Hi Russell,

Table under axis might be achieved through grouped categories plugin, but it is not supporting 3D charts - https://github.com/blacklabel/grouped_c ... /issues/35

Another option could be to add a table under a chart.
FAQ with demo: http://www.highcharts.com/docs/getting- ... data-table

Best Regards.
Kacper Madej
Highcharts Developer
russelln
Posts: 20
Joined: Fri Jul 01, 2016 9:14 pm

Re: Newbie needs help!

Thanks! I was able to use standard HTML table code to get the job done and my chart is perfect!

Now I am looking to do another chart using a Curved Trend Line, as shown in the example picture below. I see that High Charts does the standard Trend Line, but not the Curved. Any way to do this?

Thank you in advance,
Russ
curved trend line.png
curved trend line.png (121 KiB) Viewed 3241 times
User avatar
KacperMadej
Posts: 4632
Joined: Mon Sep 15, 2014 12:43 pm

Re: Newbie needs help!

Hi,

The image is not working, but I guess you could use a spline type series.

Another solution could be to calculate the needed curve and display it's approximation using line or spline series.

Kind Regards.
Kacper Madej
Highcharts Developer
russelln
Posts: 20
Joined: Fri Jul 01, 2016 9:14 pm

Re: Newbie needs help!

Hello,

Is anyone monitoring this forum?

I have a question about the pie chart. When you click on one of the segments, it moves/shifts out from the main pie a little, then moves back when clicked again, or another segment is clicked. Is there a way to have the chart return to the clicked segment back to the calling program? I wanted to be able to go to another screen depending on which segment the user clicked on the pie chart.

Thanks in advance,
Russ
Last edited by russelln on Wed Aug 23, 2017 8:09 pm, edited 1 time in total.
pritideo
Posts: 1
Joined: Mon Aug 21, 2017 7:59 am

Re: Newbie needs help!

Request you to help me for below issue. I am trying to add highcharts example in eclipse, but that is not working .
I am new to programming language. Please excuse me :)

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jq ... "></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exp ... "></script>

</head>
<body>
<script>
Highcharts.chart('container', {
title: {
text: 'Combination chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
},
labels: {
items: [{
html: 'Total fruit consumption',
style: {
left: '50px',
top: '18px',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
}
}]
},
series: [{
type: 'column',
name: 'Jane',
data: [3, 2, 1, 3, 4]
}, {
type: 'column',
name: 'John',
data: [2, 3, 5, 7, 6]
}, {
type: 'column',
name: 'Joe',
data: [4, 3, 3, 9, 0]
}, {
type: 'spline',
name: 'Average',
data: [3, 2.67, 3, 6.33, 3.33],
marker: {
lineWidth: 2,
lineColor: Highcharts.getOptions().colors[3],
fillColor: 'white'
}
}, {
type: 'pie',
name: 'Total consumption',
data: [{
name: 'Jane',
y: 13,
color: Highcharts.getOptions().colors[0] // Jane's color
}, {
name: 'John',
y: 23,
color: Highcharts.getOptions().colors[1] // John's color
}, {
name: 'Joe',
y: 19,
color: Highcharts.getOptions().colors[2] // Joe's color
}],
center: [100, 80],
size: 100,
showInLegend: false,
dataLabels: {
enabled: false
}
}]
});
</script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
kamil

Re: Newbie needs help!

Answer for pritideo:

I saved your code as a file and got the error 15: https://www.highcharts.com/errors/13
Please try to move rendering div before the script tag with Highcharts configuration:

Code: Select all

(...)
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

<script>
Highcharts.chart('container', {
title: {
text: 'Combination chart'
},
(...)
Best regards!
kamil

Re: Newbie needs help!

Answer for russelln

You can use this code for finding out which chart's points were are sliced:

Code: Select all

chart.series.forEach(function(series) {
	series.points.forEach(function(point) {
  	if(point.sliced) {
    	console.log(point);
    }
  });
});
Demo: http://jsfiddle.net/kkulig/ssve8Lq2/

Best regards!

Return to “Highcharts Usage”