I have a nodejs app which is generating chartjs diagram images. In local the label is fine it looks like this:
But when I deploy exactly the same code to azure it looks like the label is scaled up and jammed.
My dependencies are "dependencies": { "chart.js": "2.7.3", "chartjs-node-canvas": "3.2.0"} and this is my chart config:
options: {
maintainAspectRatio: false,
legend: {
display: false
},
tooltips: {
enabled: false
},
animation: {
duration: 0
},
elements: {
line: {
cubicInterpolationMode: 'monotone'
}
},
scales: {
xAxes: [{
type: 'linear',
display: true,
ticks: {
autoSkip: true,
fontColor: gray,
fontSize: 14,
maxRotation: 0,
min: 0,
minRotation: 0,
padding: 10
},
gridLines: {
color: 'transparent',
lineWidth: 0,
drawTicks: false,
zeroLineColor: gray,
zeroLineWidth: 2
},
scaleLabel: {
display: true,
labelString: xLabel,
fontColor: gray,
fontSize: 14
}
}],
yAxes: [{
display: true,
id: this.yAxisId,
position: 'left',
ticks,
gridLines: {
color: transparentGray,
lineWidth: 1,
drawTicks: false,
zeroLineColor: gray,
zeroLineWidth: 2
},
scaleLabel: {
display: true,
labelString: yLabel,
fontColor: gray,
fontSize: 14
}
}]
}
Something is wrong with my options and then why it works perfectly fine on local?
Related
I have the following code for the node.js high-Charts export-server the legend is showing but the label formatted is not applied and the function is not executed also
I have tried the load function also and it is not working, I tried custom HTML and it is now showing also
let chartDetails = {
type: "png",
options: {
chart: {
type: "pie",
showInLegend: true,
dataLabels: {
enabled: false
}
},
title: {
align: 'left',
floating: false,
text: 'Main Title',
style: {
fontSize: '24px'
}
},
subtitle: {
verticalAlign: 'middle',
align: 'center',
floating: false,
text: '<b>300</b><br>Total Issues',
style: {
fontSize: '30px'
}
},
plotOptions: {
pie: {
innerSize: '70%',
shadow: false,
showInLegend: true,
dataLabels: {
enabled: false,
}
}
},
legend: {
enabled: true,
floating: true,
borderWidth: 0,
align: 'right',
layout: 'vertical',
verticalAlign: 'middle',
useHTML: true,
labelFormatter: function () {
console.log("this: is equal to ");
console.log(this);
return 'custom word';
}
}
,
series: [
{
data: [
{
name: "a",
y: 100
},
{
name: "b",
y: 20
},
{
name: "c",
y: 50
}
]
}
]
}
};
I expected 'custom word' instead 'a','b','c' is showing
It seems when using node-export-server as a module callback functions are not supported. Check this thread on the module github: https://github.com/highcharts/node-export-server/issues/122.
As a workaround, you can use labelFormat property instead of labelFormatter:
legend: {
enabled: true,
floating: true,
borderWidth: 0,
align: 'right',
layout: 'vertical',
verticalAlign: 'middle',
useHTML: true,
labelFormat: "custom word"
}
I'm trying to make a highchart donut with a legend on the side,
I'm really struggling to get the data labels to be more centered. At the moment each of them are in a different place,
an image of intended result:
https://codepen.io/mattdavidson/pen/qgqZyV
Highcharts.chart('container', {
credits: { enabled: false },
chart: { height: 300, width: 500, animation: false },
title: {
align: 'center',
verticalAlign: 'middle',
text: 10,
y: 25,
x: 55,
style: { color: '#333333', fontSize: '72px', fontWeight:'bold'},
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
format: '{point.y}',
distance: -25,
style: { fontSize: '32px', textOutline: 0 },
},
animation: false,
showInLegend: true,
},
},
legend: {
layout: 'vertical',
verticalAlign: 'middle',
align: 'left',
symbolHeight: 25,
symbolRadius: 5,
itemMarginTop: 10,
itemMarginBottom: 10,
},
series: [
{
type: 'pie',
innerSize: '55%',
colors: ['rgb(212,33,71)', 'rgb(250,189,43)', 'rgb(60,168,74)'],
data: [['Category 1', 4], ['Category 2', 5], ['Category 3', 1]],
},
],
});
There is an issue reported on Highcharts github about donut labels position. Check it here: https://github.com/highcharts/highcharts/issues/9005.
I've changed some options and added custom text using Highcharts.SVGRenderer#text (dynamic sum of all values) on the donut center. Perhaps it will help you: https://jsfiddle.net/BlackLabel/2jmqext9/.
Code:
Highcharts.chart('container', {
credits: {
enabled: false
},
chart: {
height: 300,
width: 500,
animation: false,
events: {
load: function() {
var chart = this,
offsetLeft = -20,
offsetTop = 10,
x = chart.plotLeft + chart.plotWidth / 2 + offsetLeft,
y = chart.plotTop + chart.plotHeight / 2 + offsetTop,
value = 0;
chart.series[0].yData.forEach(function(point) {
value += point;
});
chart.renderer.text(value, x, y).add().css({
fontSize: '30px'
}).toFront();
}
}
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
color: '#fff',
format: '{point.y}',
distance: -25,
style: {
fontSize: '20px',
textOutline: 0
},
},
animation: false,
showInLegend: true,
},
},
legend: {
layout: 'vertical',
verticalAlign: 'middle',
align: 'left',
symbolHeight: 15,
symbolRadius: 5,
symbolPadding: 10,
itemMarginTop: 10,
itemMarginBottom: 10,
itemStyle: {
fontSize: '15px'
}
},
series: [{
type: 'pie',
innerSize: '55%',
colors: ['rgb(212,33,71)', 'rgb(250,189,43)', 'rgb(60,168,74)'],
data: [
['Category 1', 4],
['Category 2', 2],
['Category 3', 12]
],
}, ],
});
image = new joint.shapes.basic.Image({
position : {
x : 250,
y : 250
},
size : {
width : 90,
height : 90
},
attrs : {
image : {
"xlink:href" : image_link,
width : 100,
height : 100
}
}
});
I want to add ports to image element of joint js
You can use the below code which is in one of the examples in the demo folder of jointjs npm package.
joint.shapes.devs.MyImageModel = joint.shapes.devs.Model.extend({
markup: '<g class="rotatable"><g class="scalable"><rect class="body"/></g><image/><text class="label"/><g class="inPorts"/><g class="outPorts"/></g>',
defaults: joint.util.deepSupplement({
type: 'devs.MyImageModel',
size: { width: 70, height: 50 },
attrs: {
'.port-body': {
r: 5,
magnet: true,
stroke: '#000000'
},
// rect: { stroke: '#d1d1d1', fill: { type: 'linearGradient', stops: [{offset: '0%', color: 'white'}, {offset: '50%', color: '#d1d1d1'}], attrs: { x1: '0%', y1: '0%', x2: '0%', y2: '100%' } } },
// circle: { stroke: 'gray' },
'.inPorts circle': { fill: '' },
'.outPorts circle': { fill: '' },
image: { 'xlink:href': '/images/rout6.gif', width: 70, height: 50, 'ref-x': .5, 'ref-y': .5, ref: 'rect', 'x-alignment': 'middle', 'y-alignment': 'middle' }
}
}, joint.shapes.devs.Model.prototype.defaults)
});
joint.shapes.devs.MyImageModelView = joint.shapes.devs.ModelView;
// Usage:
var imageModel = new joint.shapes.devs.MyImageModel({
position: { x: 10, y: 190 },
size: { width: 70, height: 50 },
inPorts: [''],
outPorts: ['']
});
stencilGraph.addCell(imageModel);
How can I create dashed lines in both x-axis and y-axis in flot.js? I don't know where to change in library. This is my code Of generated graph on canvas using flot.js. But I want the Dashed Lines on x-axis and y-axis on grid background in canvas. I try markingsStyle: 'dashed' but that did not work.
plot = $.plot("#placeholder", [{
dashes: { show: true },
data: data,
color: "rgb(255, 255, 255)",
label: $("#hidsymbolid").val(),
}, {
data: dataBaseLine,
color: "rgb(255, 255, 255)",
lineStyle: "dashed"
}
], {
series: {
lines: {
lineWidth: 1,
show: true,
lineJoin: "round",
lineCap: "round"
},
points: {
show: false
}
},
grid: {
hoverable: true,
backgroundColor: {
colors: ["#3B3B3B", "#3B3B3B"]
},
markingsStyle: 'dashed'
},
xaxis: {
show: true,
tickSize: parseFloat((maxvalue - minvalue) / 6),
min: minvalue,
max: maxvalue,
dashes: { show: true },
timeformat: "%H:%M:%S",
tickColor: "rgb(255, 255, 255)",
},
yaxis: {
show: true,
dashes: { show: true },
color: "rgb(255, 255, 255)",
alignTicksWithAxis: 2
}
});
Please try this.
setLineDash([5])
Example:-
var context = document.querySelector("canvas");
var cxt = context..getContext('2d');
cxt.beginPath();
cxt.setLineDash([9]);
cxt.rect(30,15,100,100);
cxt.stroke();
using jqPlot, is it possible to limit the point labels to just one series? See screenshot below! What I would like displayed is just the values above the "Actual" bar. The "mean" and "Planned" should'nt display!
Thanks!
Here's my code
<script type="text/javascript">
$(document).ready(function () {
$.jqplot.config.enablePlugins = true;
var trendline = [60000, 70000, 110000, 80000];
var planned = [70000, 90000, 120000, 100000,];
var actual = [80000, 80000, 150000, 120000];
var xAxis = ['Jan', 'Feb', 'Mar', 'Apr'];
$(function() {
$.jqplot('chartDiv', [planned, actual, trendline], BarChart());
});
function BarChart()
{
var optionsObj = {
title: '',
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: xAxis,
},
yaxis: {
tickOptions: { showMark: false, formatString: "%'d" },
},
},
legend: {
show: true,
},
grid: {
borderColor: "#dad5d1",
background: "#dad5d1",
drawGridlines: false,
shadow: false
},
series: [
{label:'Planned',renderer:$.jqplot.BarRenderer},
{label: 'Actual',renderer:$.jqplot.BarRenderer},
{label: 'Mean',
pointLabels: {
show: true,
},
renderer:$.jqplot.LineRenderer,
lineWidth:4,
markerOptions:{
color: "#d87d12",
size:12,
}}
],
seriesColors: [ "#ada195", "#4a4541", "#ff9619"],
seriesDefaults:{
shadow: false,
rendererOptions:{
barPadding: 0,
barMargin: 10,
barWidth: 25
}
},
};
return optionsObj;
}
});
</script>
This actually looks like a bug in the point labels plugin. You can work around it by disabling the values in the seriesDefault (show:false) and then turning them on for the series you desire:
series: [
{label:'Planned',renderer:$.jqplot.BarRenderer},
{label: 'Actual',renderer:$.jqplot.BarRenderer},
{label: 'Mean',
pointLabels: {
show: true,
},
renderer:$.jqplot.LineRenderer,
lineWidth:4,
markerOptions:{
color: "#d87d12",
size:12,
}}
],
seriesDefaults:{
pointLabels:{show:false},
shadow: false,
rendererOptions:{
barPadding: 0,
barMargin: 10,
barWidth: 25
}
},