Specify xAxis values with columnRange chart in Highchart - highcharts

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.

Related

HighStock chart from sensor data

I'm logging sensor data into a SQL table that looks like this
Picture of the table for clarity
I'm processing the data intro arrays like this
$value1 = json_encode(array_reverse(array_column($sensor_data, 'value1')), JSON_NUMERIC_CHECK);
I'm processing datetime like this
$reading_time = json_encode(array_reverse($readings_time), JSON_NUMERIC_CHECK);
I managed to graph the data into a regular highcharts line graph. And for xAxis/time I used
xAxis: {
type: 'datetime',
categories: reading_time },
I want to graph the data using HighStocks so I'm able to use the navigator etc.
I can't find a way to pass the $reading_time to the x-axis. Do I need to format in a specific way?
Any sample code will be appreciated.
You can not use datetime and category axis type at the same time. Moreover, you can not use categories for Highstock at all. You should provide the date values as timestamps in miliseconds for x data property, for example:
data: [
// x, y
[1584014486654, 1],
[1584014496957, 2],
[1584014502349, 8]
]
API Reference: https://api.highcharts.com/highstock/series.line.data
Live example: http://jsfiddle.net/BlackLabel/6m4e8x0y/4904/

Stacked Column Chart With Unequal SubGroups in HighCharts.js

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.

HighChart xAxis and data discrepancy

There is some xAxis and data discrepancy, for example the second curve I need to be pictured as 2014-03 and 2014-04., but it drawn 2013-11; 2013-12
Is there exist some method where HighChart gets data in pairs, because in this case I have folowing json: [{"name":"xAxis","data":["2013-11","2013-12","2014-01","2014-02","2014-03","2014-04"]},{"name":"FIRSTname"","data":[81568256,93170615,92267597,97838553,103930539,103268030]},{"name":"SECONDname"","data":[20705697,23387653]}]
And I don't know how to inform HighChart "Hey, buddy, plz draw this curve from '2014-03' to '2014-04' for example.
Or something like "data": ['not draw this point', '1234', 'not draw this point', '1234']
So in this case he can easily understand that '1234' is for '2013-12', because it goes second.
Thanks
In the second serie data, points require to be pairs [x,y] instaed of y value. As a result use it: {"name":"SECONDname"","data":[[4,20705697],[5,23387653]]}]
Use null for data you don't want the chart to show
data: [null, 1234, null, 1234]
Here's an example: http://jsfiddle.net/ks22pgja/

Is it possible to use null datapoints with a datetime x-axis?

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.

Is there a SUMMAX or a "No Greater Than" like function in Google Spreadsheets

I have some data that needs to be summed but I would like to set the maximum value at 20, so sum the values but the greatest number that would be returned is 20.
For example, let's say I have three columns labeled A, B, and C. If in row one, the values are 5, 5, 5, the sum should be 15. But if they are 10, 10, 10, I would like the "sum" to show 20 instead of 30.
I have been playing around the the GT() function, but I would not like to create a new column just for comparisons. I would like it all to be in one cell. What would be a simple way of doing this?
=MIN(20, SUM(A1:C1))
maybe? That's what I'd use in Excel...

Resources