Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Highcharts Change Bar Color Based on Value
- $(document).ready(function() {
- var options = {
- chart: {
- renderTo: 'container',
- defaultSeriesType: 'bar'
- },
- title: {
- text: 'Spiritual Gifts Results'
- },
- colors: [
- '#3BBEE3'
- ],
- xAxis: {
- categories: []
- },
- yAxis: {
- title: {
- text: 'Service'
- }
- },
- series: []
- };
- var data = document.getElementById("<%= hdn_Data.ClientID %>");
- // Split the lines
- if (data.value != "") {
- var lines = data.value.split('n');
- // Iterate over the lines and add categories or series
- $.each(lines, function(lineNo, line) {
- var items = line.split(',');
- // header line containes categories
- if (lineNo == 0) {
- $.each(items, function(itemNo, item) {
- if (itemNo > 0) options.xAxis.categories.push(item);
- });
- }
- // the rest of the lines contain data with their name in the first position
- else {
- var series = {
- data: []
- };
- $.each(items, function(itemNo, item) {
- if (itemNo == 0) {
- series.name = item;
- } else {
- series.data.push(parseFloat(item));
- }
- });
- options.series.push(series);
- }
- });
- // Create the chart
- var chart1 = new Highcharts.Chart(options);
- }
- });
- Categories,Administration,Evangelism,Mercy,Shepherding,Leadership,Wisdom,Teaching
- Total Points,11,5,4,4,3,2,1
- series.name = item;
- series.data.push(parseFloat(item));
- series.color: '#f6f6f6'
- $(document).ready(function() {
- var options = {
- chart: {
- renderTo: 'container',
- defaultSeriesType: 'bar'
- },
- title: {
- text: 'Spiritual Gifts Results'
- },
- colors: [
- '#3BBEE3'
- ],
- xAxis: {
- categories: []
- },
- yAxis: {
- title: {
- text: 'Service'
- }
- },
- series: []
- };
- var data = document.getElementById("hdn_Data");
- // Split the lines
- if (data.value != "") {
- var lines = data.value.split('n');
- // Iterate over the lines and add categories or series
- $.each(lines, function(lineNo, line) {
- var items = line.split(',');
- // header line containes categories
- if (lineNo == 0) {
- $.each(items, function(itemNo, item) {
- if (itemNo > 0) options.xAxis.categories.push(item);
- });
- }
- // the rest of the lines contain data with their name in the first position
- else {
- var series = {
- data: []
- };
- $.each(items, function(itemNo, item) {
- var data = {};
- if (itemNo == 0) {
- series.name = item;
- } else {
- data.y = parseFloat(item);
- if (itemNo <= 3) {
- data.color = 'Gray';
- }
- else {
- data.color = '#3BBEE3';
- }
- series.data.push(data);
- }
- });
- options.series.push(series);
- }
- });
- // Create the chart
- var chart1 = new Highcharts.Chart(options);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement