Using ExtJS 4 charts in ExtJS 3 application - extjs

I'm trying to add Ext4 charting to an existing Ext3 application, using ext-all-sandbox.js. I've got the basics working, but the code below gives axis.processView is not a function. It works fine without the axes defined (but with no axes obviously).
It appears that the config objects are being used directly instead of being used to create actual axis instances. Any solutions to get this working?
TestGraphPanel = Ext.extend(Ext.Panel, {
initComponent: function() {
TestGraphPanel.superclass.initComponent.call(this);
Ext4.define('DataPoint', {
extend: 'Ext.data.Model',
fields: ['xValue', 'yValue']
});
this.store = Ext4.create('Ext.data.Store', {
model: 'DataPoint',
data: [
{xValue: 0, yValue: 2},
{xValue: 1, yValue: 4},
{xValue: 2, yValue: 7},
{xValue: 3, yValue: 5},
{xValue: 4, yValue: 8},
{xValue: 5, yValue: 9}
]
});
},
afterRender: function() {
Ext4.create('Ext.chart.Chart', {
renderTo: this.body.dom,
width: this.ownerCt.getWidth(),
height: this.ownerCt.getHeight(),
store: this.store,
axes: [
{
title: 'x',
type: 'Numeric',
postition: 'bottom',
fields: ['xValue']
},
{
title: 'y',
type: 'Numeric',
position: 'left',
fields: ['yValue']
}
],
series: [
{
type: 'line',
xField: 'xValue',
yField: 'yValue'
}
]
});
}
});

After a quick look at the source, I think your problem might come from the fact that you're creating your chart in the afterRender.
I'm thinking of those lines in particular
//process all views (aggregated data etc) on stores
//before rendering.
me.axes.each(function(axis) {
axis.processView();
});
The config objects are parsed just before. Otherwise try to set a breakpoint in there and check the objects.

Related

Highcharts: How to compare two series with different xAxis intervals in the same line chart

I'm trying to compare two different date interval data in a single chart by using 'linkedTo' attribute (in order to vanish and show two lines in a single click of a legend since they are related)
My problem: two series are automatically align themselves in the middle (Fiddle Link Here)
Here's my options:
Highcharts.chart('container', {
xAxis: [{
tickInterval: 1,
left: 0
},
{
type: 'datetime',
categories: ['4/18/2018', '4/19/2018', '4/20/2018', '4/21/2018', '4/22/2018', '4/23/2018'],
visible: false,
left: 0,
labels: {
formatter: function() {
return Highcharts.dateFormat('%b/%e/%Y', this.value);
}
}
},
{
type: 'datetime',
categories: ['5/2/2018', '5/3/2018', '5/4/2018'],
visible: false,
}
],
yAxis: [{
type: 'value',
visible: false
},
],
series: [{
name: 'instance1',
key: 'instance1',
type: 'line',
data: [1, 5, 2, 2, 8, 6
],
xAxis: 1
},
{
name: 'instance1 compared',
linkedTo: 'instance1',
dashStyle: 'shortdash',
type: 'line',
data: [
8, 3, 6
],
xAxis: 2
}
],
tooltip: {
crosshairs: true,
shared: true,
useHTML: true,
headerFormat: '<table><tr><th colspan="2">{point.key}</th></tr>',
pointFormat: '<tr><td>{series.name} </td> <td style="text-align: right"><b>{point.y}</b></td></tr>',
footerFormat: '</table>'
},
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>
What I want is something like here:
Where the days are ticked together and short serie is halted before the other one
I tried linking the two series in a single xAxis that tracks the day count as the picture. That partially worked to align the dots together but then I couldn't send the separate date data to tooltip. How can I format the tooltip?
Another solution I tried to find online is if there's any way I can link three data in highchart then I can use the day count as a single xAxis and put the date data in tooltip separately.
Ex: (125 clicks, 1/8/2022, Day: 2)
Add the max property to the xAxis with fewer categories, in order to match it to the other one.
xAxis: [{
tickInterval: 1
},
{
categories: categories1,
visible: false
},
{
categories: categories2,
max: categories1.length - 1,
visible: false
}
],
tooltip: {
crosshairs: true,
shared: true,
useHTML: true,
headerFormat: '<table><tr><th colspan="2">Day {point.point.x}</th></tr>',
pointFormat: '<tr><td>{point.category} </td> <td style="text-align: right"><b>{point.y}</b></td></tr>',
footerFormat: '</table>'
},
Demo:
https://jsfiddle.net/BlackLabel/naes6v89/
Another approach you mentioned would be possible to achieve by using series.keys (API: https://api.highcharts.com/highcharts/series.line.keys), but in this case, is not necessary. You need to only pass the category as a point.name, and then use the point.x value in tooltip.headerFormat
tooltip: {
crosshairs: true,
shared: true,
useHTML: true,
headerFormat: '<table><tr><th colspan="2">Day {point.x}</th></tr>',
pointFormat: '<tr><td>{point.name} </td> <td style="text-align: right"><b>{point.y}</b></td></tr>',
footerFormat: '</table>',
},
series: [{
name: 'instance1',
id: 'instance1',
data: [
['4/18/2018', 1],
['4/19/2018', 5],
['4/20/2018', 2],
['4/21/2018', 2]
],
},
{
name: 'instance1 compared',
linkedTo: 'instance1',
dashStyle: 'shortdash',
data: [
['5/2/2018', 8],
['5/3/2018', 3],
['5/4/2018', 6]
],
}
]
Demo:
https://jsfiddle.net/BlackLabel/8xsnr7c9/
P.S. Remember you need to use linkedTo with id, instead of key.
series: [{
name: 'instance1',
id: 'instance1',
data: [1, 5, 2, 2],
xAxis: 1
},
{
name: 'instance1 compared',
linkedTo: 'instance1',
dashStyle: 'shortdash',
data: [8, 3, 6],
xAxis: 2
}
]
API Reference:
https://api.highcharts.com/highcharts/series.line.linkedTo

Capture dynamic data from store EXTjs

I want to load data dynamically in a graph.
If my data is:
"data": [
{
"A": "11",
"DATE": "2018-02-07",
"B": "100"
},
{
"A": "12",
"DATE": "2018-03-04",
"B": "1"
}
]`
And the view part is
loadChart: function () {
var cha = this.down('#charid');
var iii = null;
Ext.Ajax.request({
url: utils.createUrl('api', 'dashboard-read'),
async: true,
callback: function(opts, success, response) {
try {
if (success) {
var fields = ['A', 'B'];
cha.series.clear();
for(var i=0;i<fields.length;i++){
cha.series.add({
type: 'line',
axis: 'left',
xField: 'DATE',
border: false,
flex: 1,
title: fields[i],
yField: fields[i],
markerConfig: {
radius: 4
},
}
What I need is instead of defining var fields = ['A', 'B']; in view have to push the data from the back end to the fields array dynamically. Because the backend may send different companies in different times. So can't hard coded them.
Use the following approach:
...
callback: function(opts, success, response) {
if (success) {
responseText.data.forEach(function(o){
cha.series.add({
type: 'line',
axis: 'left',
xField: 'DATE',
border: false,
flex: 1,
title: o.A,
yField: o.B,
markerConfig: {
radius: 4
}
});
});
}
}
...

Angular gantt customize data fields

Does angular gantt plugin allow to change the column header labels? I tried to change the side table headers but couldn't. If it doesn't allow what other gantt chart can I use? At the side table, I need to show work station, id and type. In the gannt chart, I need to show the particular ids under the respective priority numbers. Any suggestions, please?
You can change or defined the column header labels at property Options.
$scope.options = {
...
treeTableColumns: ['from', 'to', 'myColumn'],
columnsHeaders: { 'model.name': 'Name', 'from': 'From', 'to': 'To', 'myColumn': 'My column name' },
columnsClasses: { //css
'myColumn': 'myclass'
},
//defined content here. ex: String, checkbox, radio, ...
//ex: <input type="checkbox" id={{row.model.id}} ng-model="row.model.myColumn">
columnsContents: {
'myColumn': '{{row.model.myColumn}}',
...
},
};
$scope.myData = [{
id: 1,
name: 'Finalize concept',
myColumn: 'content',
tasks: [{
id: 'Finalize concept',
name: 'Finalize concept',
priority: 10,
color: '#F1C232',
from: new Date(2013, 9, 17, 8, 0, 0),
to: new Date(2013, 9, 18, 18, 0, 0),
progress: 100
}]
}, {
id: 2,
name: 'Development',
myColumn: 'content',
children: ['Sprint 1', 'Sprint 2', 'Sprint 3', 'Sprint 4'],
content: '<i class="fa fa-file-code-o" ng-click="scope.handleRowIconClick(row.model)"></i> {{row.model.name}}'
} ]
https://www.angular-gantt.com/configuration/attributes/
Here yo have the answer about all you can do.
You cant change the column header labels but you can select between all the formats that you have:
$scope.headersFormats = {
'year': 'YYYY',
'quarter': '[Q]Q YYYY',
month: 'MMMM YYYY',
week: 'w',
day: 'D',
hour: 'H',
minute:'HH:mm'
};

Highchart + Extjs + chart Updates

I setup this jsfiddle to show you an issue regarding Extjs and Highchart:
http://jsfiddle.net/xea0w8n3/21/
var store = new Ext.data.ArrayStore({
fields: ['month', 'value'],
data : [
['jan', 1],
['feb', 2],
['mar', 3],
['apr', 4],
['mai', 5],
['jun', 6],
['jul', 16],
['aug', 2],
['sep', 7],
['oct', 4],
['nov', 3],
['dec', 11]
]
});
var chart = Ext.create('Chart.ux.Highcharts', {
id:'chart',
series:[{
dataIndex: 'value'
}],
xField: 'month',
store: store,
chartConfig: {
chart: {
type: 'spline'
},
title: {
text: 'A simple graph'
},
xAxis: {
plotLines: [{
color: '#FF0000',
width: 5,
value: 'mar'
}]
}
}
});
store.load();
Ext.create('Ext.window.Window', {
title: 'Highchart Testing',
id:'window',
closable : true,
width: 300,
height: 400,
layout:'fit',
anchor:'100%',
items:[chart],
tbar:[
{
xtype:'button',
text:'Add PlotLine',
handler: function(){
Ext.getCmp('chart').chart.yAxis[0].addPlotLine({
value:'12',
width: '2',
dashStyle: 'longdashdot',
color: 'red'
});
}
}
]
}).show();
If I add a Plot Line and resize the window the line disappear :(
Any ideas to keep the plotline while window is open?
Thanks in advance!
Regards
I've had a similar issue with the line disappearing when I move the window. Does that also happen for you? I worked around the problem by hiding and showing the chart on the window's move event. It is a bit silly but it worked for me.
listeners: {
// For me it was the move event
resize: function (window) {
var chart = Ext.getCmp('chart');
chart.hide();
chart.show();
}
}

ExtJs 4.1.1 chart missing markers

I spent days trying to solve this one:
I'm trying to create a chart with several series. In one series I show a line with all points (in my code "val" series). In the second series I wish to show only part of the points ("temperature" series). Both series are showing a data type of int.
I tried to set a very low value to the "temperature" field in order to omit it from the chart but it also caused the respective "val" to be skipped!
In ExtJs 4.1.1: The 10am value of the "val" field is skipped.
In ExtJs 4.0.7: The 10am value of the "val" field exists!
(I wish I could post images here but I do not have 10 reputation points.:-( )
Here is my code:
Ext.define('WeatherPoint', {
extend: 'Ext.data.Model',
fields: ['temperature', 'date', 'val']
});
var store1 = Ext.create('Ext.data.Store', {
model: 'WeatherPoint',
data: [
{ temperature: 58, date: new Date(2011, 1, 1, 8), val: 10 },
{ temperature: 63, date: new Date(2011, 1, 1, 9), val: 20 },
{ temperature: -100, date: new Date(2011, 1, 1, 10), val: 40 },
{ temperature: 78, date: new Date(2011, 1, 1, 11), val: 90 },
{ temperature: 81, date: new Date(2011, 1, 1, 12), val: 50 }
]
});
var chart1 = Ext.create('Ext.chart.Chart',{
xtype: 'chart',
animate: false,
store: store1,
legend: true,
insetPadding: 30,
axes: [{
title: 'Temperature',
type: 'Numeric',
position: 'left',
fields: ['temperature', 'val'],
minimum: 0,
maximum: 100
}, {
title: 'Time',
type: 'Time',
position: 'bottom',
fields: ['date'],
dateFormat: 'ga',
step: [Ext.Date.HOUR, 1],
fromDate: new Date(2011, 1, 1, 8),
toDate: new Date(2011, 1, 1, 12)
}],
series: [{
type: 'scatter',
axis: ['left','bottom'],
xField: 'date',
yField: 'temperature'
}, {
type: 'line',
title: 'val',
axis: ['left','bottom'],
xField: 'date',
yField: 'val'
}]
});
var panel1 = Ext.create('widget.panel', {
width: 600,
height: 400,
renderTo: Ext.getBody(),
layout: 'fit',
items: chart1
});
Why 4.1.1 makes all series skip because of a value that is out-of-range in one series?
How can I show only part of the points in one series and all of the point in the second?
Try using null or empty '' values for points you want to hide.
Example:
var store1 = Ext.create('Ext.data.Store', {
model: 'WeatherPoint',
data: [
{ temperature: 58, date: new Date(2011, 1, 1, 8), val: 10 },
{ temperature: 63, date: new Date(2011, 1, 1, 9), val: 20 },
{ temperature: '', date: new Date(2011, 1, 1, 10), val: 40 },
{ temperature: 78, date: new Date(2011, 1, 1, 11), val: ''},
{ temperature: 81, date: new Date(2011, 1, 1, 12), val: 50 }
]
});

Resources