Highcharts map appending unwanted data - javascript
I have a small problem with my Highcharts maps. I managed to get it plotting the data I want and even included a selector so the user can adjust which data series is shown. However, it appears that after rendering one particular series once, the Map is appending data objects to each series for those U.S. territories I don't have data for. My biggest series has 53 data objects (US States plus DC, Puerto Rico, Virgin Islands) but after being rendered once the series shows up with 62 structures including those for which I didn't have data (Saint John, Saipan, etc.). This is causing problems with the snippet of code I use to change the state code to the hc-key format needed by this map. While I could just add some extra checks to that function, i would like to understand why Highcharts is adding data to my data structures. Any help would be most appreciated. My Javascript code is below:
<script type="text/javascript">
var states ={resStates: [{code: "AK",value:3},{code: "AL",value:49},{code: "AR",value:9},{code: "AZ",value:28},{code: "CA",value:170},{code: "CO",value:26},{code: "CT",value:12},{code: "DC",value:10},{code: "DE",value:5},{code: "FL",value:126},{code: "GA",value:51},{code: "HI",value:7},{code: "IA",value:5},{code: "ID",value:13},{code: "IL",value:31},{code: "IN",value:28},{code: "KS",value:15},{code: "KY",value:12},{code: "LA",value:17},{code: "MA",value:54},{code: "MD",value:124},{code: "ME",value:13},{code: "MI",value:60},{code: "MN",value:8},{code: "MO",value:19},{code: "MS",value:16},{code: "MT",value:6},{code: "NC",value:43},{code: "ND",value:3},{code: "NE",value:10},{code: "NH",value:14},{code: "NJ",value:72},{code: "NM",value:35},{code: "NV",value:7},{code: "NY",value:70},{code: "OH",value:84},{code: "OK",value:23},{code: "OR",value:11},{code: "PA",value:101},{code: "PR",value:2},{code: "RI",value:20},{code: "SC",value:26},{code: "SD",value:5},{code: "TN",value:19},{code: "TX",value:91},{code: "UT",value:67},{code: "VA",value:112},{code: "VI",value:1},{code: "VT",value:1},{code: "WA",value:29},{code: "WI",value:13},{code: "WV",value:2},{code: "WY",value:4}],
acadStates: [{code: "AK",value:1},{code: "AL",value:47},{code: "AR",value:12},{code: "AZ",value:31},{code: "CA",value:163},{code: "CO",value:34},{code: "CT",value:9},{code: "DC",value:18},{code: "DE",value:7},{code: "FL",value:121},{code: "GA",value:80},{code: "HI",value:6},{code: "IA",value:9},{code: "ID",value:9},{code: "IL",value:29},{code: "IN",value:55},{code: "KS",value:16},{code: "KY",value:8},{code: "LA",value:14},{code: "MA",value:65},{code: "MD",value:81},{code: "ME",value:8},{code: "MI",value:66},{code: "MN",value:7},{code: "MO",value:20},{code: "MS",value:13},{code: "MT",value:4},{code: "NB",value:1},{code: "NC",value:53},{code: "ND",value:4},{code: "NE",value:8},{code: "NH",value:13},{code: "NJ",value:32},{code: "NM",value:32},{code: "NV",value:4},{code: "NY",value:93},{code: "OH",value:83},{code: "OK",value:25},{code: "OR",value:7},{code: "PA",value:123},{code: "PR",value:2},{code: "RI",value:15},{code: "SC",value:17},{code: "SD",value:4},{code: "TN",value:9},{code: "TX",value:103},{code: "UT",value:62},{code: "VA",value:114},{code: "VT",value:2},{code: "WA",value:27},{code: "WI",value:19},{code: "WV",value:4},{code: "WY",value:4}],
empStates: [{code: "AK",value:2},{code: "AL",value:71},{code: "AR",value:4},{code: "AZ",value:12},{code: "CA",value:235},{code: "CO",value:1},{code: "DC",value:36},{code: "FL",value:104},{code: "GA",value:70},{code: "HI",value:5},{code: "IL",value:17},{code: "IN",value:18},{code: "KS",value:14},{code: "LA",value:5},{code: "MA",value:61},{code: "MD",value:244},{code: "MI",value:39},{code: "MN",value:3},{code: "MO",value:4},{code: "MS",value:64},{code: "NC",value:22},{code: "NE",value:2},{code: "NH",value:20},{code: "NJ",value:62},{code: "NM",value:95},{code: "NY",value:22},{code: "OH",value:133},{code: "OK",value:53},{code: "OR",value:7},{code: "PA",value:38},{code: "RI",value:37},{code: "SC",value:26},{code: "TN",value:9},{code: "TX",value:22},{code: "UT",value:75},{code: "VA",value:126},{code: "WA",value:22},{code: "WV",value:2}]};
$(init)
function init() {
drawMap();
}
function drawMap() {
var map_select = $('#smartStates').val();
var map_text = $('#smartStates option:selected').text();
var mydata = states[map_select];
var mycolors = {resStates: {
min: 1,
type: 'linear',
minColor: '#EEEEFF',
maxColor: '#000022',
stops: [
[0, '#EFEFFF'],
[0.67, '#4444FF'],
[1, '#000022']
]
}, acadStates: {
min: 1,
type: 'linear',
minColor: '#FFEEEE',
maxColor: '#220000',
stops: [
[0, '#FFFFEE'],
[0.67, '#FF4444'],
[1, '#220000']
]
}, empStates: {
min: 1,
type: 'linear',
minColor: '#EEFFEE',
maxColor: '#002200',
stops: [
[0, '#EEFFEE'],
[0.67, '#44FF44'],
[1, '#002200']
]
}
}
// Adjusting codes to fit with the us-all-territories map
$.each(mydata, function(){ //looping through each instance of mydata
if (this.code == "PR") {
this.code = "pr-3614";
} else if (this.code == "undefined"){
//not sure what to do here
}
else if (this.code.length==2) {
this.code = "us-" + this.code.toLowerCase();
}
});
// Instanciate the map
$('#container').highcharts('Map', {
chart : {
borderWidth : 1
},
title : {
text : 'SMART Participant Counts by ' + map_text
},
legend: {
layout: 'horizontal',
borderWidth: 0,
backgroundColor: 'rgba(255,255,255,0.85)',
floating: true,
verticalAlign: 'top',
y: 25
},
mapNavigation: {
enabled: true
},
colorAxis: mycolors[map_select],
series : [{
animation: {
duration: 1000
},
data : mydata,
mapData: Highcharts.maps['countries/us/custom/us-all-territories'],
joinBy: ['hc-key', 'code'],
dataLabels: {
enabled: true,
color: '#FFFFFF',
format: '{point.name}'
},
name: 'SMART Participants',
tooltip: {
pointFormat: '{point.name}: {point.value} participants'
}
}]
});
}
</script>
This is because in your mapData property you have this:
mapData: Highcharts.maps['countries/us/custom/us-all-territories'],
us-all-territories, but as you stated, you don't have the data for all of the territories.
The solution is to use a different custom map from Highcharts, unfortunately it doesn't look like they have one with only the US territories you are looking for.
Update: as the comment by Kacper has mentioned: If you set allAreas in series to false, then empty map zones will not be displayed. Example: http://jsfiddle.net/oen00hec/
Related
Pass data to Stacked Column Chart (Highcharts Framework)
I have a problem when trying to render a stacked column chart with the Highcharts framework. I get an error when rendering on the client: Uncaught TypeError: a.toPrecision is not a function From what I've gathered this is related with stacking. If I set stacking to null it won't give an error, but no graph will show. I'm passing dynamic data to the series. The data is in the form of a name for the legend and an array of values for each xAxis category. Below is an example of one object that is passed as data. This is stored in an array with a more entries. name:"READ_CALENDAR" y: (24) [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] This must be the wrong way, since I can't get it to work, but what then is the correct way? My question is, what am I doing wrong? How should I pass dynamic data to make it work? I need to pass several unique instances of data that need to stack and match the xAxis categories. I will add more details below regarding how I pass data and such. If you want more info comment and I will try to provide as much as I can. Please help! Thanks in advance!!! This is an example of data that is passed to the client: [{"name":"READ_CALENDAR","timesUsed":[1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0]}, {"name":"READ_CONTACTS","timesUsed":[1,0,0,0,0,0,0,0,0,0,0,0,5,8,12,3,2,0,1,0,0,0,0,0]}, {"name":"READ_EXTERNAL_STORAGE","timesUsed":[1,0,0,0,0,0,0,0,0,10,0,1,9,17,13,39,8,1,0,0,0,0,0,2]}, {"name":"WRITE_EXTERNAL_STORAGE","timesUsed":[1,0,0,0,0,0,0,0,0,10,0,2,9,17,13,38,8,1,0,0,0,0,0,2]}, {"name":"WRITE_SMS","timesUsed":[1,0,0,0,0,0,0,0,0,0,0,0,5,7,12,2,2,1,0,0,0,0,0,0]}, {"name":"CAMERA","timesUsed":[0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,2,1,0,0,0,0,0,0]}, {"name":"FINE_LOCATION","timesUsed":[0,0,0,0,0,0,0,0,0,15,4,0,0,0,0,2,0,0,0,0,0,0,0,0]}, {"name":"GPS","timesUsed":[0,0,0,0,0,0,0,0,0,3,0,0,0,1,1,2,0,0,0,0,0,0,0,0]}, {"name":"MONITOR_HIGH_POWER_LOCATION","timesUsed":[0,0,0,0,0,0,0,0,0,4,0,0,0,1,1,2,0,0,0,0,0,0,0,0]}, {"name":"MONITOR_LOCATION","timesUsed":[0,0,0,0,0,0,0,0,0,3,0,0,0,1,1,2,0,0,0,0,0,0,0,0]}, {"name":"OP_READ_PHONE_STATE","timesUsed":[0,0,0,0,0,0,0,0,0,2,0,0,3,2,1,3,0,2,0,0,0,0,0,0]}, {"name":"POST_NOTIFICATION","timesUsed":[0,0,0,0,0,0,0,0,0,16,15,7,10,14,26,17,5,2,1,0,0,0,0,0]}, {"name":"TAKE_AUDIO_FOCUS","timesUsed":[0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1,0,0,0,0,0,0,0,0]}, {"name":"TOAST_WINDOW","timesUsed":[0,0,0,0,0,0,0,0,0,14,15,7,10,9,13,12,3,1,0,0,0,0,0,0]}, {"name":"WAKE_LOCK","timesUsed":[0,0,0,0,0,0,0,0,0,6,0,0,1,3,2,17,7,2,0,0,0,0,0,1]}, {"name":"WIFI_SCAN","timesUsed":[0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0]}, {"name":"BOOT_COMPLETED","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,4,2,0,0,0,0,0,0,0,0,0,0]}, {"name":"GET_ACCOUNTS","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,3,0,0,0,0,0,0,0,0]}, {"name":"WIFI_CHANGE","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,4,2,0,0,0,0,0,0,0,0,0,0]}, {"name":"USE_FINGERPRINT","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0]}, {"name":"RECORD_AUDIO","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,0,0,0,0,0,0,0]}, {"name":"VIBRATE","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,0,0,0,0,0,0,0]}, {"name":"WRITE_CALENDAR","timesUsed":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0]}] This data will then be parsed to a JSON Object with: var jsonObj = JSON.parse(obj); (where obj is the data) Then the the data will be pushed to an array: var seriesData = []; for (var i in jsonObj) { seriesData.push({ name: jsonObj[i].name , y: jsonObj[i].timesUsed }); } Then the Hichcharts scripts looks like this: Highcharts.chart('permData', { chart: { type: 'column' }, title: { text: 'Example graph' }, xAxis: { categories: ['00-01','01-02','02-03','03-04','04-05','05-06','06-07','07-08','08-09','09-10','10-11','11-12','12-13','13-14','14-15','15-16','16-17','17-18','18-19','19-20','20-21','21-22','22-23','23-24'] }, yAxis: { min: 0, title: { text: 'Y axis text here' }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: null /*(Highcarts.theme && Highcharts.theme.textColor) || 'gray'*/ } } }, legend: { align: 'right', x: -30, verticalAlign: 'top', y: 25, floating: true, backgroundColor: null /*(Highcharts.theme && Highcharts.theme.background2) || 'white'*/, borderColor: '#CCC', borderWidth: 1, shadow: false }, tooltop: { headerFormat: '<b>{point.x}</b><br/>', pointFormat: '{series.name}:{point.y}<br/>', }, plotOptions: { column: { stacking: 'percentage', dataLabels: { enabled: true, color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white' } } }, series: [{ type: 'column', name: 'perm', data: seriesData }] });
You were very close, you have set y instead of data in your loop building the dataSeries. It should be like this: for (var i in jsonObj) { seriesData.push({ name: jsonObj[i].name , data: jsonObj[i].timesUsed //data instead of y }); } After changing that, it works in the fiddle. y is a member of data, and is used in case you want to set several properties for each point. Working example: https://jsfiddle.net/ewolden/r5yd56eb/1/ API on series.data: https://api.highcharts.com/highcharts/series.column.data
How do I remove padding from both sides of Highcharts area category chart?
There's too much padding on either side of the area chart and minPadding/maxPadding doesn't work with categories. I want the area chart to start and end without any padding. My code is below: http://jsfiddle.net/nx4xeb4k/1/ $('#container').highcharts({ chart: { type: 'area', inverted: false }, title: { text: 'Too Much Padding On Either Side' }, plotOptions: { series: { fillOpacity: 0.1 } }, xAxis: { type: 'category' }, yAxis: { title: { text: 'Data Point' } }, legend: { enabled: false }, tooltip: { pointFormat: '<b>{point.y}</b> points' }, series: [{ name: 'Visits', data: [ ["Monday", 58], ["Tuesday", 65], ["Wednesday", 55], ["Thursday", 44], ["Friday", 56], ["Saturday", 65], ["Sunday", 69] ], dataLabels: { enabled: false, rotation: -90, color: '#FFFFFF', align: 'right', format: '{point.y:.1f}', y: 10, style: { fontSize: '14px', fontFamily: 'Verdana, sans-serif' } } }] });
A colleague of mine solved this very situation for some of my charts. Their solution was to remove the type: 'category' from the x-axis (making it a linear type instead) and instead replace the axis labels from an array. Here's what's been changed: First, I added an array of your x-axis labels. var categoryLabels = ["Monday","Tuesday","Wednesday","Thursday","Friday", "Saturday","Sunday"]; Next, I updated your series values to hold only the y-axis values. series: [{ name: 'Visits', data: [58, 65, 55, 44, 56, 65, 69], Then, for your x-axis, I included a formatter function to pull in the labels from the array as substitutes for the default linear values. xAxis: { labels: { formatter: function(){ return categoryLabels[this.value]; } } }, Lastly, I updated the tooltip options to show the values from the labels array. tooltip: { formatter: function () { return categoryLabels[this.x] + ': ' + Highcharts.numberFormat(this.y,0); } }, I updated your fiddle with this tweaks: http://jsfiddle.net/brightmatrix/nx4xeb4k/4/ I hope you'll find this solution as useful as I have!
According to API, the default value of highcharts.xAxis.tickmarkPlacement is between and this is why the point of each category drops between two ticks on xAxis in your chart. By setting highcharts.xAxis.tickmarkPlacement to on and playing around the value of highcharts.xAxis.min and highcharts.xAxis.max like this, you should be able to achieve what you want.
You can declare the min / max values to fix the problem. var categoryLabels = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; //.... xAxis: { min: 0.49, max: categoryLabels.length - 1.49, categories: categoryLabels, type: 'category' }, Example: http://jsfiddle.net/fo04m7k7/
Highcharts Map not rendering no errors
I am attempting to take the example produced by Highcharts here http://www.highcharts.com/maps/demo/color-axis and substitute the data loaded by the $.getJson with a local JSON file called 'testdata1.json'. The code I've modified below produces no errors yet the map does not render. I think it's because the testdata1.json is loaded late, after the javascript is executed. If so, is there a better way I should be doing this -- perhaps waiting for the data to load before executing the JS file? I attempted to do this by placing a $(document).ready( in front of the function but it didn't work. Any thoughts are greatly appreciated, I think it's something relatively minor that is just escaping me. Thank you. $(function () { // Map options var options = { chart : { renderTo: '#map', borderWidth : 1 }, title : { text : 'US population density (/km²)' }, legend: { layout: 'horizontal', borderWidth: 0, backgroundColor: 'rgba(255,255,255,0.85)', floating: true, verticalAlign: 'top', y: 25 }, mapNavigation: { enabled: true }, colorAxis: { min: 1, type: 'logarithmic', minColor: '#EEEEFF', maxColor: '#000022', stops: [ [0, '#EFEFFF'], [0.67, '#4444FF'], [1, '#000022'] ] }, series : [{ animation: { duration: 1000 }, mapData: Highcharts.maps['countries/us/us-all'], joinBy: ['postal-code', 'code'], dataLabels: { enabled: true, color: 'white', format: '{point.code}' }, name: 'Population density', tooltip: { pointFormat: '{point.code}: {point.value}/km²' } }] }; $.getJSON('static/data/testdata1.json', function (data) { // Make codes uppercase to match the map data $.each(data, function () { this.code = this.code.toUpperCase(); }); options.series.data= data; var chart = new Highcharts.Chart(options) }); });
You have three problems. Here's a fiddle based on their sample that uses your approach, but still uses their data, and works: http://jsfiddle.net/g29k24vw/1/ Here are the important parts: chart : { renderTo: 'container', borderWidth : 1, type: 'map' }, And: $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=us-population-density.json&callback=?', function (data) { // Make codes uppercase to match the map data $.each(data, function () { this.code = this.code.toUpperCase(); }); options.series[0].data= data; var chart = new Highcharts.Chart(options); }); Note the differences here: You need to specify the chart type in options if you're going to instantiate the chart object directly instead of using the jQuery helper. renderTo doesn't want a hash in front of the element name. options.series[0].data, not options.series.data...series is actually an array of objects.
Data Not Showing in Highcharts
I'm attempting to combine a couple of different chart demos from Highcharts. My examples are: Data classes and popup and Small US with data labels I want the map from the first with the popup feature of the second. I need to connect the map to my own google spreadsheet but for now I'm just trying to get the data from the first example to work. This is what I have so far but can't seem to get any data in the map. I thought I had a joinBy problem, and I may still, but when I set joinBy to null I thought "the map items are joined by their position in the array", yet nothing happened. https://jsfiddle.net/9eq6mydv/ $(function () { // Load the data from a Google Spreadsheet // https://docs.google.com/a/highsoft.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc&output=html Highcharts.data({ googleSpreadsheetKey: '0AoIaUO7wH1HwdDFXSlpjN2J4aGg5MkVHWVhsYmtyVWc', googleSpreadsheetWorksheet: 1, // custom handler for columns parsed: function (columns) { // Make the columns easier to read var keys = columns[0], names = columns[1], percent = columns[10], // Initiate the chart options = { chart : { renderTo: 'container', type: 'map', borderWidth : 1 }, title : { text : 'US presidential election 2008 result' }, subtitle: { text: 'Source: <a href="http://en.wikipedia.org/wiki/United_States_presidential_election,' + '_2008#Election_results">Wikipedia</a>' }, mapNavigation: { enabled: true, enableButtons: false }, legend: { align: 'right', verticalAlign: 'top', x: -100, y: 70, floating: true, layout: 'vertical', valueDecimals: 0, backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || 'rgba(255, 255, 255, 0.85)' }, colorAxis: { dataClasses: [{ from: -100, to: 0, color: '#C40401', name: 'McCain' }, { from: 0, to: 100, color: '#0200D0', name: 'Obama' }] }, series : [{ data : data, dataLabels: { enabled: true, color: '#FFFFFF', format: '{point.code}', style: { textTransform: 'uppercase' } }, mapData: Highcharts.geojson(Highcharts.maps['countries/us/custom/us-small']), joinBy: keys, name: 'Democrats margin', point: { events: { click: pointClick } }, tooltip: { ySuffix: ' %' }, cursor: 'pointer' }, { type: 'mapline', data: Highcharts.geojson(Highcharts.maps['countries/us/custom/us-small'], 'mapline'), color: 'silver' }] }; /** * Event handler for clicking points. Use jQuery UI to pop up * a pie chart showing the details for each state. */ function pointClick() { var row = this.options.row, $div = $('<div></div>') .dialog({ title: this.name, width: 400, height: 300 }); window.chart = new Highcharts.Chart({ chart: { renderTo: $div[0], type: 'pie', width: 370, height: 240 }, title: { text: null }, series: [{ name: 'Votes', data: [{ name: 'Obama', color: '#0200D0', y: parseInt(columns[3][row], 10) }, { name: 'McCain', color: '#C40401', y: parseInt(columns[4][row], 10) }], dataLabels: { format: '<b>{point.name}</b> {point.percentage:.1f}%' } }] }); } // Read the columns into the data array var data = []; $.each(keys, function (i, key) { data.push({ key: key,//.toUpperCase(), value: parseFloat(percent[i]), name: names, row: i }); }); // Initiate the chart window.chart = new Highcharts.Map(options); }, error: function () { $('#container').html('<div class="loading">' + '<i class="icon-frown icon-large"></i> ' + 'Error loading data from Google Spreadsheets' + '</div>'); } }); }); UPDATE: I wanted to share with everyone my final solution. Although Ondkloss did a magnificent job answering my question the popup feature still didn't work and this is because I forgot to include the jQuery for the .dialog call. Once I included that I had an empty popup with a highchart error 17, this is because the highmaps.js code doesn't include the pie chart class. So I had to add the highcharts.js code and include map.js module afterward. You can see my final jsfiddle here. Thanks again to Ondkloss for the excellent answer!
The problem here mostly comes down to the use of joinBy. Also to correct it there are some required changes to your data and mapData. Currently your joinBy is an array of strings, like ["al", "ak", ...]. This is quite simply not an accepted format of the joinBy option. You can read up on the details in the API documentation, but the simplest approach is to have a attribute in common in data and mapData and then supply a string in joinBy which then joins those two arrays by that attribute. For example: series : [{ data : data, mapData: mapData, joinBy: "hc-key", ] Here the "hc-key" attribute must exist in both data and mapData. Here's how I'd create the data variable in your code: var data = []; $.each(keys, function (i, key) { if(i != 0) data.push({ "hc-key": "us-"+key, code: key.toUpperCase(), value: parseFloat(percent[i]), name: names[i], row: i }); }); This skips the first key, which is just "Key" (the title of the column). Here we make the "hc-key" fit the format of the "hc-key" in our map data. An example would be "us-al". The rest is just metadata that will be joined in. Note that you were referencing your data in the options prior to filling it with data, so this has to be moved prior to this. This is how I'd create the mapData variable in your code: var mapData = Highcharts.geojson(Highcharts.maps['countries/us/custom/us-small']); // Process mapdata $.each(mapData, function () { var path = this.path, copy = { path: path }; // This point has a square legend to the right if (path[1] === 9727) { // Identify the box Highcharts.seriesTypes.map.prototype.getBox.call(0, [copy]); // Place the center of the data label in the center of the point legend box this.middleX = ((path[1] + path[4]) / 2 - copy._minX) / (copy._maxX - copy._minX); this.middleY = ((path[2] + path[7]) / 2 - copy._minY) / (copy._maxY - copy._minY); } // Tag it for joining this.ucName = this.name.toUpperCase(); }); The first part is your "standard map data". The rest is to correctly center the labels for the popout states, and gotten directly from the example. And voila, see this JSFiddle demonstration to witness your map in action. I suggest doing some console.log-ing to see how data and mapData have the hc-key in common and that leads to the joining of the data in the series.
jqplot bargraph not displaying data
Not getting any errors from firebug. Not showing in any browser. Was working previously and stopped working about a week ago. Sample of the code... $(document).ready(function () { //Generic names for multiple graphs var First = $('#hfFirstOrder').val().split(","); var Second = $('#hfSecondOrder').val().split(","); var Third = $('#hfThirdOrder').val().split(","); var ticks = $('#hfDaysOrder').val().split(","); var maxValue = parseInt($('#hfMaxOrder').val()); var FirstArray = []; var SecondArray = []; var ThirdArray = []; for (i = 0; i < First.length; i++) { FirstArray.push(parseInt(First[i])); SecondArray.push(parseInt(Second[i])); ThirdArray.push(parseInt(Third[i])); } plotGraph("stackedPurchase", [FirstArray, SecondArray, ThirdArray], true, ticks, "Orders", maxValue, '#000', "Completed", '#00F', "Ship/Pick", '#F00', "Back Order"); function plotGraph(chartName, total, stackBool, tick, yLabel, maxValue, SC1, SL1, SC2, SL2, SC3, SL3) { plot = $.jqplot(chartName, total, { stackSeries: stackBool, seriesDefaults: { renderer:$.jqplot.BarRenderer, rendererOptions: { barMargin: 20, barWidth: 10 }, showMarker: false, pointLabels: { show: false } }, axes: { xaxis: { label: "Days", renderer: $.jqplot.CategoryAxisRenderer, ticks: tick }, yaxis: { label: yLabel, padMin: 0, tickInterval: parseInt(maxValue * .1), min: 0, max: maxValue, tickOptions: { formatString: '%d' } } }, series: [{ color: SC1, label: SL1 }, { color: SC2, label: SL2 }, { color: SC3, label: SL3 } ], legend: { show: true, location: 'e', placement: 'outside' } }); } }); And then there's a call in the html for <div id="stackedPurchase" style="height:450px;width:900px;" runat="server"></div> And the various hidden values are csv strings from the code behind. According to firebug they are being passed in correctly (right formats and correct number of each variable). Judging from my coding experiences recently, its probably something obvious.
Got a partial answer, the first two graphs work now because someone else at work moved the folders that the jqplot stuff was in without informing me. Changing the address in the scripts at top fixed the problem. But for some reason the third one isn't working. plotGraph("graphQuote", [FirstArray, SecondArray, ThirdArray], false, ticks, "Quotes", maxValue, '#F00', "Request RFQ", '#00F', "RFQ", '#0F0', "Customer Quote"); SecondArray is all zero values, FirstArray is mostly zero and ThirdArray has a value in most of its fields. Ticks has correct dates.
Alright, found the problem. Apparently parseInt(maxValue * .1) gets pissy and returns 0 if maxValue is less than 10, and jqplot doesn't like 0 as a tick interval. Found a better way to do intervals and now everything works.