Commit 169f5262 authored by Frank Bergmann's avatar Frank Bergmann

- added scatter diagram to general reporting components

parent d8ea608e
<if @project_count@ ge 2>
<div id=@diagram_id@></div>
<script type='text/javascript'>
Ext.require(['Ext.chart.*', 'Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit']);
window.store1 = Ext.create('Ext.data.JsonStore', {
fields: ['x_axis', 'y_axis', 'color', 'diameter', 'caption', 'url'],
data: @data_json;noquote@
});
function createHandler(fieldName) {
return function(sprite, record, attr, index, store) {
return Ext.apply(attr, {
radius: record.get('diameter'),
fill: record.get('color')
});
};
}
Ext.onReady(function () {
chart = new Ext.chart.Chart({
width: @diagram_width@,
height: @diagram_height@,
animate: true,
store: store1,
renderTo: '@diagram_id@',
axes: [{
@axis_y_title_json;noquote@
type: 'Numeric',
position: 'left',
fields: ['y_axis'],
grid: true
}, {
@axis_x_title_json;noquote@
type: 'Numeric',
position: 'bottom',
fields: ['x_axis']
}],
series: [{
type: 'scatter',
axis: 'left',
xField: 'x_axis',
yField: 'y_axis',
highlight: true,
markerConfig: { type: 'circle' },
renderer: createHandler('xxx'),
label: {
display: 'under',
field: 'caption',
'text-anchor': 'left',
color: '#000'
},
listeners: {
itemmousedown: function(obj) {
var url = obj.storeItem.data['url'];
window.open(url, "_blank");
}
},
tips: {
trackMouse: false,
anchor: 'right',
width: 200,
height: 50,
renderer: function(storeItem, item) {
var xTitle = '';
var yTitle = '';
if ("" != '@diagram_x_title;noquote@') { xTitle = '@diagram_x_title;noquote@='; }
if ("" != '@diagram_y_title;noquote@') { yTitle = '@diagram_y_title;noquote@='; }
this.setTitle(
"<a href='"+storeItem.get('url')+"' target='_blank'>" +
storeItem.get('caption') + ":<br>\n" +
xTitle + storeItem.get('x_axis') + ', ' +
yTitle + storeItem.get('y_axis') +
"</a>"
);
}
}
}]
}
)});
</script>
</if>
# /packages/sencha-reporting-portfolio/lib/scatter-diagram.tcl
#
# Copyright (C) 2011 ]project-open[
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
# ----------------------------------------------------------------------
#
# ---------------------------------------------------------------------
# The following variables are expected in the environment
# defined by the calling /tcl/*.tcl libary:
# program_id
# diagram_width
# diagram_height
# sql Defines the columns x_axis, y_axis, color and diameter
# Create a random ID for the diagram
set diagram_id "margin_tracker_[expr round(rand() * 100000000.0)]"
set x_axis 0
set y_axis 0
set color "yellow"
set diameter 5
set title ""
set axis_x_title_json ""
set axis_y_title_json ""
if {[info exists diagram_x_title] && "" ne $diagram_x_title} { set axis_x_title_json "title: '$diagram_x_title'," }
if {[info exists diagram_y_title] && "" ne $diagram_y_title} { set axis_y_title_json "title: '$diagram_y_title'," }
set data_list {}
set project_count 0
set url ""
db_foreach scatter_sql $sql {
if {$project_count > 10} { continue }
lappend data_list "{x_axis: $x_axis, y_axis: $y_axis, color: '$color', diameter: $diameter, caption: '$title', url: '$url'}"
incr project_count
}
set data_json "\[\n"
append data_json [join $data_list ",\n"]
append data_json "\n\]\n"
# ad_return_complaint 1 "<pre>$data_json</pre>"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment