Fusion Chart: how to adjust 'displayValue' Y-position - fusioncharts

Is there any way to adjust 'displayValue' (not the value) on a stacked bar chart? My JSON looks like this:
{
"chart": {
"animation": 0,
"canvasBgColor": "FFFFFF",
"showBorder": 0,
"borderColor": "FFFFFF",
"bgColor": "FFFFFF",
"yAxisValuesPadding": 5,
"divLineColor": "DDDDDD",
"showValues": "1",
"showSum": "1",
"numDivLines": "1",
"yAxisMaxValue": "228",
"adjustDiv": "0",
"divLineAlpha": "100",
"scrollColor": "FFFFFF",
"showCanvasBorder": "1"
},
"categories": {
"category": [
{
"label": "Sep 07 Sep 13"
},
{
"label": "Sep 07 Sep 13"
}
]
},
"dataset": [
{
"color": "4DB6C1",
"seriesName": "tomatoes",
"data": [
{
"value": "6",
"displayValue": "01 Oct",
"toolText": "6 tomatoes"
},
{
"value": "50",
"displayValue": "02 Oct",
"toolText": "50 tomatoes"
}
]
},
{
"color": "AFBCD6",
"seriesName": "potatoes",
"data": [
{
"value": "6",
"displayValue": "01 Oct",
"toolText": "6 potatoes"
},
{
"value": "38",
"displayValue": "02 Oct",
"toolText": "38 potatoes"
}
]
}
],
"styles": {...}
}
So I have two stacked columns, series names: tomatoes and potatoes. And if I hide tomatoes and there is just 5 of potatoes per period, the displayed value = "02 Oct" is got cut as it's aligned based on the column height.
When generated the code looks like this:
<text x="664.5" y="182" text-anchor="middle" stroke="none" fill="#223a67" style="text-anchor: middle; font-family: Verdana; font-size: 12px; font-weight: bold;" font-family="Verdana" font-size="12px" font-weight="bold">
And what I need to do is to change 'dy' attribute for the tspan, so when the bar itself is small, the displayValue still could be visible.
Is there any chart fusion method to do that?

Related

How to create Grouped Bar Chart in Vegalite?

Name | Value 1 | Value 2
BTC | 1 | 2
ETH | 1 | 2
to this:
Tried to used this as an example: https://vega.github.io/vega-lite/examples/bar_grouped.html,
but I can't make it work.
Can someone please point me to the right direction? Thank you in advance.
Instead of using column provided in your question, You can simply use layers and keep the x axis as common and provide value1 and value2 in y axis of each layer respectively and simply provide some offset to show it as a grouped bar chart. Below is the basic spec configuration and editor:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A simple bar chart with embedded data.",
"title": "My chart",
"width": 200,
"data": {
"values": [
{"name": "BTH", "value1": 28, "value2": 24, "legendTitle": "value1"},
{"name": "ETH", "value1": 55, "value2": 25, "legendTitle": "value2"}
]
},
"encoding": {
"x": {"field": "name", "type": "nominal", "axis": {"labelAngle": 0}}
},
"layer": [
{
"mark": {"type": "bar", "xOffset": -20, "size": 30, "color": "skyblue"},
"encoding": {
"y": {
"field": "value1",
"type": "quantitative",
"axis": {"title": null, "ticks": false}
}
}
},
{
"mark": {"type": "bar", "size": 30, "xOffset": 18, "color": "orange"},
"encoding": {
"y": {
"field": "value2",
"type": "quantitative",
"axis": {"title": null, "ticks": false}
}
}
},
{
"mark": {"type": "text"},
"encoding": {
"fill": {
"field": "legendTitle",
"scale": {"range": ["skyBlue", "orange"]},
"legend": {"title": null, "symbolType": "square", "orient": "bottom"}
}
}
}
]
}

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.