JavaScript - Graficos Chart.js

 
Vista:

Graficos Chart.js

Publicado por Juan Pablo (2 intervenciones) el 18/02/2016 04:15:23
Buenas noches, estoy haciendo unos graficos usando chart.js. Esta muy bueno, pero no logre hacer funcionar los graficos teniendo 2 tipos de graficos iguales, ej: dos piechart. les adjunto el codigo.
Espero puedan darme una mano
Saludos


CODIGO:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//-------------
//- PIE CHART1
//-------------
 
 
var PieData = [
	{
		value: 2,
		color: "#dd4b39",
		highlight: "#FFC0CB",
		label: "2"
	},
 
	{
		value: 1,
		color: "#3c8dbc",
		highlight: "#9dc6dd",
		label: "1"
 
	}
];
 
window.onload = function () {
 
	var ctx = document.getElementById("pieChart").getContext("2d");
	window.myDoughnut = new Chart(ctx).Doughnut(PieData, { responsive: true });
 
};
 
//-------------
//- PIE CHART 2
//-------------
// Get context with jQuery - using jQuery's .get() method.

var PieData2 = [
	{
		value: 2,
		color: "#dd4b39",
		highlight: "#FFC0CB",//"#FFF2F4",//"#f56954"
		label: "2"
	},

	{
		value: 1,
		color: "#3c8dbc",
		highlight: "#9dc6dd",
		label: "1"

	}
];

window.onload = function () {

	var ctxpagaron = document.getElementById("pieChartOtro").getContext("2d");
	window.myDoughnut = new Chart(ctxpagaron).Doughnut(PieData2, { responsive: true });

};
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Graficos Chart.js

Publicado por xve (2100 intervenciones) el 18/02/2016 08:29:57
Hola Juan Pablo, entiendo que tu problema es que tienes definido dos veces el window.onload... y solo te ejecuta uno... prueba así:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//-------------
//- PIE CHART1
//-------------
 
var PieData = [
	{
		value: 2,
		color: "#dd4b39",
		highlight: "#FFC0CB",
		label: "2"
	},
 
	{
		value: 1,
		color: "#3c8dbc",
		highlight: "#9dc6dd",
		label: "1"
 
	}
];
 
//-------------
//- PIE CHART 2
//-------------
// Get context with jQuery - using jQuery's .get() method.

var PieData2 = [
	{
		value: 2,
		color: "#dd4b39",
		highlight: "#FFC0CB",//"#FFF2F4",//"#f56954"
		label: "2"
	},

	{
		value: 1,
		color: "#3c8dbc",
		highlight: "#9dc6dd",
		label: "1"

	}
];

window.onload = function () {

	var ctxpagaron = document.getElementById("pieChartOtro").getContext("2d");
	window.myDoughnut = new Chart(ctxpagaron).Doughnut(PieData2, { responsive: true });

	var ctx = document.getElementById("pieChart").getContext("2d");
	window.myDoughnut = new Chart(ctx).Doughnut(PieData, { responsive: true });
};
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Graficos Chart.js

Publicado por Juan Pablo (2 intervenciones) el 18/02/2016 12:04:56
Muchas gracias fue un exito!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar