Hello,How can I add labels to the top of series on a column chart?
I already saw your example solution here, but it did not work:http://ko.infragistics.com/community/forums/t/93243.aspx
When I copy / paste it, I get an error in the console. Perhaps it is for an older version of the charting library?The example solution seems to apply a data source to each series individually.
The code I wrote below follows examples on your site, using valueMemberPath.
Here is the code I am working with:
HTML:
<div class="charts-container"> <div class="row"> <div class="col-sm-3"> <div id="legend"></div> <div id="chart"></div> </div></div>
BLOCKED SCRIPT
$(function () {
var thedata = [{"Year": 2012,"Minority": 10,"Female": 50,},{"Year": 2013,"Minority": 20,"Female": 33.3,},{"Year": 2014,"Minority": 30,"Female": 33.3,}];
$("#chart").igDataChart({width: "100%",height: "400px",dataSource: thedata,axes: [{name: "YearAxis",type: "categoryX",title: "",label: "Year"},{name: "PercentAxis",type: "numericY",minimumValue: 0,title: ""}],series: [{name: "2012Minority",title: "Minority",type: "column",xAxis: "YearAxis",yAxis: "PercentAxis",valueMemberPath: "Minority",legend: { element: "legend" }},{name: "2012Female",title: "Female",type: "column",xAxis: "YearAxis",yAxis: "PercentAxis",valueMemberPath: "Female",legend: { element: "legend" }}],brushes: ["#002361", "#ff0000"]});
});
Hello Thomas,
Thank you for your patience.
You receive that error because you try to access variable from the current object named "value". Please review in detail the forum post you mentioned and the code in it.
Here is your working sample - http://jsfiddle.net/d1tswq0f/4/.
Please let me know if I could be of further assistance.
Hello,
Thanks for your reply.
I've created a fiddle that shows my attempt to apply the custom marker code that I picked up from your example fiddle.
http://jsfiddle.net/d1tswq0f/3/
Yields: (in the console)
Uncaught TypeError: Cannot read property 'value' of nullUncaught TypeError: Cannot read property 'toString' of undefined
Can you tell me whats wrong here?
Thanks! :)
Hi,
Your code seems fine, so I cannot guess what happens. Please share the error you receive. Also pay attention that the sample in jsfiddle uses custom markers to add labels above the bar series - I don't see using custom markers in the code you shared - therefore you will not be getting those labels.