/    Sign up×
Community /Pin to ProfileBookmark

Need to pass proper data to heading title.

In this code is showing charts nicely with real data. I have to show better code for the headings the company name and dates.

How is best way to display this type of data? this bit here: title: {
text: ‘Prospect Park Res. Department Spending May 2011 ‘
},

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”PieChart.aspx.cs” Inherits=”SA_Dashboard.PieChart” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head runat=”server”>
<title>Highchart real data drill sample</title>
<script src=”Javascript/jquery-1.5.1.js” type=”text/javascript”></script>
<script src=”Javascript/highcharts/highcharts.js” type=”text/javascript”></script>
<script src=”Javascript/highcharts/modules/exporting.js” type=”text/javascript”></script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div id=”container” style=”width: 100%”>
</div>
</form>
<script type=”text/javascript”>
//Global Chart
var chart;

var customerID = ‘<%=this.CustomerID %>’;

$(document).ready(function () {
DrawDeptChart();
});

function DrawCategoriesChart(DepartmentID) {
//Call Ajax
$.ajax({
url: “Ajax/AjaxHelper.aspx/GetCustomerDepartmentCategories”,

data: “{‘customerID’:'” + customerID + “‘,’departmentID’:'” + DepartmentID + “‘}”,
type: “POST”,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
success: function (data) {
//$(‘.Pager’).html(msg.d);

var series = {
type: ‘pie’,
name: ‘Categories’,
data: []
};

chart.series[0].remove();

jQuery.each(data.d, function (itemNo, item) {
//Get the items from the JSON and add then
//to the data array of the series

series.data.push({
name: item.CategoryName,
y: parseFloat(item.Expense),
CategoryID: item.CategoryID,
AllowDrillDown: item.AllowDrillDown
})
});

chart.addSeries(series);
//options.series.push(series);

//Create the chart
//chart = new Highcharts.Chart(options);
//chart.render();
}
});

}

function DrawDeptChart() {
//define the options
var options = {
chart: {
renderTo: ‘container’,
margin: [50, 200, 60, 170]
},
title: {
text: ‘Prospect Park Res. Department Spending May 2011 ‘
},
plotArea: {
shadow: null,
borderWidth: null,
backgroundColor: null
},
tooltip: {
formatter: function () {
return ‘<b>’ + this.point.name + ‘</b>: ‘ + this.y + ‘ %’;
}
},
plotOptions: {
pie: {
//allowPointSelect: true,
cursor: ‘pointer’,
point: {
events: {
click: function () {
var drilldown = this.AllowDrillDown;
if (drilldown) { // drill down
DrawCategoriesChart(this.DepartmentID);
} else { // restore
DrawDeptChart();
}
}
}
},
dataLabels: {
enabled: true,
formatter: function () {
return ‘<b>’ + this.point.name + ‘</b>: ‘ + this.y + ‘ K’;
},

style: {
font: ’13px Trebuchet MS, Verdana, sans-serif’
}
}
}
},
legend: {
layout: ‘vertical’,
style: {
left: ‘auto’,
bottom: ‘auto’,
right: ’50px’,
top: ‘100px’
}
},
series: []
};

//Call Ajax
$.ajax({
url: “Ajax/AjaxHelper.aspx/GetCustomerDepartments”,
data: “{‘customerID’:'” + customerID + “‘}”,
type: “POST”,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
success: function (data) {
//$(‘.Pager’).html(msg.d);

var series = {
type: ‘pie’,
name: ‘Departments’,
data: []
};

jQuery.each(data.d, function (itemNo, item) {
//Get the items from the JSON and add then
//to the data array of the series

series.data.push({
name: item.DepartmentName,
y: parseFloat(item.Expense),
DepartmentID: item.DepartmentID,
AllowDrillDown: item.AllowDrillDown
})
});

options.series.push(series);

//Create the chart
chart = new Highcharts.Chart(options);
chart.render();
}
});

}

</script>

</body>
</html>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @trancefrank spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...