Related
The highcharts chart is not showing.
hc.xAxis[0].categories are loaded ok, but hc.series are not
r.forEach(x => {
var hc = Highcharts.chart('chart_div', {
xAxis: { categories: x.categories },
series: x.series,
});
console.log(hc.series); // 1st
console.log(x.series); // 2nd
});
The 1stconsole.log shows no data and the 2nd one shows this:
[{name: 'DE Shaw Comp (75;Q)', data: [100,100.5,101.91,103.03,104.37,103.85,103.22,104.77,105.71,105.5,107.08,107.51,106.33,107.18,107.18,108.68,109.44,110.87,110.53,111.75,115.21,116.83,117.41,116.82,116.24,118.21,119.99,121.79,121.54,122.88,122.27,123.86,124.6,126.22,128.36,124.77,129.14,], color: '#33a', label:{enabled:false}},{name: 'SPX', data: [100,94.93,94.53,100.77,101.05,102.59,102.69,106.34,106.21,106.08,104.02,107.58,109.54,111.49,115.64,115.6,116.65,118,118.57,120.86,120.93,123.26,125.99,129.53,130.81,138.16,132.77,129.2,129.56,132.36,133,137.79,141.96,142.57,132.67,135.04,122.65,119.76], color: '#a33', label:{enabled:false}},{name: 'HFRI RV: MULTI-STRATEGY', data: [100,98.37,97.83,99.53,101.19,102,102.66,103.99,104.87,105.72,106.02,106.54,107.66,109.08,109.73,110.07,110.37,110.38,110.58,111.34,111.51,111.95,112.37,112.46,113.29,114.53,114.13,113.48,114.48,115.17,114.97,116.2,116.26,116.68,115.32,114.95,,], color: '#aa3', label:{enabled:false}}]
which looks like a proper input.
series: eval(x.series) is the solution
without eval x.series was interpreted as a string, not as an array of Object as I thought
I am generating a Project Cumulative Flow Chart, which is based on the Project name that I fetch using a "find," however I can't get it working.
Here is the Problem:
1) The "Find" in my code is just fetching one kind of project name, "FE," however, I have a lot of other Project name such as FE, BE, VisualRF, etc. I am not sure what's going on
2) I return this to "storeConfig" inside the chart and then I want try to give "Name" to the "stateFieldName." This is not working! I don't see any graph at all.
Here is the code.
_chart2: function() {
var projectName = this.getContext().getProject()._refObjectName;
console.log("========");
console.log(projectName); <<<<<<<<<< This always prints one name'FE' (My project name are FE, BE, etc)
this.chart = {
xtype: 'rallychart',
storeType: 'Rally.data.lookback.SnapshotStore',
storeConfig: this._getStoreForChart2(),
calculatorType: 'Rally.example.CFDCalculator',
calculatorConfig: {
stateFieldName: this.getContext().getProject()._refObjectName, <<<<< I think usage is not fetching name of all projects
stateFieldValues: ['FE','BE','VisualRF']
},
width: 1000,
height: 600,
chartConfig: this._getChart2Config()
};
this.chartContainer.add(this.chart);
},
_getStoreForChart2: function() {
var obj1 = {
find: {
_TypeHierarchy: { '$in' : [ 'Defect' ] },
Children: null,
_ProjectHierarchy: this.getContext().getProject().ObjectID,
_ValidFrom: {'$gt': Rally.util.DateTime.toIsoString(Rally.util.DateTime.add(new Date(), 'day', -30)) },
State: "Open",
},
fetch: ['Severity','Project','ObjectID','FormattedID'],
hydrate: ['Severity','Project','ObjectID','FormattedID'],
sort: {
_ValidFrom: 1
},
context: this.getContext().getDataContext(),
limit: Infinity,
val: this.Name,
};
return obj1;
},
Though this should not matter but here is the code for the high chart function I am calling above
_getChart2Config: function() {
console.log("starting chart config");
return {
chart: {
zoomType: 'xy'
},
title: {
text: 'Chart2'
},
xAxis: {
tickmarkPlacement: 'on',
tickInterval: 20,
title: {
text: 'Date'
}
},
yAxis: [
{
title: {
text: 'Count'
}
}
],
plotOptions: {
series: {
marker: {
enabled: false
}
},
area: {
stacking: 'normal'
}
}
};
},
Down below you can see 'FE' getting printed:
Thanks a lot!
Kay
stateFieldName is the field which is used to calculate the CFD- usually ScheduleState or a custom dropdown field like KanbanState that captures your process. The stateFieldValues should be the values of that field (Defined, In-Progress, Accepted, Completed, etc.) This doesn't deal with projects at all. Definitely remember to include that field in your hydrate and fetch as well.
I am trying to write a script that produces a col chart. The data is from an MySQL query that produces the following array content:
97.2,63.9,33.4,28.9,325.2,114.9,46.1,56.7,104.9,4.5,42.2,56.4,10.5
When I run the script I get an error:
SyntaxError: missing ] after element list
I have tracked down to where I thik the error is but can not see whats wrong.
Inside the jQuery function I have an PHP echo statement which populates the $data variable with the data, $data[] = $row_An['AValue'];.
The values are correct as seen in FireFox dev console. Can anyone see why I am getting the error.
$(function () {
<?php
$data[] = $row_An['AValue'];
?>
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'AN'
},
xAxis: {
categories: ['Inbound', 'Outbound', 'InService']
},
yAxis: {
title: {
text: ''
}
},
series: [{
data: [97.2,63.9,33.4,28.9,325.2,114.9,46.1,56.7,104.9,4.5,42.2,56.4,10.5],
pointStart: 0,
pointInterval
}]
});
});
Many thanks in advance
what's value in pointInterval ? its wrong to leave that without any value
series: [{
data: [97.2,63.9,33.4,28.9,325.2,114.9,46.1,56.7,104.9,4.5,42.2,56.4,10.5],
pointStart: 0,
pointInterval //here is error you should provide value or remove it
}]
Also, these two properties PointInterval and PointStart are part of plotOptions.series
your number of categories don't match with number of data points ,correct them
categories: ['Inbound', 'Outbound', 'InService']
I am in the process of moving from a built in graph library to HighStock.
I have to comply to crasy implementations. So at the end I got this configuration :
$(function() {
chart = new Highcharts.StockChart({
chart : {
renderTo : 'div_#divid#'
},
rangeSelector : {
selected : 0,
buttons: [{
type: 'day',
count: 7,
text: '7j'
}, {
type: 'day',
count: 15,
text: '15j'
}, {
type: 'day',
count: 30,
text: '30j'
}, {
type: 'all',
text: 'Tous'
}]
},
series : [{
type : 'column',
name : 'valeur',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});
Here is the fiddled version.
I don't get whats wrong with my data. (but I think I did correctly the conversion for the dates.)
[[1362355200000,672],[1362441600000,9764],[1362528000000,9839],[1362614400000,9906], [1362700800000,9973],[1362787200000,9906],[1362873600000,10592],[1362960000000,11236], [1363046400000,13233],[1363132800000,0],[1363219200000,0],[1363305600000,0],[1363392000000,0],[1363478400000,0],[1363564800000,0],[1363651200000,0],[1363737600000,0],[1363824000000,0],[1363910400000,0],[1363996800000,0],[1364083200000,0],[1364169600000,0],[1364256000000,0],[1364342400000,0],[1364428800000,0],[1364515200000,0],[1364601600000,0],[1364688000000,0],[1364770800000,0],[1364857200000,0],[1364943600000,0],[1365030000000,0],[1365116400000,0],[1365202800000,0],[1365289200000,0],[1365375600000,0],[1365462000000,0],[1365548400000,0],[1365634800000,0],[1365721200000,0],[1365807600000,0],[1365894000000,0],[1365980400000,0],[1366066800000,0],[1366153200000,0],[1366239600000,0],[1366326000000,0],[1366412400000,0],[1366498800000,0],[1366585200000,0],[1366671600000,0],[1366758000000,0],[1366844400000,0],[1366930800000,0],[1367017200000,0],[1367103600000,0],[1367190000000,0],[1367276400000,0],[1367362800000,0],[1367449200000,5490]]
Thanks for your help.
I'm not sure, the problem is that you can't see the chart? That's cause your data contains '
Check the jsFiddle: http://jsfiddle.net/SqZY2/1/
You have this:
data = '[[1362355200000,672],[1362441600000,9764],[1367103600000,0],[1367190000000,0],[1367276400000,0],[1367362800000,0],[1367449200000,5490]]';
Must be this:
data = [[1362355200000,672],[1362441600000,9764],[1362528000000,9839],[1362614400000,9906],[1367103600000,0],[1367190000000,0],[1367276400000,0],[1367362800000,0],[1367449200000,5490]];
hi my json object looks like this
[
{"name":"Tokyo","data":3.0},
{"name":"NewYork","data":2.0},
{"name":"Berlin","data":3.5},
{"name":"London","data":1.5}
]
How to populate the series points to make a pie chart using highcharts
Try this below code. This will parse all the values and create an array called dataArrayFinal .
var d = [{"name":"Tokyo","data":3.0},{"name":"NewYork","data":2.0}, {"name":"Berlin","data":3.5},{"name":"London","data":1.5}]
var name = Array();
var data = Array();
var dataArrayFinal = Array();
for(i=0;i<d.length;i++) {
name[i] = d[i].name;
data[i] = d[i].data;
}
for(j=0;j<name.length;j++) {
var temp = new Array(name[j],data[j]);
dataArrayFinal[j] = temp;
}
And your series stuff should look like below. i.e, you should pass the array dataArrayFinal like below.
series: [{
type: 'pie',
name: 'Browser share',
data: dataArrayFinal
}]
Actually the only difference between your data definition and the format that Highcharts requires, is that yours has a property called "data" where Highcharts expects "y". So you just need to loop over the data and set that property. See it live at http://jsfiddle.net/highcharts/uTyZk/.
// Original data
var data = [{
"name": "Tokyo",
"data": 3.0
}, {
"name": "NewYork",
"data": 2.0
}, {
"name": "Berlin",
"data": 3.5
}, {
"name": "London",
"data": 1.5
}];
// Highcharts requires the y option to be set
$.each(data, function (i, point) {
point.y = point.data;
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'pie'
},
series: [{
data: data
}]
});