Is there a possibility to plot the errorbars in highcharts behind the actual lines/datapoints?
I am usually plotting the data and the errorbars with a for loop, therefore it would be convenient to set an attribute for the errorbars.
series: [
{% for key in dataset %}
{
name: '{{key}}',
data : {{ dataset[key].data}}
},
{
name: ' error',
type: 'errorbar',
data : {{ dataset[key].error}}
},
{% endfor %}
],
This can be controlled by the zIndex, like this:
series: [
{% for key in dataset %}
{
name: '{{key}}',
data : {{ dataset[key].data}},
zIndex: 2
},
{
name: ' error',
type: 'errorbar',
data : {{ dataset[key].error}},
zIndex: 1
},
{% endfor %}
]
API on series.zIndex: https://api.highcharts.com/highcharts/series.errorbar.zIndex
Define the visual z index of the series.
Defaults to undefined.
Working example: http://jsfiddle.net/ewolden/vrdmdzmz/1/
Related
I'd like to show two sets of Venn diagrams inside a single chart. So I have the following code for sets A and B:
Highcharts.chart('container', {
series: [{
type: 'venn',
data: [{
sets: ['A1'],
value: 188956
}, {
sets: ['A2'],
value: 211267
}, {
sets: ['A1', 'A2'],
value: 23085,
name: "overlap"
}, {
sets: ['B1'],
value: 10880
}, {
sets: ['B2'],
value: 10880
}, {
sets: ['B1', 'B2'],
value: 6389,
name: "overlap"
}]
}],
title: {
text: 'Sets A and B'
}
});
What's really nice about showing everything together is that the four circles are sized proportionately to each other. The problem is how they're laid out. I'd want to show set B on the right side of A with some spacing between them. I also want set B to be laid out horizontally like A is.
Is this doable and if so how?
Thanks!
Alvaro
That is not possible in one chart, but you can create multiple charts:
Highcharts.chart('container', {
...,
series: [{
type: 'venn',
data: [...]
}]
});
Highcharts.chart('container2', {
...,
series: [{
type: 'venn',
data: [...]
}]
});
Live demo: https://jsfiddle.net/BlackLabel/xy5dfq4s/
Docs: https://www.highcharts.com/docs/chart-and-series-types/venn-series
I'm using HighCharts, I have this array,
I would like to create a chart like this:
As I know, the format of series is like this:
series:[{
name: 'Production',
data: [0.074, 0.040,0.034,0.036,0.068]
}, {
name: 'Reprise',
data: [0.024,0.022,0.029, 0.055, 0.052]
}]
with categories array:
['Mario', 'Andre', 'Jean Jacques', 'Fidy', 'Judith']
How could I do if I want to paste each value of column Volumes to each Production Stacked Bar value like the chart above ?
Thanks!
you can see an example here: http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/column-stacked/
series: [{
name: 'Volume',
data: [1, 0.16, 0.46, 0.37, 0.24]
}, {
name: 'Reprise',
data: [0.024, 0.0.....]
}, {
name: 'Production',
data: [....]
}]
Later edit: to display volume as data label you can use the formatter function:
column: {
stacking: 'normal',
dataLabels: {
formatter: function () {
return this.x;//you can have a little logic here if (thix.x == 'Production) return myVariable[y];myVariable will contains values from volume or something similar
}
}
}
Define volume in your data array:
data: [{y:0.074,volume:1}, {y:0.040,volume:0.15}]
And use formatter in datalabels options to get custom value:
formatter: function () {
return this.point.volume + ' km';
}
jsfiddle
I have a ui grid that contains a directive, this directive has an isolated scope and changes it's template basing on some logic.
The problem is that, when sorting (and also when PAGING), the 'logic' of the directive seems to not be correctly "re-evaluated".
In the specific example, the rightmost column should only see some "11" while if you try to sort by id (or the other fields) you'll see some spurios '0' appearing.
this is the ui:
<div ng-app="myapp">
<div ng-controller="myctrl">
<div ui-grid="gridOptions" ng-style="gridStyle"></div>
</div>
</div>
this is the js:
var myapp = angular.module('myapp', ["ngRoute", "ui.grid"])
.controller('myctrl', function($scope) {
$scope.gridOptions = {
data: [{
id: 1,
name: "Max",
other: "pippo",
number: 1
}, {
id: 2,
name: "Adam",
other: "pluto",
number: 0
}, {
id: 3,
name: "Betty",
other: "paperino",
number: 0
}, {
id: 4,
name: "Sara",
other: "fava",
number: 1
}, {
id: 5,
name: "Favonio",
other: "favona",
number: 1
}],
columnDefs: [{
field: "id",
displayName: "ID"
}, {
field: "name",
displayName: "Name"
}, {
field: "other",
displayName: "Other"
}, {
field: "number",
cellTemplate: '<div class="ui-grid-cell-contents"><mydir data="row.entity"></mydir></div>'
}]
};
}).directive("mydir", function() {
return {
restrict: 'E',
scope: {
data: "=",
},
template: '<div><label ng-if="data.number==1">{{set}}</label></div>',
link: function(scope, iElement, iAttrs) {
scope.set = -1;
if (scope.data.number == 0) {
scope.set = 00;
} else {
scope.set = 11;
}
}
}
});
and here's a fiddle:
https://jsfiddle.net/27yrut4n/
Any hint?
In the end it's a known bug:
https://github.com/angular-ui/ui-grid/issues/4869
And I solved using watch like it's said here:
Directive rendered via UI-Grid cellTemplate rendering incorrectly
I have json
{
"_total": 824,
"_links": "self",
"top": [
{
"viewers": 80896,
"channels": 1177,
"game": {
"name": "League of Legends",
"_id": 21779,
}
},
{
"viewers": 31211,
"channels": 232,
"game": {
"name": "Dota 2",
"_id": 29595,
}
}
]
}
how best displayed "top" list? I try:
Tuple = jsx:decode(unicode:characters_to_binary(Json)),
[_, _, Top] = Tuple,
Games = element(2, Top);
but how using this in template?
{% for v in games %}
{{ v.viewers }}<br><br>
{{ v.channel }}<br><br>
{{ v.game.name }}<br><br>
{% endfor %}
not work, and then show {{ games.game.name }} ?
The code you did is fine, it just need a few updates, you shouldn't pass Games to the template, instead you should use top as the key, as an example, build a rebar file like:
%rebar.config
{deps, [
{erlydtl, ".*", {git, "git#github.com:erlydtl/erlydtl.git", "HEAD"}},
{jsx, ".*", {git, "git#github.com:talentdeficit/jsx.git", "HEAD"}}
]}.
then run:
rebar get-deps
rebar compile
Now define a template with the suggested update, named template.dtl:
{% for v in top %}
{{ v.viewers }}<br><br>
{{ v.channels }}<br><br>
{{ v.game.name }}<br><br>
{% endfor %}
Start an erlang shell:
erl -pa ./deps/erlydtl/ebin/ -pa ./deps/merl/ebin/ -pa ./deps/jsx/ebin/
and execute the commands which should display the template as expected
Json = "{
\"_total\": 824,
\"_links\": \"self\",
\"top\": [
{
\"viewers\": 80896,
\"channels\": 1177,
\"game\": {
\"name\": \"League of Legends\",
\"_id\": 21779,
}
},
{
\"viewers\": 31211,
\"channels\": 232,
\"game\": {
\"name\": \"Dota 2\",
\"_id\": 29595,
}
}
]
}".
Tuple = jsx:decode(unicode:characters_to_binary(Json)).
erlydtl:compile("./template.dtl", test).
test:render(Tuple).
which gives the expecte output
{ok,[[[<<"\n ">>,"80896",<<"<br><br>\n ">>,"1177",
<<"<br><br>\n\t">>,<<"League of Legends">>,<<"<br><br>\n">>],
[<<"\n ">>,"31211",<<"<br><br>\n ">>,"232",
<<"<br><br>\n\t">>,<<"Dota 2">>,<<"<br><br>\n">>]],
<<"\n">>]}
in few words, in your template, replace games with top and pass Tuple to the template
I need to be able take a list of objects in liquid and display them on the page in a specific format.
If I have an array of objects (pages), I need to be able to print them in the following way:
list category names (page.category.name)
list each subcategory name with a list of pages under each subcategory name (page.subcategory.name and page.title)
Typically in ruby I would simply group the pages but I can't do that in liquid. The other thing I tried was to capture unique lists of categories and subcategories for pages but I couldn't find a way to get a unique list of items from an array. Any suggest help would be great.
I'm a little late to answer your question, but maybe this will help someone else struggling with the same problem. It's a bit hacky, as Liquid logic tends to be, but it works (at least for me, on Shopify).
Assuming you have a 'pages' array that looks like this:
pages = [
{ name: 'Page 1', category: { name: 'pants' } },
{ name: 'Page 2', category: { name: 'pants' } },
{ name: 'Page 3', category: { name: 'shoes' } },
{ name: 'Page 4', category: { name: 'shirts' } },
{ name: 'Page 5', category: { name: 'shoes' } }
]
This code will return only unique category names:
{% assign delimiter = "," %}
{% assign names_str = "" %}
{% assign names = pages | map: 'category' | map: 'name' %}
{% for name in names %}
{% assign names_arr = names_str | split: delimiter %}
{% unless names_arr contains name %}
{% assign names_str = names_str | append: delimiter | append: name %}
{% endunless %}
{% endfor %}
{% assign names_uniq = names_str | remove_first: delimiter | split: delimiter %}
Result:
names_uniq => [ 'pants', 'shoes', 'shirts' ]