How do I have text display within the inside of a stacked bar graph in highcharts - charts

How do I have insert text within the stacked sections of a highcharts stacked bar graph ( https://www.highcharts.com/demo/bar-stacked ).
My graph will really only have two columns, and they'll have the y-axis reversed and displayed as so: https://jsfiddle.net/ogjz9ra0/
Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
categories: ['Bananas']
},
colors: ['#1b98ee', '#1366a6'],
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
},
legend: {
reversed: true,
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: 'John',
data: [4726.78]
}, {
name: 'Brian',
data: [4250.00],
}]
});
What I'd like is to be able to inject text into each of the columns.
https://drive.google.com/file/d/1CDttfeB9mqI5r9voYalsLtEeH0OSs3Ey/view?usp=sharing
I'm still relatively new to HighCharts, so any help would be appreciated.
Thank you all so much again!
I did some googling, and most of the results talk about having the text render inside the bar for non-stacked bar charts. Note that the placing for the problem I'm trying to solve is in the center.

You can use datalabels documentation like this :
plotOptions: {
series: {
stacking: 'normal',
dataLabels: {
enabled: true,
formatter: function() {
// console.log(this) // uncomment this line to see all params available
return 'custom text here'
}
}
}
},
Fiddle

Related

How add labelline to Bubble Chart in EChart

Because some date are overlap, I want to add labelline in each Bubble, How can I do that? Thks
You can add the label option to your series object:
series: [{
type: 'scatter',
symbolSize: function (data) {
...
},
emphasis: {
...
},
label: {
show: true,
position: 'top'
},
itemStyle: {
...
},
...
}]
all the customizations available for this label are here (position, format, etc):
https://echarts.apache.org/en/option.html#series-scatter.label

How to get newline after the title in echarts line chart?

I would like to add new line after the title, can anyone help me how to i do that?
Here i'm setting options like,
option ={
title: 'test content regarding the line chart'
}
Due to title is long, it is coming on top of legends
tried like,
option ={
title: 'test content regarding the line chart \n'
}
won't workout...
Thanks,
You did it right. Just use the '\n' to add another line and you can use the eChart editor online to test it.
Pay attention on the subtext position when you change the title inserting or removing the new line at the end of the title.
https://ecomfe.github.io/echarts-examples/public/editor.html
You can use this example:
option = {
title: {
text: ' Inserting a break on title \n and another break here \n',
subtext: 'We also have the subtext'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: ['Production']
},
grid: {
containLabel: true
},
xAxis: {
type: 'value',
data: ['abc','xyz'],
boundaryGap: [0, 0.01]
},
yAxis: {
type: 'category',
data: ['Month 1','Month 2']
},
series: {
name: 'Production',
type: 'bar',
data: [70,80],
isBiggerOrEqual: true
}};

convert kendo chart type

I have a kendo's scatterline chart on my HTML page.
I have generated it as following.
objchart = $("#chart").kendoChart({
dataSource: {
data: Chartdata
},
background: mainbackground,
series: [{
type: "scatterLine",
xField: "date"
}],
xAxis: {
title: {
text: "Date"
},
min: min_date,
max: max_date,
name: "Date",
template: "#= kendo.toString(value,'MM/dd/yyyy HH:mm:ss')#",
type: "date",
baseUnit: "seconds",
background: xaxisbackcolor,
},
yAxis: {
title: {
text: "Closing stock prices"
},
min: min_close,
max: max_symbol,
background: yaxisbackcolor,
},
title: {
text: "Close and Volume Date-wise"
},
transitions: false,
zoom: setRange,
dragStart: onDragStart,
drag: onDrag,
dragEnd: onDragEnd
}).data("kendoChart");
Following is my datasource (calling from web api)
[{"date":"9/14/2015 1:20:00 AM","close":6.0,"volume":18.0,"open":58.0,"high":42.0,"low":60.0,"symbol":79.0}]
Now, I need to change the type of the chart from scatter line chart into others like series and bar chart.
when I change it as objchart.options.series[0].type = "column", it does not give any output.
It only leaves the blank chart behind.
What is the correct method to change or cast the chart from any type to any other type?
Thank you

redraw funnel chart in highchart when a segment is removed?

Is there a way funnel chart will redraw like pie chart does, when a segment is removed?
Similar to this question redraw pie chart in highchart
http://jsfiddle.net/2Me2z/
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'pie'
},
plotOptions: {
pie: {
showInLegend: true
}
},
legend: {
enabled: true
},
series: [{
data: [20, 30, 30, 20]
}]
});
// button handler
$('#button').click(function() {
var series = chart.series[0];
if (series.data.length) {
chart.series[0].data[0].remove();
}
});
});
So click on any slice in legend will cause the chart to redraw and the remaining slices will take up 100%
Wonder if the same thing can be done for a funnel chart
http://jsfiddle.net/YUL5c/2/
$(function () {
var chart;
$(document).ready(function () {
// Build the chart
$('#container').highcharts({
chart: {
type: 'funnel',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Browser market shares at a specific website, 2010'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
series: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.01]
]
}]
});
});
});
Currently the segment just disaapear. But the chart does not redraw
Unfortunately this animation is not supported, but I advice to post your request on the uservoice website
point.visible flag is ignored in funnel code.
If adding the check back to the drawing logic things just work magically. Even for the animation.
Not sure if it is a bug or ignored by intention

Kendo ui chart hide circle for data points

I'm not able to hide rounded circle for the line chart in Kendo ui. I do want to show tooltip value but want to hide circle.
below example is from demo site: http://demos.kendoui.com/dataviz/line-charts/index.html
Even, I don't know what do they call it so that I can find in the document here: http://docs.kendoui.com/api/dataviz/chart
According to the docs, you can set series.markers.visible to false:
http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-series.markers.visible
Additionally you can change their size and shape.
Please try with the below code snippet. Let me know if any concern.
<style>
#chart circle {
display: none !important;
}
</style>
<script>
function createChart() {
$("#chart").kendoChart({
title: {
text: "Gross domestic product growth /GDP annual %/"
},
legend: {
position: "bottom"
},
chartArea: {
background: ""
},
seriesDefaults: {
type: "line"
},
series: [{
name: "India",
data: [3.907, 7.943, 7.848, 9.284, 9.263, 9.801, 3.890, 8.238, 9.552, 6.855]
}, {
name: "World",
data: [1.988, 2.733, 3.994, 3.464, 4.001, 3.939, 1.333, -2.245, 4.339, 2.727]
}, {
name: "Russian Federation",
data: [4.743, 7.295, 7.175, 6.376, 8.153, 8.535, 5.247, -7.832, 4.3, 4.3]
}, {
name: "Haiti",
data: [-0.253, 0.362, -3.519, 1.799, 2.252, 3.343, 0.843, 2.877, -5.416, 5.590]
}],
valueAxis: {
labels: {
format: "{0}%"
},
line: {
visible: false
},
axisCrossingValue: -10
},
categoryAxis: {
categories: [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011],
majorGridLines: {
visible: false
}
},
tooltip: {
visible: false
}
});
}
$(document).ready(createChart);
</script>