Place values above the graph for Multi series Column chart - fusioncharts

I am trying to place the values for one of the series in a 2 series stacked column chart. I tried to use properties as shown in this link Data Values Properties but I dont see the changes being applied on the chart.
I need the values to be on top only for one of the series but not both.
Here is the screen shot of the graph. I need to place the values for the second series highlighted, since they are not clearly visible in this graph.
Here is the fiddle where I attempted to achieve this. JS Fiddle Demo
My XML is below:
<chart labelDisplay='ROTATE' useRoundEdges='0' slantLabels='1'
formatNumber='1' formatNumberScale='0' plotGradientColor=''
showValues='1' valuePosition='ABOVE'
caption='Total Call vs LTL Call'>
<categories>
<category label='01AUG2014' />
<category label='02AUG2014' />
<category label='03AUG2014' />
</categories>
<dataset seriesName='TOTAL_CALL' color='FFFFCC'>
<set value=' 11708' />
<set value=' 7675' />
<set value=' 8210' />
</dataset>
<dataset seriesName='LTL_TOTAL' color='800000'>
<set value=' 158' />
<set value=' 80' />
<set value=' 34' />
</dataset>
</chart>
Note: I am using Fusion Charts V3.0

For Stacked Column, it is not feasible to show values for one dataset on top. Instead, try using Text Annotations, to place the values of second dataset on top of the data plot.
Please check the JSFiddle here
FusionCharts.ready(function () {
var revenueChart = new FusionCharts({
type: 'stackedcolumn2d',
renderAt: 'chart-container',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Revenue split by product category",
"subCaption": "For current year",
"xAxisname": "Quarter",
"yAxisName": "% Revenue",
"numberPrefix": "$",
"showValues": "0",
"decimals": "0",
"theme": "fint",
"valuePosition": "auto",
},
"categories": [{
"category": [{
"label": "Q1"
}, {
"label": "Q2"
}, {
"label": "Q3"
}, {
"label": "Q4"
}]
}],
"dataset": [{
"seriesname": "Food Products",
"showValues": "1",
"data": [{
"value": "11000",
"valuePosition": "above"
}, {
"value": "15000",
"valuePosition": "above"
}, {
"value": "13500",
"valuePosition": "above"
}, {
"value": "15000",
"valuePosition": "above"
}]
}, {
"seriesname": "Non-Food Products",
"data": [{
"value": "11"
}, {
"value": "14"
}, {
"value": "83"
}, {
"value": "11"
}]
}],
"annotations": {
"groups": [{
"id": "infobar",
"items": [{
"id": "label",
"type": "text",
"text": "11",
"fillcolor": "#6baa01",
"rotate": "90",
"x": "$canvasStartX + 50",
"y": "$dataset.1.set.0.y - 10"
}, {
"id": "label1",
"type": "text",
"text": "14",
"fillcolor": "#6baa01",
"rotate": "90",
"x": "$canvasStartX + 160",
"y": "$dataset.1.set.1.y - 10"
}, {
"id": "label2",
"type": "text",
"text": "83",
"fillcolor": "#6baa01",
"rotate": "90",
"x": "$canvasStartX + 260",
"y": "$dataset.1.set.2.y - 10"
}, {
"id": "label1",
"type": "text",
"text": "11",
"fillcolor": "#6baa01",
"rotate": "90",
"x": "$canvasStartX + 370",
"y": "$dataset.1.set.3.y - 10"
}]
}]
},
}
});
revenueChart.render();
});
<!-- A simple 100% stacked column chart in FusionCharts showing revenue by product category for current year Attribute: # stack100Percent - Used to make Percentage distribution instead of actual values in a stacked chart -->
<div id="chart-container">FusionCharts will render here</div>

Related

Vega-Lite: is it possible to define a selection based on date/time range?

Apologies for the vague question, I'm not too sure how to completely phrase what I'm wanting to do, which hasn't helped my searching for solutions at all! I'm pretty new to javascript and vega-lite but am trying to upskill. As such I'm working on COVID19 data made available by the New Zealand Ministry of Health, and looking at how I can visualise the data. If interested here is my rough site thus far: https://sirselim.github.io/covid_analysis/
I'm trying to define all days that have been in lockdown here in NZ, since the 26th March 2020, and display these in a different colour, see below for my current solution which is I believe 95% of the way there:
So I have essentially what I want being displayed, however I am manually defining the dates in the scale element, which doesn't seem like the correct way to do things. I would have thought I should be able to define a date range and it would apply the formatting to dates that fall in the defined range. The other, smaller, tweak I would like to make is not listing the dates in the legend but just have [blue] no lockdown and [orange] lockdown.
Here's the code:
<!DOCTYPE html>
<html>
<head>
<title>Embedding Vega-Lite</title>
<script src="https://cdn.jsdelivr.net/npm/vega#5.10.1"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite#4.9.0"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed#6.5.2"></script>
</head>
<body>
<div id="vis"></div>
<script type="text/javascript">
var yourVlSpec = {
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"width": 580,
"height": 200,
"padding": 5,
"description": "simple vega-lite chart with linked data",
"title": "Confirmed COVID cases in NZ DHBs",
"data": {
"url": "https://raw.githubusercontent.com/sirselim/covid_analysis/master/data//NZCOVID_confirmed_formatted.json"
},
"transform": [{
"sort": [{"field": "Date of report"}],
"window": [{"op": "count", "field": "count", "as": "cumulative_count"}],
"frame": [null, 0]
}],
"mark": {
"type": "bar",
"tooltip": true
},
"encoding": {
"x": {
"field": "Date of report",
"type": "nominal"
},
"y": {
"field": "cumulative_count",
"type": "quantitative"
},
"color": {
"value": "steelblue",
"condition": {
"test": {
"field": "Date of report",
"range": [
"2020-03-26",
"2020-04-30"
]
},
"field": "Date of report",
"title": "Days in lockdown",
"type": "nominal",
"scale": {
"domain": [
"2020-03-26",
"2020-03-27",
"2020-03-28",
"2020-03-29",
"2020-03-30",
"2020-03-31",
"2020-04-01"
],
"range": [
"#FFA500",
"#FFA500"
]
}
}
}
}
};
vegaEmbed('#vis', yourVlSpec);
</script>
</body>
</html>
Thank you in advance to anyone with some insight!
If you're using a test condition for the color, you can specify the values you want directly, rather than defining them indirectly via a custom scale.
For example (vega editor):
{
"title": "Confirmed COVID cases in NZ DHBs",
"data": {
"url": "https://raw.githubusercontent.com/sirselim/covid_analysis/master/data//NZCOVID_confirmed_formatted.json"
},
"transform": [
{
"sort": [{"field": "Date of report"}],
"window": [{"op": "count", "field": "count", "as": "cumulative_count"}],
"frame": [null, 0]
}
],
"mark": {"type": "bar", "tooltip": true},
"encoding": {
"x": {"field": "Date of report", "type": "nominal"},
"y": {"field": "cumulative_count", "type": "quantitative"},
"color": {
"value": "steelblue",
"condition": {
"test": {"field": "Date of report", "gt": "2020-03-26"},
"value": "orange"
}
}
},
"width": 580,
"height": 200
}

fancytree The font color of the moved item changes after dragging and dropping

I have a problem while using fancytree.
After checking one or more items, drag and drop, the font color of the moved item has been changed
$(function() {
// Attach the fancytree widget to an existing <div id="tree"> element
// and pass the tree options as an argument to the fancytree() function:
$("#tree").fancytree({
extensions: ["dnd5", "multi", "table"],
checkbox: true,
// debugLevel: 1,
source: [{
"title": "Books",
"expanded": true,
"folder": true,
"children": [{
"title": "Art of War",
"type": "book",
"author": "Sun Tzu",
"year": -500,
"qty": 21,
"price": 5.95
},
{
"title": "The Hobbit",
"type": "book",
"author": "J.R.R. Tolkien",
"year": 1937,
"qty": 32,
"price": 8.97
},
{
"title": "The Little Prince",
"type": "book",
"author": "Antoine de Saint-Exupery",
"year": 1943,
"qty": 2946,
"price": 6.82
},
{
"title": "Don Quixote",
"type": "book",
"author": "Miguel de Cervantes",
"year": 1615,
"qty": 932,
"price": 15.99
}
]
},
{
"title": "Music",
"folder": true,
"children": [{
"title": "Nevermind",
"type": "music",
"author": "Nirvana",
"year": 1991,
"qty": 916,
"price": 15.95
},
{
"title": "Autobahn",
"type": "music",
"author": "Kraftwerk",
"year": 1974,
"qty": 2261,
"price": 23.98
},
{
"title": "Kind of Blue",
"type": "music",
"author": "Miles Davis",
"year": 1959,
"qty": 9735,
"price": 21.90
},
{
"title": "Back in Black",
"type": "music",
"author": "AC/DC",
"year": 1980,
"qty": 3895,
"price": 17.99
},
{
"title": "The Dark Side of the Moon",
"type": "music",
"author": "Pink Floyd",
"year": 1973,
"qty": 263,
"price": 17.99
},
{
"title": "Sgt. Pepper's Lonely Hearts Club Band",
"type": "music",
"author": "The Beatles",
"year": 1967,
"qty": 521,
"price": 13.98
}
]
},
{
"title": "Electronics & Computers",
"expanded": true,
"folder": true,
"children": [{
"title": "Cell Phones",
"folder": true,
"children": [{
"title": "Moto G",
"type": "phone",
"author": "Motorola",
"year": 2014,
"qty": 332,
"price": 224.99
},
{
"title": "Galaxy S8",
"type": "phone",
"author": "Samsung",
"year": 2016,
"qty": 952,
"price": 509.99
},
{
"title": "iPhone SE",
"type": "phone",
"author": "Apple",
"year": 2016,
"qty": 444,
"price": 282.75
},
{
"title": "G6",
"type": "phone",
"author": "LG",
"year": 2017,
"qty": 951,
"price": 309.99
},
{
"title": "Lumia",
"type": "phone",
"author": "Microsoft",
"year": 2014,
"qty": 32,
"price": 205.95
},
{
"title": "Xperia",
"type": "phone",
"author": "Sony",
"year": 2014,
"qty": 77,
"price": 195.95
},
{
"title": "3210",
"type": "phone",
"author": "Nokia",
"year": 1999,
"qty": 3,
"price": 85.99
}
]
},
{
"title": "Computers",
"folder": true,
"children": [{
"title": "ThinkPad",
"type": "computer",
"author": "IBM",
"year": 1992,
"qty": 16,
"price": 749.90
},
{
"title": "C64",
"type": "computer",
"author": "Commodore",
"year": 1982,
"qty": 83,
"price": 595.00
},
{
"title": "MacBook Pro",
"type": "computer",
"author": "Apple",
"year": 2006,
"qty": 482,
"price": 1949.95
},
{
"title": "Sinclair ZX Spectrum",
"type": "computer",
"author": "Sinclair Research",
"year": 1982,
"qty": 1,
"price": 529
},
{
"title": "Apple II",
"type": "computer",
"author": "Apple",
"year": 1977,
"qty": 17,
"price": 1298
},
{
"title": "PC AT",
"type": "computer",
"author": "IBM",
"year": 1984,
"qty": 3,
"price": 1235.00
}
]
}
]
},
{
"title": "More...",
"folder": true,
"lazy": true
}
],
activate: function(event, data) {},
lazyLoad: function(event, data) {
data.result = [{
"title": "Sub item",
"lazy": true
}, {
"title": "Sub folder",
"folder": true,
"lazy": true
}]
},
renderColumns: function(event, data) {
var node = data.node,
$tdList = $(node.tr).find(">td");
$tdList.eq(1).text(node.key);
$tdList.eq(2).text(!!node.folder);
},
dnd5: {
preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
autoExpandMS: 1000,
multiSource: true, // drag all selected nodes (plus current node)
// focusOnClick: true,
// refreshPositions: true,
dragStart: function(node, data) {
// allow dragging `node`:
data.dataTransfer.dropEffect = "move";
return true;
},
// dragDrag: function(node, data) {
// data.node.info("dragDrag", data);
// data.dataTransfer.dropEffect = "copy";
// return true;
// },
dragEnter: function(node, data) {
data.node.info("dragEnter", data);
data.dataTransfer.dropEffect = "link";
return true;
},
// dragOver: function(node, data) {
// data.node.info("dragOver", data);
// data.dataTransfer.dropEffect = "link";
// return true;
// },
dragEnd: function(node, data) {
data.node.info("dragEnd", data);
},
dragDrop: function(node, data) {
// This function MUST be defined to enable dropping of items on the tree.
//
// The source data is provided in several formats:
// `data.otherNode` (null if it's not a FancytreeNode from the same page)
// `data.otherNodeData` (Json object; null if it's not a FancytreeNode)
// `data.dataTransfer.getData()`
//
// We may access some meta data to decide what to do:
// `data.hitMode` ("before", "after", or "over").
// `data.dataTransfer.dropEffect`, `.effectAllowed`
// `data.originalEvent.shiftKey`, ...
//
// Example:
var dataTransfer = data.dataTransfer,
sourceNodes = data.otherNodeList,
event = data.originalEvent,
copyMode = event.ctrlKey || event.altKey;
if (copyMode) {
$.each(sourceNodes, function(i, o) {
o.copyTo(node, data.hitMode, function(n) {
delete n.key;
n.selected = false;
n.title = "Copy of " + n.title;
});
});
} else {
$.each(sourceNodes, function(i, o) {
o.moveTo(node, data.hitMode);
});
}
node.debug("drop", data);
node.setExpanded();
}
}
});
});
.fancytree-drag-source {
font-style: oblique;
}
.fancytree-drag-source.fancytree-drag-remove {
opacity: 0.5;
}
/* Prevent scrolling while DND */
ul.fancytree-container {
/*
height: 200px;
overflow: auto;
*/
/* position: inherit;*/
}
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Test D'n'D - Fancytree</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://wwwendt.de/tech/fancytree/src/skin-win8/ui.fancytree.css" rel="stylesheet">
<script src="https://wwwendt.de/tech/fancytree/src/jquery-ui-dependencies/jquery.fancytree.ui-deps.js"></script>
<script src="https://wwwendt.de/tech/fancytree/src/jquery.fancytree.js"></script>
<script src="https://wwwendt.de/tech/fancytree/src/jquery.fancytree.dnd5.js"></script>
<script src="https://wwwendt.de/tech/fancytree/src/jquery.fancytree.multi.js"></script>
<script src="https://wwwendt.de/tech/fancytree/src/jquery.fancytree.table.js"></script>
</head>
<body class="example">
<h1>Example: extended drag'n'drop sample</h1>
<div class="description">
This sample shows how to
<ul>
<li>implement drag'n'drop with multiple selected nodes
<li>allow modifier keys <kbd>Ctrl</kbd> or <kbd>Alt</kbd> to force copy instead of move operations
</ul>
</div>
<div>
<label for="skinswitcher">Skin:</label>
<select id="skinswitcher"></select>
</div>
<!-- Add a <table> element where the tree should appear: -->
<!--<p class="description">
Standard tree:
</p>
<div id="tree"></div>-->
<p class="description">
Table tree:
</p>
<table id="tree">
<colgroup>
<col width="*"/>
<col width="200px"/>
<col width="100px"/>
</colgroup>
<thead>
<tr>
<th></th>
<th>Key</th>
<th>Folder</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<p class="droppable">
Droppable.
</p>
</body>
This may be related to a bug that is closed with v2.30.

Decimal point in secondary Y axis and integer value in primary Y axis in fusion chart

How to create dual axis with primary Y axis having integer value and secondary Y axis has decimal point in fusion chart. Below is my current code that is showing both axis as decimal point values.
<graph animation='0' PYAxisName='Units' SYAxisName='PPB' bgColor='f5f5f5' rotateNames='1' PYAxisMaxValue='" + maxYVal + "' SYAxisMaxValue='" + maxY1Val + "' canvasBorderColor='cccccc' canvasBorderThickness='0' canvasBgAlpha='100' showColumnShadow='0' showvalues='0' formatNumberScale='1' anchorSides='10' anchorRadius='3' decimalPrecision='1' showShadow='0' showDivLineValue='1' numdivlines='" + numLines + "' divlinecolor='DCDCDC' divLineThickness='1'>
Try using FusionCharts v 3.12.2, it is possible to get the secondary y-axis value in decimal by setting "sForceDecimals" attribute at chart attribute level. Refer to the code below:
FusionCharts.ready(function() {
var revenueChart = new FusionCharts({
type: 'stackedcolumn3dlinedy',
renderAt: 'chart-container',
width: '550',
height: '350',
dataFormat: 'json',
dataSource: {
"chart": {
"caption": "Product-wise Quarterly Revenue vs. Profit %",
"subCaption": "Harry's SuperMart - Last Year",
"xAxisname": "Quarter",
"pYAxisName": "Sales",
"sYAxisName": "Profit %",
"numberPrefix": "$",
"sNumberSuffix": "%",
//This "sForceDecimals" attribute will make only the secondary y-axis values in decimals.
"sForceDecimals": "1",
"sYAxisMaxValue": "25",
"paletteColors": "#0075c2,#1aaf5d,#f2c500",
"bgColor": "#ffffff",
"borderAlpha": "20",
"showCanvasBorder": "0",
"usePlotGradientColor": "0",
"plotBorderAlpha": "10",
"legendBorderAlpha": "0",
"legendShadow": "0",
"legendBgAlpha": "0",
"valueFontColor": "#ffffff",
"showXAxisLine": "1",
"xAxisLineColor": "#999999",
"divlineColor": "#999999",
"divLineIsDashed": "1",
"showAlternateHGridColor": "0",
"subcaptionFontBold": "0",
"subcaptionFontSize": "14",
"showHoverEffect": "1"
},
"categories": [{
"category": [{
"label": "Q1"
}, {
"label": "Q2"
}, {
"label": "Q3"
}, {
"label": "Q4"
}]
}],
"dataset": [{
"seriesname": "Food Products",
"data": [{
"value": "11000"
}, {
"value": "15000"
}, {
"value": "13500"
}, {
"value": "15000"
}]
}, {
"seriesname": "Non-Food Products",
"data": [{
"value": "11400"
}, {
"value": "14800"
}, {
"value": "8300"
}, {
"value": "11800"
}]
}, {
"seriesname": "Profit %",
"renderAs": "line",
"parentYAxis": "S",
"showValues": "0",
"data": [{
"value": "14"
}, {
"value": "16"
}, {
"value": "15"
}, {
"value": "17"
}]
}]
}
}).render();
});
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<div id="chart-container">FusionCharts will render here</div>

kendo chart series legend in top on two lines

I have an implementation of a chart where the legend must be in top for screen size reasons. My customer complains that it is hard to see the (in this case) two series titles.
Currently it shows like this:
[] series title 1 [] series title 2
I want:
[] series title 1
[] series title 2
setting legend.position = "right" shows them like I want, but on the side, so it must be set to "top"
Any way to achieve this?
Look here http://plnkr.co/edit/BVPb4AivJuks5VGr6FGz?p=preview
Chart is configured like this:
{
"chartArea": {
"font": "14px/1.714 \"roboto\", \"Arial\", \"Helvetica\", sans-serif",
"width": 1000,
"height": 333.3333333333333,
"background": "",
"border": {
"color": ""
}
},
"title": {
"text": "",
"font": "14px/1.714 \"roboto\", \"Arial\", \"Helvetica\", sans-serif"
},
"legend": {
"position": "top"
},
"seriesDefaults": {
"markers": {
"visible": false
}
},
"series": [
{
"type": "column",
"name": "03-02-2016",
"data": [
0.110845970287301,
0.0914614304545012,
0.0828538550058511,
0.0828538550056237,
0.0897167892449033,
0.178615728107161,
0.178615728107161,
0.178615728107161,
0.178615728107161,
0.0727362937236649,
0,
0
],
"color": "#8f9b49"
},
{
"type": "line",
"name": "02-02-2016 (perioden før!)",
"data": [
0.110709412367669,
0.0911219388724476,
0.0911219388722202,
0.0911219388724476,
0.0911219388722202,
0.0235651458583561,
0.140159626241029,
0.140159626241029,
0.140159626241029,
0.075608331711237,
0.899526564965754,
0.899526564965754,
0.899526564965754,
0.687138348237795,
0.431259248819742,
0.431259248819742,
0.431259248819515,
0.400167587908072,
0.325565217391159,
0.325565217391386,
0.325565217391159,
0.260910866318909,
0.110845970287073,
0.110845970287073
],
"color": "#bdc779",
"border": {
"width": 1,
"color": "#dddddd"
}
}
],
"valueAxis": {
"plotBands": [],
"title": {
"text": "kWh",
"background": "none",
"font": "14px/1.714 \"roboto\", \"Arial\", \"Helvetica\", sans-serif"
},
"labels": {
"format": "{0}",
"font": "12px/1.714 \"roboto\", \"Arial\", \"Helvetica\", sans-serif"
},
"line": {
"visible": false
},
"axisCrossingValue": 0
},
"categoryAxis": {
"majorGridLines": {
"width": 0
},
"title": {
"text": "Time",
"background": "none",
"font": "14px/1.714 \"roboto\", \"Arial\", \"Helvetica\", sans-serif"
},
"categories": [
"00",
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23"
],
"line": {
"visible": false
},
"labels": {
"padding": {
"top": 4
},
"font": "12px/1.714 \"roboto\", \"Arial\", \"Helvetica\", sans-serif"
}
},
"tooltip": {
"visible": true,
"format": "{0}m2",
"template": "#= series.name # #= category #: #= value #"
}
}
Set the legend orientation to vertical and then set the height as needed:
legend: {
position: "top",
orientation: "vertical",
height: 50
},

How to change AmChart pie chart background?

How can I replace the color in the pie chart?
Please find my code below :
AmCharts.makeChart("pie-diagramm", {
"type": "pie",
"theme": "none",
"dataProvider": [{
"title": "Интернэшнл",
"value": 100
}, {
"title": "Казахстан",
"value": 90
},{
"title": "Лтд",
"value": 100
},
{
"title": "Лимитед",
"value": 400},
{
"title": "компания",
"value": 400},
{
"title": "ЛУКАРКО",
"value": 600},{
"title": "Компани",
"value": 700
},
{
"title": "«КазМунайГаз»",
"value": 900},{
"title": "КТК",
"value": 350},
{
"title": "Федерация",
"value": 1300},
{
"title": "Пайплайн",
"value": 90}
],
"titleField": "title",
"valueField": "value",
"labelRadius": 5,
"fontSize": 16,
"radius": "25%",
"innerRadius": "30%",
"labelText": "[[title]]",
"exportConfig": {
"menuItems": [{
"icon": '/lib/3/images/export.png',
"format": 'png'
}]
}
});
Thanks!
add color attribute in your DataProvider
dataProvider": [{
"title": "Интернэшнл",
"value": 100,
"color": "your choice of color"
}, {
"title": "Казахстан",
"value": 90,
"color": "your choice of color"
}
http://docs.amcharts.com/3/javascriptcharts/AmPieChart,
http://docs.amcharts.com/3/javascriptcharts/Slice
the dataprovider holds the property of each slice in pie chart
chart.chartData = dataProvider;
The best and most simple way to do this would be setting background-color style of your chart's container div. Or you can set chart.backgroundColor="#FF0000"; and chart.backgroundAlpha to some bigger than 0 value.