I am attempting to create a stacked column chart with an unequal number of "sub-groups".
For example, given the following data:
Category#1 : [SubCategory1: 2, SubCategory2: 4, SubCategory3: 3],
Category#2 : [SubCategory4: 5, SubCategory5: 3],
Category#3 : [SubCategory6: 4, SubCategory7: 3, SubCategory8: 3, SubCategory9: 5]
...
I want to create a column chart where the first column is comprised of three stacked segments and has a total height of 9,
the second column has a stack of two segments with total height of 8,
and the third column has four segments with a total height of 15.
After having worked for a little while with the HighCharts API and generally getting good results, I believe what I want to accomplish is probably doable and I am likely just missing some combination of options or structuring my data incorrectly. Does anyone know what I need to do in order to create such a chart?
Two of the ways you can solve this are:
Giving each point in your series a specific x index that relates to the category index.
Example of a series (JSFiddle):
series: [{
name: 'John',
data: [{x:0,y:5},{x:3,y:7},{x:4,y:2}]
}
Here we skip the 2nd and 3rd category (index 1 and 2), so they will not have a value.
Using null values in your series to skip having it appear in a category.
Example of a series (JSFiddle):
series: [{
name: 'John',
data: [5, null, null, 7, 2]
}
This series also skips the 2nd and 3rd category, like the one above.
Your solution choice may rely on how many null values you would end up with. If it is only a few, then that might be the most lightweight solution. If it is a lot, then using Point objects with x values may be more suitable and cleaner.
Related
I am using Javascript Highcharts, and am trying to make a chart that contains column and line series. I have 3 column series, and I want 2 of them to stack. I want the 3rd one to stay by itself. Is this possible? I tried putting them on different y axes, but they still all stack.
Thanks in advance.
After tons more searching, I found the answer in an unexpected place.
You can use the "stack:" series option to group things to stack together.
{ name: 'series1', data: 'data1', stack: 'stack12' },
{ name: 'series2', data: 'data2', stack: 'stack12' },
{ name: 'series3', data: 'data3', stack: 'stack3' }
In this example, series1 and series2 would stack, while series 3 would stay separate.
I have categories that are grouped and sorted by a sort order 1-7.
So group 1 has 3 categories in it.
So the first 3 categories belong to group one, next 4 belongs to group 2 and so on.
Is it possible to apply plot bands based on the categories?
Thanks
JS fiddle
https://jsfiddle.net/juliangurung/v73dcjs0/
Im not sure how to add plotbands which looks at my categories
xAxis: [{
plotBands: [{
color: 'orange', // Color value
from: 3, // Start of the plot band
to: 4 // End of the plot band
}],
}]
Sure, you can simply use plotBands. Take a look at examples posted below.
API Reference:
http://api.highcharts.com/highcharts/xAxis.plotBands
Examples:
http://jsfiddle.net/d9pn98jL/
https://jsfiddle.net/kryeo92u/
I'm trying to use the type:'datetime' for my x-axis, and am getting a graph on a vertical line and dates going all the way back to 1970. Is there any way to circumvent this error?
Here's my use case: I'm tracking my page performance at regular intervals. if the server goes down for any reason or the metric was unable to be tracked, then we end up with a gap in the line. the requirement is to show this as datetime, but if i populate the series with any null datapoints, Highcharts throws an error 15.
series: [{
data: [
{x:1389254400000,y:10},
{x:1389554400000,y:9},
null,
{x:1389854400000,y:12}]
}]
Here's the fiddle: http://jsfiddle.net/agjZB/23/
If i remove the null datapoint, everything works fine. Thanks for the extra eyes!
You have to make the NULL point the same format as your other points.
Or, don't include it. If you have no data for timestamp x why include it or if you have no data at all why include it?
Example of option 1:
series: [{
data: [
{x:1389254400000,y:10},
{x:1389554400000,y:9},
{x:1389554400000,y:null},
{x:1389854400000,y:12}]
}]
For line chart you shouldn't use points with the same x value, becasue a few feateaures like tooltip will not work correct. You need to set scatter type and lineWidth as 2.
i got a pool of data with exact same value in a scatter plot with HighCharts as in :
http://jsfiddle.net/DvbHa/1/
i want to be able to display them in tooltip when i go over it to be able to click them individualy
is something like that possible?
Thx all
Code:
$(function () {
$('#container').highcharts({
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: ''
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x}, {point.y}'
},
series: [{
data: [[10, 5],
[15, 6],
[10, 5],
[15, 7],
[13, 6],
[13, 6]]
}],
});
});
One option that is implemented in most major data visualization software packages is jittering - a function that adds small amounts of random noise to the data points so that each data point is slightly offset from it's actual data values.
This is a trade off with precision, of course, but those are the kinds of choices that are to be made when displaying data.
There is not a jittering option in Highcharts, but with a little digging you should be able to find or create a solution.
I have had some moderate success doing this on the server side before sending the data to the chart.
First check for any duplicates. If there aren't any, go no further.
If there are, create an array of any duplicate points for any point that has duplicates.
Loop through each array and add random decimal values to the x and y values of each point.
To add click events, use plotOptions.scatter.events.click.
However, I don't know what is the purpose of displaying the same points in the same place with the same value.
Increase size of the plot by using marker radius and you can differentiate the plots at same location.
marker: {
radius: 13
}
http://api.highcharts.com/highcharts/plotOptions.spline.marker.radius
See this one helps or not
Since 7.0.2, HighCharts now does officially support jittering for scatter plots.
See here: https://api.highcharts.com/highcharts/plotOptions.scatter.jitter
I am using highchart, trying to make a chart that shows high and low values for the number of people occupying various rooms. So I have a data like this:
[[roomName, low, high], [roomName, low, high] ...]
For example:
["XRay", 12, 45], ["Waiting Room", 8, 22], ["Admitting", 22, 56]]
What I want to have happen is for the x Axis to use the room names as the values on the category axis. But I can't see to get this to happen. It uses them as the names of the points instead.
If I am just doing a column chart, I can set x and y properties for the points:
[x:"XRay", y:12], [x:"Waiting Room", y:8], [x:"Admitting", y:56]]
But I don't know how I can do this with column ranges.
I can of course manually parse the data and set the categories of the xAxis myself, but I am wondering if there is a better way.
Thanks!
It could be done in two ways, as suggested categories, or using label formatter, both are here: http://jsbin.com/oyudan/17/edit
Formats:
[ {x: 'string' } ... ]
are not proper.