OpenLayers WebGLPointsLayer conditional symbol source - webgl

I work with the new feature from openLayers: https://openlayers.org/en/latest/examples/webgl-points-layer.html
and want to achieve to have some case transform operator like in the color array, but for the src string
thunderstorm: {
symbol: {
symbolType: "image",
src: `data:image/svg+xml;utf8,${icon(faThunderstorm, {
transform: {
size: 14,
},
attributes: {
stroke: "black",
"stroke-width": "30",
color: "white",
},
}).html[0]}`,
color: [
"case",
["==", ["get", "type"], "cloud-to-ground"],
"rgb(247, 37, 133)",
["==", ["get", "type"], "inter-cloud"],
"rgb(72, 12, 168)",
"rgb(255, 255, 255)", // fallback
],
size: [20, 20],
anchor: [0.5, 0.5],
rotateWithView: false,
},
},
I tried something like this, but it doesn't resolve the string:
thunderstorm: {
symbol: {
symbolType: "image",
src: [
"case",
["==", ["get", "type"], "cloud-to-ground"],
`data:image/svg+xml;utf8,${icon(faBolt, {
transform: {
size: 14,
},
attributes: {
stroke: "black",
"stroke-width": "30",
color: "white",
},
}).html[0]}`,
["==", ["get", "type"], "inter-cloud"],
`data:image/svg+xml;utf8,${icon(faThunderstorm, {
transform: {
size: 14,
},
attributes: {
stroke: "black",
"stroke-width": "30",
color: "white",
},
}).html[0]}`,
`data:image/svg+xml;utf8,${icon(faBolt, {
transform: {
size: 14,
},
attributes: {
stroke: "black",
"stroke-width": "30",
color: "white",
},
}).html[0]}`, // fallback
],
[...]
},
},
and will throw these WebGL errors:
WebGL: INVALID_VALUE: texImage2D: bad image data
[.WebGL-0x12b2a1000]RENDER WARNING: texture bound to texture unit 0 is not renderable. It might be non-power-of-2 or have incompatible texture filtering (maybe)?
Any idea how to implement the transform operation, for having to different kind of icons for one style (JSON)?
(I looked into this one: https://openlayers.org/en/latest/examples/icon-sprite-webgl.html
but don't know how to build the "A very simple sprite atlas is used in the form of a PNG file containing all icons on a grid.")

Related

Highcharts Boxplot - box with lower, upper quartile and median is not displaying when min and max are null of a category

navigate to below fiddle and find first category is not showing boxplot.
my expectation is that highcharts should show q1,q3 and median box.
is there a way to render boxplot without min and max?
https://jsfiddle.net/rammohanreddy201/ga20p14y/28/
Highcharts.chart('container', {
chart: {
type: 'boxplot'
},
title: {
text: 'Highcharts Box Plot Example'
},
legend: {
enabled: false
},
xAxis: {
categories: ['1', '2', '3', '4', '5'],
title: {
text: 'Experiment No.'
}
},
yAxis: {
title: {
text: 'Observations'
},
plotLines: [{
value: 932,
color: 'red',
width: 1,
label: {
text: 'Theoretical mean: 932',
align: 'center',
style: {
color: 'gray'
}
}
}]
},
series: [{
name: 'Observations',
data: [
[null, 801, 848, 895, null],
[733, 853, 939, 980, 1080],
[714, 762, 817, 870, 918],
[724, 802, 806, 871, 950],
[834, 836, 864, 882, 910]
],
tooltip: {
headerFormat: '<em>Experiment No {point.key}</em><br/>'
}
}, {
name: 'Outliers',
color: Highcharts.getOptions().colors[0],
type: 'scatter',
data: [ // x, y positions where 0 is the first category
[0, 644],
[4, 718],
[4, 951],
[4, 969]
],
marker: {
fillColor: 'white',
lineWidth: 1,
lineColor: Highcharts.getOptions().colors[0]
},
tooltip: {
pointFormat: 'Observation: {point.y}'
}
}]
});
The implemented logic for the boxplot series requires 6 or 5 values in the array or in the data config objects - x,low,q1,median,q3,high. More: https://api.highcharts.com/highcharts/series.boxplot.data and https://www.highcharts.com/docs/chart-and-series-types/box-plot-series
However, setting the low and high to the same value as q1 makes that their lines are invisible (are covered by the q1 line), so it could be a good workaround to your requirement. So the data config should look like this:
data: [
[801, 801, 848, 895, 801],
[733, 853, 939, 980, 1080],
[714, 762, 817, 870, 918],
[724, 802, 806, 871, 950],
[834, 836, 864, 882, 910]
],
Next it will be nice to hide those values in the tooltip. We can use the formatter callback to achieve it:
tooltip: {
formatter(tooltip) {
let point = this.point;
if (point.low === point.q1 || point.high === point.q1) {
point.low = null;
point.high = null;
}
return tooltip.defaultFormatter.call(this, tooltip);
}
},
Demo: https://jsfiddle.net/BlackLabel/rd4aLgne/
API: https://api.highcharts.com/highcharts/tooltip.formatter

Customize halo of a scatter chart so that the center is intransparently colored

This is what I mean by halo:
http://api.highcharts.com/highcharts/plotOptions.area.states.hover.halo
It seems that "fill", "fillColor" and "color" in or not in "attributes" does not do the job.
As you can see from this jsfiddle: jsfiddle.net/s7ff806c/1 The halos are hallow circles which one can see through. I would like the circle to be solid (i.e not be able to be see through).
I think intransparently colored means full opaque see here how to achieve
in each series give color: 'rgba(223, 83, 83, 1.0)', 1.0 means full opaque, in rgba format
series: [{
name: 'Female',
color: 'rgba(223, 83, 83, 1.0)',
data: [
[161.2, 51.6],....]
}, {
name: 'Male',
color: 'rgba(119, 152, 191, 1.0)',
data: [
[174.0, 65.6],...]}
]
Fiddle link with Customize halo
Update
halo opacity can be adjusted see Opacity from highcharts docs
Fiddle Demo with Opacity adjusted to full
plotOptions: {
series: {
states: {
hover: {
halo: {
size: 9,
opacity:1,
attributes: {
fill: Highcharts.getOptions().colors[2],
'stroke-width': 2,
stroke: Highcharts.getOptions().colors[1]
}
}
}
}
}
},
Update ->set the opacity of stroke independently of the opacity of the fill
give 'stroke-opacity': .5, inside attribute
Fiddle link
plotOptions: {
series: {
states: {
hover: {
halo: {
size: 9,
opacity: 1,
attributes: {
fill: Highcharts.getOptions().colors[2],
'stroke-width': 5,
'stroke-opacity': .5,
stroke: Highcharts.getOptions().colors[1]
}
}
}
}
}
},

Highchart - show heatmap legend by category

I would like to use the heatmap to generate a status overview of a machine for a given day. The states show up as I want but I have a question about the legend. Can I show a 'traditional' legend that shows the states and their colors.
Highchart fiddle: http://jsfiddle.net/p7v2f117/7/
$(function () {
$('#container').highcharts({
chart: {
type: 'heatmap',
marginTop: 40,
marginBottom: 40
},
title: {
text: 'HIGHCHART - Machine State on 1/7/2015'
},
xAxis: { // minute interval
categories: ['00', '15', '30', '45']
},
yAxis: { // hour
categories: ['20:00', '21:00'],
title: null
},
colorAxis: {
min: 0,
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
},
legend: {
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
y: 25,
symbolHeight: 320
},
tooltip: {
formatter: function () {
return '<b>' + this.series.yAxis.categories[this.point.y] + ' (' + this.series.xAxis.categories[this.point.x] + 'min)</b>' + '<br>state: <b>' + this.point.value + '</b><br>More details go here'
}
},
series: [{
name: 'Machine State',
borderColor: '#000000',
borderWidth: 1,
data: [{
x: 0,
y: 0,
value: 'RUN',
color: '#00FF00'
}, {
x: 1,
y: 0,
value: 'RUN',
color: '#00FF00'
}, {
x: 2,
y: 0,
value: 'RUN',
color: '#00FF00'
}, {
x: 3,
y: 0,
value: 'IDLE',
color: '#00FFFF'
}, {
x: 0,
y: 1,
value: 'IDLE',
color: '#00FFFF'
}, {
x: 1,
y: 1,
value: 'DOWN',
color: '#FF0000'
}, {
x: 2,
y: 1,
value: 'PM',
color: '#C0C0C0'
}, {
x: 3,
y: 1,
value: 'Marathon',
color: '#FFCCFF'
}, ],
dataLabels: {
enabled: false
}
}]
});
});
I am trying to basically get the same behavior that I can get in Fusion charts, where the color is automatically driven by the status field (text) and it shows the categories. The fact that they are clickable is nice but not necessary.
Fusionchart fiddle: http://jsfiddle.net/c8V2F/25/
FusionCharts.ready(function () {
var chart = new FusionCharts({
type: 'heatmap',
renderAt: 'chartdiv1',
width: '600',
height: '400',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "FUSIONCHART - Machine State on 1/7/2015",
"plottooltext": "<div id='nameDiv' style='font-size: 12px; border-bottom: 1px dashed #666666; font-weight:bold; padding-bottom: 3px; margin-bottom: 5px; display: inline-block; color: #888888;'>$tlLabel</div>{br}State: <b>$value</b>{br}details can go here",
"mapbycategory": "1",
//Cosmetics
"showXaxisLabels": "1",
"showYaxisLabels": "1",
"baseFontColor": "#333333",
"baseFont": "Helvetica Neue,Arial",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"subcaptionFontBold": "0",
"showBorder": "0",
"bgColor": "#ffffff",
"showShadow": "0",
"usePlotGradientColor": "0",
"canvasBgColor": "#ffffff",
"canvasBorderAlpha": "0",
"legendBgAlpha": "0",
"legendBorderAlpha": "0",
"legendShadow": "0",
"legendItemFontSize": "10",
"legendItemFontColor": "#666666",
"toolTipColor": "#ffffff",
"toolTipBorderThickness": "0",
"toolTipBgColor": "#000000",
"toolTipBgAlpha": "80",
"toolTipBorderRadius": "2",
"toolTipPadding": "5"
},
"dataset": [{
"data": [{
"rowid": "20:00",
"columnid": "00",
"categoryid": "RUN",
"displayvalue": ""
}, {
"rowid": "20:00",
"columnid": "15",
"categoryid": "RUN"
}, {
"rowid": "20:00",
"columnid": "30",
"categoryid": "RUN"
}, {
"rowid": "20:00",
"columnid": "45",
"categoryid": "IDLE"
}, {
"rowid": "21:00",
"columnid": "00",
"categoryid": "IDLE"
}, {
"rowid": "21:00",
"columnid": "15",
"categoryid": "DOWN"
}, {
"rowid": "21:00",
"columnid": "30",
"categoryid": "PM"
}, {
"rowid": "21:00",
"columnid": "45",
"categoryid": "Marathon"
}, ]
}],
"colorrange": {
"gradient": "0",
"color": [{
"label": "RUN",
"code": "00FF00"
}, {
"label": "ASSIST",
"code": "FFFF00"
}, {
"label": "DOWN",
"code": "FF0000"
}, {
"label": "IDLE",
"code": "00FFFF"
}, {
"label": "PM",
"code": "C0C0C0"
}, {
"label": "ENG",
"code": "00B0F0"
}, {
"label": "Marathon",
"code": "FFCCFF"
}
]
}
}
});
chart.render();
});
Is there a simple way to not show the legend at all?
I can certainly convert the states back to a number if that makes more sense.
--Nico
You need to cover default parameter for highmaps:
var H = Highcharts;
H.seriesTypes.heatmap.prototype.axisTypes = ['xAxis', 'yAxis'],
H.seriesTypes.heatmap.prototype.optionalAxis = null;
Example: http://jsfiddle.net/ww6Lbnc5/

Periodic events with duration

I need to show on graph duration of periodic events. For example user with ID 1 is calling to user with ID 2 at 10:00 AM and they are speaking 5 minutes. Then he is calling him again at 2:00PM and they are speaking 2 minutes. So this events are happening periodically and I need to show them on the graph as horizontal bars. They should look something like that: User 1: [ 5min ][ 2min ][ ... ][ ... ]
I've almost achieved what I want except that I can't find the way to show time at X axis. The X axis should show time with 30 minutes interval.
Here is my configuration:
title: null,
chart: {
type: 'bar',
backgroundColor: '#F9F9F9',
plotBackgroundColor: '#F9F9F9',
borderColor: '#F9F9F9',
borderWidth: 1,
animation: 0
},
legend: {
enabled: false
},
series: [
{ data: [{ y:1, color: 'red'} ] },
{ data: [{ y:1, color: 'blue'} ] },
{ data: [{ y:1, color: 'transparent'} ] },
{ data: [{ y:1, color: 'red'} ] },
{ data: [{ y:1, color: 'transparent'} ] },
{ data: [{ y:1, color: 'red'} ] },
{ data: [{ y:1, color: 'blue'} ] },
{ data: [{ y:1, color: 'red'} ] },
{ data: [{ y:1, color: 'transparent'} ] },
{ data: [{ y:1, color: 'red'} ] },
{ data: [{ y:1, color: 'transparent'} ] },
{ data: [{ y:1, color: 'red'} ] }
],
xAxis: {
categories: ['User 1']
},
yAxis: {
allowDecimals: false,
min: 0,
type: '',
title: {
text: 'Time'
},
stackLabels: {
enabled: false
}
},
plotOptions: {
bar: {
stacking: 'normal',
dataLabels: {
enabled: false
},
borderWidth: 0
}
Here is demonstration of concept: http://jsfiddle.net/dimitrykislichenko/SjdR5/
I think you should be using columnrange series with axis type: 'datetime'. See: http://jsfiddle.net/SjdR5/2/
Note requires change in series object:
series: [{
data: [{
x: 0,
low: Date.UTC(2013, 1, 1, 10, 53),
high: Date.UTC(2013, 1, 1, 10, 59),
color: 'red'
},{
x: 0,
low: Date.UTC(2013, 1, 1, 12, 12),
high: Date.UTC(2013, 1, 1, 12, 17),
color: 'red'
},{
x: 0,
low: Date.UTC(2013, 1, 1, 16, 35),
high: Date.UTC(2013, 1, 1, 16, 55),
color: 'red'
}]
}],
x:0 -it's category index ( 0 = User 1 )
low and high is like from and to for time
color is just color of bar ;)

how do you draw two yAxis chart in highcharts

I need to build a highchart with 2 yAxis, one on the left (primary) and one on the right(secondar). I was not able to make this work. Any ideas what I am doing wrong here or missing?
here is the jsfiddle: http://jsfiddle.net/gsaray101/KX4AS/2/
I am using the example from the highcharts site as this:
yAxis: [{ // Primary yAxis
labels: {
format: '{value}ms',
style: {
color: '#89A54E'
}
},
title: {
text: 'response time',
style: {
color: '#89A54E'
}
}
}, { // Secondary yAxis
title: {
text: 'volume',
style: {
color: '#4572A7'
}
},
labels: {
format: '{value}',
style: {
color: '#4572A7'
}
},
opposite: true
}],
Axis are 0 based. So you need (http://jsfiddle.net/zEBSh/)
var data = [{
"name": "1",
"yAxis": 0,
"data": [
[1374019440000, 25],
[1374056640000, 43],
[1374056880000, 49]
]
}, {
"name": "2",
"yAxis":1,
"data": [
[1374019440000, 33],
[1374019740000, 42],

Resources