Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
How do I add labels to top of series
posted

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"]
});


});

 

Parents
No Data
Reply
  • 16310
    Offline posted

    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.

Children