Commit cf9cb429 authored by David Schnur's avatar David Schnur

Fix the pie interactivity example.

parent 61a13d10
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
#menu button { #menu button {
display: inline-block; display: inline-block;
width: 200px; width: 200px;
margin-bottom: 2px; margin-bottom: 5px;
font-size: 16px;
} }
#description { #description {
...@@ -109,12 +110,16 @@ ...@@ -109,12 +110,16 @@
} }
} }
var placeholder = $("#placeholder");
$("#example-1").click(function() { $("#example-1").click(function() {
placeholder.unbind();
$("#title").text("Default pie chart"); $("#title").text("Default pie chart");
$("#description").text("The default pie chart with no options set."); $("#description").text("The default pie chart with no options set.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true show: true
...@@ -135,10 +140,12 @@ ...@@ -135,10 +140,12 @@
$("#example-2").click(function() { $("#example-2").click(function() {
placeholder.unbind();
$("#title").text("Default without legend"); $("#title").text("Default without legend");
$("#description").text("The default pie chart when the legend is disabled. Since the labels would normally be outside the container, the chart is resized to fit."); $("#description").text("The default pie chart when the legend is disabled. Since the labels would normally be outside the container, the chart is resized to fit.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true show: true
...@@ -165,10 +172,12 @@ ...@@ -165,10 +172,12 @@
$("#example-3").click(function() { $("#example-3").click(function() {
placeholder.unbind();
$("#title").text("Custom Label Formatter"); $("#title").text("Custom Label Formatter");
$("#description").text("Added a semi-transparent background to the labels and a custom labelFormatter function."); $("#description").text("Added a semi-transparent background to the labels and a custom labelFormatter function.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -213,10 +222,12 @@ ...@@ -213,10 +222,12 @@
$("#example-4").click(function() { $("#example-4").click(function() {
placeholder.unbind();
$("#title").text("Label Radius"); $("#title").text("Label Radius");
$("#description").text("Slightly more transparent label backgrounds and adjusted the radius values to place them within the pie."); $("#description").text("Slightly more transparent label backgrounds and adjusted the radius values to place them within the pie.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -261,10 +272,12 @@ ...@@ -261,10 +272,12 @@
$("#example-5").click(function() { $("#example-5").click(function() {
placeholder.unbind();
$("#title").text("Label Styles #1"); $("#title").text("Label Styles #1");
$("#description").text("Semi-transparent, black-colored label background."); $("#description").text("Semi-transparent, black-colored label background.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -311,10 +324,12 @@ ...@@ -311,10 +324,12 @@
$("#example-6").click(function() { $("#example-6").click(function() {
placeholder.unbind();
$("#title").text("Label Styles #2"); $("#title").text("Label Styles #2");
$("#description").text("Semi-transparent, black-colored label background placed at pie edge."); $("#description").text("Semi-transparent, black-colored label background placed at pie edge.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -361,10 +376,12 @@ ...@@ -361,10 +376,12 @@
$("#example-7").click(function() { $("#example-7").click(function() {
placeholder.unbind();
$("#title").text("Hidden Labels"); $("#title").text("Hidden Labels");
$("#description").text("Labels can be hidden if the slice is less than a given percentage of the pie (10% in this case)."); $("#description").text("Labels can be hidden if the slice is less than a given percentage of the pie (10% in this case).");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -405,10 +422,12 @@ ...@@ -405,10 +422,12 @@
$("#example-8").click(function() { $("#example-8").click(function() {
placeholder.unbind();
$("#title").text("Combined Slice"); $("#title").text("Combined Slice");
$("#description").text("All slices less than a given percentage of the pie can be combined into a single, larger slice (10% in this case)."); $("#description").text("All slices less than a given percentage of the pie can be combined into a single, larger slice (10% in this case).");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -443,10 +462,12 @@ ...@@ -443,10 +462,12 @@
$("#example-9").click(function() { $("#example-9").click(function() {
placeholder.unbind();
$("#title").text("Rectangular Pie"); $("#title").text("Rectangular Pie");
$("#description").text("The radius can also be set to a specific size (even larger than the container itself)."); $("#description").text("The radius can also be set to a specific size (even larger than the container itself).");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -485,10 +506,12 @@ ...@@ -485,10 +506,12 @@
$("#example-10").click(function() { $("#example-10").click(function() {
placeholder.unbind();
$("#title").text("Tilted Pie"); $("#title").text("Tilted Pie");
$("#description").text("The pie can be tilted at an angle."); $("#description").text("The pie can be tilted at an angle.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true, show: true,
...@@ -543,10 +566,12 @@ ...@@ -543,10 +566,12 @@
$("#example-11").click(function() { $("#example-11").click(function() {
placeholder.unbind();
$("#title").text("Donut Hole"); $("#title").text("Donut Hole");
$("#description").text("A donut hole can be added."); $("#description").text("A donut hole can be added.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
innerRadius: 0.5, innerRadius: 0.5,
...@@ -569,10 +594,12 @@ ...@@ -569,10 +594,12 @@
$("#example-12").click(function() { $("#example-12").click(function() {
placeholder.unbind();
$("#title").text("Interactivity"); $("#title").text("Interactivity");
$("#description").text("The pie can be made interactive with hover and click events."); $("#description").text("The pie can be made interactive with hover and click events.");
$.plot("#placeholder", data, { $.plot(placeholder, data, {
series: { series: {
pie: { pie: {
show: true show: true
...@@ -598,7 +625,7 @@ ...@@ -598,7 +625,7 @@
"});" "});"
]); ]);
$("#placeholder").bind("plothover", function(event, pos, obj) { placeholder.bind("plothover", function(event, pos, obj) {
if (!obj) { if (!obj) {
return; return;
...@@ -608,7 +635,7 @@ ...@@ -608,7 +635,7 @@
$("#hover").html("<span style='font-weight:bold; color:" + obj.series.color + "'>" + obj.series.label + " (" + percent + "%)</span>"); $("#hover").html("<span style='font-weight:bold; color:" + obj.series.color + "'>" + obj.series.label + " (" + percent + "%)</span>");
}); });
$("#placeholder").bind("plotclick", function(event, pos, obj) { placeholder.bind("plotclick", function(event, pos, obj) {
if (!obj) { if (!obj) {
return; return;
...@@ -661,7 +688,7 @@ ...@@ -661,7 +688,7 @@
<button id="example-9">Rectangular Pie</button> <button id="example-9">Rectangular Pie</button>
<button id="example-10">Tilted Pie</button> <button id="example-10">Tilted Pie</button>
<button id="example-11">Donut Hole</button> <button id="example-11">Donut Hole</button>
<button id="example-11">Interactivity</button> <button id="example-12">Interactivity</button>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment