I am trying to figure out why I have that chart wider than the container. I noticed that if I remove the width completely for the first screenshot and then set width: 100% in the next. However, I am not able to force this styles and I think this is not the right way to go.
Here are the settings of my chart. Apart from that, I do not use any other css.
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container10',
type: 'line',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
spacingRight: 5,
height: 370,
width: 770
},
title: {
text: 'Database volume'
},
colors:['#229369', '#00526F'],
xAxis: {
categories: catValues
},
yAxis: [{
title: {
text: 'Table size in MB'
},
labels: {
style: {
color: '#229369'
}
}
},
{
title: {
text: 'Index size in MB'
},
labels: {
style: {
color: '#00526F'
}
},
opposite: true
}],
tooltip: {
valueSuffix: ' MB'
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: true
}
},
series: [{
name: 'Table',
data: series1,
}, {
name: 'Index',
yAxis: 1,
data: series2
}]
});
I am not sure if this is the correct way of fixing that, but seems to work. I set the width of the container of the chart directive.
.chart-wrapper {
width: 99%;
}
Then in the directive code onDataLoaded or windowResized I call this:
function resize() {
height = chart.height;
width = $(".chart-wrapper").width();
chart.setSize(width, height, doAnimation = false);
}
Related
I am using echart for display line chart.
In this chart yAxis values are not ploting for red line.
As you can see in tooltip value of green line is match position. At this point red line must be blow 9000.
How can i set yAxis value for multiple line.
Hare is my echart code
<ReactEcharts
option={{
animationDuration: 1000,
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
toolbox: {
feature: {
saveAsImage: {}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
boundaryGap: false,
data: usersData.indexes
}
],
yAxis: [
{
type: 'value',
}
],
series: [
{
name: 'Total new users',
type: 'line',
stack: 'Total',
data: [
5230,4963,5167,5715,5468,4752,9732,9312,8814,7900,6964,6889,7613,9363,5911],
smooth: false,
showSymbol: true,
},
{
name: 'India new Users',
type: 'line',
stack: 'Total',
data: [2515,2424,2691,2817,2687,2207,6769,4182,3941,3487,2716,2690,3381,4431,1493],
smooth: false,
showSymbol: true,
}
]
}}
/>
I have implemented the piechart using highcart. Highchart 3d piechart pointer is not pointing correct color. It is pointing the wrong area. But If I removed 3d options it is working as expected. Please find the below code snippet and screenshot.
chart: {
renderTo: element[0],
backgroundColor: 'transparent',
type: "pie",
options3d: {
enabled: true,
alpha: 45,
beta: 0
},
height: dynamicHieght,
verticalAlign: 'top'
},
title: {
text: ''
},
credits: {
enabled: false
},
exporting: false,
legend: {
enabled: false
},
tooltip: {
pointFormat: '{point.name} - {point.incomingTaffic}</b>',
headerFormat: ''
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth: 35,
dataLabels: {
enabled: true,
format: '{point.y}%'
}
}
},
series: [{
type: 'pie',
name: "Traffic in bps",
colorByPoint: true,
data: scope.chartconfig.data,
colors: ["#5DA5DA", "#F17CB0", "#414a89", "#ff8b80", "#ffa661", "#74beec" , "#ffbf00", "#b67bd1", "#ffc54c", "#e4e34f", "#b2ff73", "#60d394", "#ee6055"]
}]
I'm using this pie chart example in this link to display a pie chart.
How do I set the pie chart dynamically and refresh the pie chart?
To dynamically create chart:-
var chart = Ext.create('Ext.chart.Chart', {
xtype: 'chart',
animate: true,
store: store1,
shadow: true,
legend: {
position: 'right'
},
insetPadding: 60,
theme: 'Base:gradients',
series: [{
type: 'pie',
field: 'data1',
showInLegend: true,
donut: donut,
tips: {
trackMouse: true,
renderer: function(storeItem, item) {
//calculate percentage.
var total = 0;
store1.each(function(rec) {
total += rec.get('data1');
});
this.setTitle(storeItem.get('name') + ': ' + Math.round(storeItem.get('data1') / total * 100) + '%');
}
},
highlight: {
segment: {
margin: 20
}
},
label: {
field: 'name',
display: 'rotate',
contrast: true,
font: '18px Arial'
}
}]
});
To refresh the chart you can use store.loadData method.
Reference url
For loading dynamic data in pie char store you can use reload(),loadData() and load() methods of store.
store.reload() example
store.reload({
params : {
userid : 1234
}
});
store.load() example
store.load({
scope: this,
callback: function(records, operation, success) {
// the Ext.data.operation.Operation object
// contains all of the details of the load operation
console.log(records);
}
});
If the callback scope does not need to be set, a function can simply be passed:
store.load(function(records, operation, success) {
console.log('loaded records');
});
store.loadData() example
var data= [{
os: 'Android',
data1: 68.3
},{
os: 'Others',
data1: 1.9
}];
store.loadData(data);
In this FIDDLE, I have created a demo. Hope this will help/guide you to achieve your requirement.
CODE SNIPPET
Ext.application({
name: 'Fiddle',
launch: function () {
/**
* Returns a random integer between min (inclusive) and max (inclusive)
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function createDyanmicData(store) {
store.each(rec => {
rec.set('data1', getRandomInt(20, 100));
});
}
Ext.create({
xtype: 'polar',
tbar: ['->', {
text: 'Refresh Chart',
height: 35,
padding: 5,
margin:'0 10',
style: {
background: 'green'
},
handler: function () {
createDyanmicData(this.up('polar').getStore())
}
}],
title: 'Pie Chart Example',
renderTo: Ext.getBody(),
width: '100%',
height: window.innerHeight,
interactions: 'rotate',
store: {
fields: ['os', 'data1'],
data: [{
os: 'Android',
data1: 68.3
}, {
os: 'iOS',
data1: 17.9
}, {
os: 'Windows Phone',
data1: 10.2
}, {
os: 'BlackBerry',
data1: 1.7
}, {
os: 'Others',
data1: 1.9
}]
},
series: {
type: 'pie',
xField: 'data1',
label: {
field: 'os',
display: 'inside',
calloutLine: true
},
showInLegend: true,
highlight: true,
highlightCfg: {
fill: '#ccc',
'stroke-width': 10,
stroke: '#fff'
},
tips: {
trackMouse: true,
renderer: function (storeItem, item) {
this.setTitle(storeItem.get('os') + ': ' + storeItem.get('data1') + '%');
}
}
}
});
}
});
I am trying to export highstock data to csv/xlsx and also view data table. But I do not get proper data when I download or view data. It exports the chart series data as well as the navigator series data.
Highcharts.stockChart('container_' + $scope.tileId, {
rangeSelector: {
selected: 1,
allButtonsEnabled: true,
inputEnabled: true,
buttons: [{
type: 'minute',
count: 60,
text: '1h'
}, {
type: 'day',
count: 1,
text: '1d'
}, {
type: 'week',
count: 1,
text: '1w'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}]
},
chart: {
width: null,
marginRight: 100
},
title: {
text: $scope.tileName
},
navigator: {
enabled: true
},
exporting: {
chartOptions: {
rangeSelector: {
enabled: false
}
},},
yAxis: {
title: { text: $scope.xAxisLabel }
},
plotOptions: {
},
xAxis: {
type: 'datetime'
},
legend: {
enabled: true,
align: 'center',
verticalAlign: 'bottom',
layout: 'horizontal',
},
series: $scope.seriesOptions
});
I am also using export-data.js as Highstock does not support export to excel directly.
data downloaded looks something like this
Now If I disable the navigator the exported data is correct.
The issue is I need to keep the Navigator enabled and not export the series data in the navigator but only the Chart series data.
According to this:
To prevent the navigator in a stock chart, set
navigator.series.includeInCSVExport to false.
Like this:
navigator: {
series: {
includeInCSVExport: false
}
}
I have a button in a panel, and I need set a margin value, but the component not apply the value of margin, the EXT just ignore the margin property.
The follow code:
Ext.define('CadastroEnsaioWTD.view.typecalculated.TypeCalculatedItem', {
extend: 'Maestro.panel.Panel',
requires: [
'Maestro.form.Button',
'Maestro.form.TextField',
'Maestro.form.ComboBox'
],
alias: 'widget.typecalculateditemview',
layout: {
type: 'hbox',
align: 'middle'
},
width: '100%',
height: '100%',
initComponent: function () {
var me = this;
var config = {
defaults: {
width: 200,
node: me.node,
margin: '5 5 5 5',
labelSeparator: '',
xtype: 'maestro.form.textfield'
},
items: [
{
xtype: 'label',
html: '<b>' + me.alias + '</b>',
width: 100
},
{
width: 300,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_DETERMINADO_CARACT'
},
{
xtype: 'maestro.form.combobox',
name: 'ENS_ENR_REFRIGERACAO_WTD'
},
{
name: 'ENS_PERC_CARGA_WTD'
},
{
name: 'ENS_COS_PHI'
},
{
width: 170,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_ENR_APL_WTD'
},
{
width: 170,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_ENR_CC_WTD'
},
{
name: 'ENS_ENR_TAP_TENSAO_APL'
},
{
name: 'ENS_ENR_TAP_TENSAO_CC'
},
{
name: 'ENS_POT_REF_WTD'
},
{
name: 'ENS_PERC_TENSAO_WTD'
},
{
width: 100,
name: 'ENS_TIPO_DETERMINADO_VAL'
},
{
width: 100,
xtype: 'maestro.form.combobox',
name: 'ENS_TIPO_DETERMINADO_UNID'
},
{
xtype: 'button',
text: '-',
width: 30,
style: 'border-radius: 7px;',
handler: function (btn) {
me.getObjectContextSynchronizer().executeServerRequest('deleteContextNode', [me.node]);
}
}
]
};
Ext.apply(this, config);
this.callParent();
}
});
And if I set the value by console of chrome after the component rendered, using Ext.getCmp('xxxx').setMargin('15 0 0 0') does not work, but if I use Ext.getCmp('xxxx').getEl().setMargin('15 0 0 0') works.
Did I do something wrong?
you should use style:'margin:5px;' instead of using margin property
You do it properly. I created working fiddle for you with button margins - Button & margin.
Try to play with it and repeat your issue.