Beispiel #1
0
    def line_hollow(self, search_result, y_legend, line_text):
        #定义chart
        chart = openFlashChart.template(u'折线图')
        chart.set_y_legend(y_legend, style='{font-size: 12px}')  #设置y轴
        #横坐标
        x_labels = []
        for row in search_result:
            x_labels.append(row[0])
        chart.set_x_axis(colour='#736AFF',
                         three_d=5,
                         labels=x_axis_labels(labels=x_labels))

        row_num = len(search_result)  #共多少条记录
        column_num = len(search_result[0])  #每条记录有几列
        #取值
        mymax = 0

        for column_i in range(1, column_num):
            plot = Line()
            values = []
            for row in search_result:
                if int(row[column_i]) > mymax:
                    mymax = int(row[column_i])
                values.append(int(row[column_i]))
            plot.set_values(values=values)
            plot.set_colour(colorArr[column_i - 1])
            plot['on-show'] = dict([['type', 'shrink-in'], ['cascade', 1],
                                    ['delay', 0.5]])  #api中没有on-show 手动加上
            plot['dot-style'] = dict([['type', 'star'], ['colour', '#a44a80'],
                                      ['dot-size', 5]])  #api中没有dot-style 手动加上
            plot['text'] = line_text[column_i - 1]
            chart.add_element(plot)
            values = []
        chart.set_y_axis(min=0, max=mymax)
        return chart.encode()
Beispiel #2
0
	def line_hollow(self,search_result,y_legend,line_text):
		#定义chart
		chart = openFlashChart.template(u'折线图')
		chart.set_y_legend(y_legend, style = '{font-size: 12px}')#设置y轴
		#横坐标
		x_labels = []
		for row in search_result:
			x_labels.append(row[0])
		chart.set_x_axis(colour = '#736AFF', three_d = 5, labels = x_axis_labels(labels = x_labels))

		row_num = len(search_result)#共多少条记录
		column_num = len(search_result[0])#每条记录有几列
		#取值
		mymax = 0
		
		for column_i in range(1,column_num):
			plot = Line()
			values = []
			for row in search_result:
				if int(row[column_i]) > mymax:
					mymax = int(row[column_i])
				values.append(int(row[column_i]))
			plot.set_values(values=values)
			plot.set_colour(colorArr[column_i-1])
			plot['on-show'] = dict([['type','shrink-in'],['cascade',1],['delay',0.5]])#api中没有on-show 手动加上
			plot['dot-style'] = dict([['type','star'],['colour','#a44a80'],['dot-size',5]])#api中没有dot-style 手动加上
			plot['text'] = line_text[column_i-1]
			chart.add_element(plot)
			values = []
		chart.set_y_axis(min = 0, max = mymax)
		return chart.encode()
Beispiel #3
0
	def bar_3d(self,search_result,y_legend,column_text,org,time):
		#定义chart
		chart = openFlashChart.template(u''+time+'年'+org+'公司费用统计柱状图')
		chart.set_y_legend(y_legend, style = '{font-size: 12px}')#设置y轴
		#横坐标
		x_labels = []
		for row in search_result:
			x_labels.append(row[0])
		chart.set_x_axis(colour = '#736AFF', three_d = 5, labels = x_axis_labels(labels = x_labels))

		row_num = len(search_result)#共多少条记录
		column_num = len(search_result[0])#每条记录有几列
		#取值
		mymax = 0
		
		for column_i in range(1,column_num):
			plot = Bar_3d()
			values = []
			for row in search_result:
				if int(row[column_i]) > mymax:
					mymax = int(row[column_i])
				values.append(bar_3d_value(int(row[column_i]), colorArr[column_i-1]))
			plot.set_values(values=values)
			plot.set_colour(colorArr[column_i-1])
			plot['on-show'] = dict([['type','pop-up'],['cascade',1],['delay',0.5]])#api中没有on-show 手动加上
			plot['text'] = column_text[column_i-1]
			chart.add_element(plot)
			values = []
		chart.set_y_axis(min = 0, max = mymax)
		return chart.encode()
Beispiel #4
0
    def bar_stack(self):
        plot = Bar_Stack(colours=['#C4D318', '#50284A', '#7D7B6A'])
        plot.set_tooltip(
            'X label [#x_label#], Value [#val#]<br>Total [#total#]')
        plot.append_keys('#C4D318', 'job1', 13)
        plot.append_keys('#50284A', 'job2', 13)
        plot.append_keys('#7D7B6A', 'job3', 13)
        plot.append_keys('#ff0000', 'job4', 13)
        plot.append_keys('#ff00ff', 'job5', 13)

        plot.append_stack([2.5, 5, 2.5])
        plot.append_stack([2.5, 5, 1.25, 1.25])
        plot.append_stack([5, bar_stack_value(5, '#ff0000')])
        plot.append_stack([2, 2, 2, 2, bar_stack_value(2, '#ff00ff')])

        chart = openFlashChart.template(
            "Bar_Stack chart",
            style='{font-size: 20px; color: #F24062; text-align: center;}')
        chart.set_tooltip(behaviour='hover')
        chart.set_x_axis(labels=x_axis_labels(
            labels=['Winter', 'Spring', 'Summer', 'Autumn']))
        chart.set_y_axis(min=0, max=14, steps=2)
        chart.add_element(plot)

        return chart.encode()
Beispiel #5
0
    def bar_3d(self, search_result, y_legend, column_text, org, time):
        #定义chart
        chart = openFlashChart.template(u'' + time + '年' + org + '公司费用统计柱状图')
        chart.set_y_legend(y_legend, style='{font-size: 12px}')  #设置y轴
        #横坐标
        x_labels = []
        for row in search_result:
            x_labels.append(row[0])
        chart.set_x_axis(colour='#736AFF',
                         three_d=5,
                         labels=x_axis_labels(labels=x_labels))

        row_num = len(search_result)  #共多少条记录
        column_num = len(search_result[0])  #每条记录有几列
        #取值
        mymax = 0

        for column_i in range(1, column_num):
            plot = Bar_3d()
            values = []
            for row in search_result:
                if int(row[column_i]) > mymax:
                    mymax = int(row[column_i])
                values.append(
                    bar_3d_value(int(row[column_i]), colorArr[column_i - 1]))
            plot.set_values(values=values)
            plot.set_colour(colorArr[column_i - 1])
            plot['on-show'] = dict([['type', 'pop-up'], ['cascade', 1],
                                    ['delay', 0.5]])  #api中没有on-show 手动加上
            plot['text'] = column_text[column_i - 1]
            chart.add_element(plot)
            values = []
        chart.set_y_axis(min=0, max=mymax)
        return chart.encode()
Beispiel #6
0
	def area_hollow(self):
		plot = Area_Hollow(colour = '#838A96', fill = '#E01B49', fill_alpha = 0.4, values = [math.sin(float(x)/10) * 1.9 for x in range(0, 62, 2)])
		plot.set_halo_size(1)
		plot.set_width(2)
		plot.set_dot_size(4)
		
		chart = openFlashChart.template("Area_Hollow chart")
		chart.set_y_axis(min = -2, max = 2, steps = 2, offset = False)
		chart.set_x_axis(labels = x_axis_labels(rotate = 'diagonal'), steps = 2)
		chart.add_element(plot)
		
		return chart.encode()
Beispiel #7
0
	def area_line(self):
		plot = Area_Line(colour = '#C4B86A', fill = '#C4B86A', fill_alpha = 0.7, values = [math.sin(float(x)/10) * 1.9 for x in range(0, 62, 2)])
		plot.set_halo_size(1)
		plot.set_width(2)
		plot.set_dot_size(4)
		
		chart = openFlashChart.template("Area_Line chart")
		chart.set_y_axis(min = -2, max = 2, steps = 2, offset = True)
		chart.set_x_axis(labels = x_axis_labels(labels = ['%d' %i for i in range(0, 62, 2)], steps = 4, rotate = 'vertical'), steps = 2)
		chart.add_element(plot)
		
		return chart.encode()
Beispiel #8
0
	def hbar(self):
		months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
	
		plot = HBar(colour = '#86BBEF')
		plot.set_tooltip('Months: #val#')
		plot.append_values(hbar_value((0, 4), colour = '#909090'))
		plot.append_values(hbar_value((4, 8), colour = '#909009'))
		plot.append_values(hbar_value((8, 11), tooltip = '#left# to #right#<br>%s to %s (#val# months)' %(months[8], months[11])))
		
		chart = openFlashChart.template("HBar chart")
		chart.set_x_axis(offset = False, labels = x_axis_labels(labels = months))
		chart.set_y_axis(offset = True, labels = ['one', 'two', 'three'])
		chart.add_element(plot)
		
		return chart.encode()
Beispiel #9
0
    def area_hollow(self):
        plot = Area_Hollow(
            colour='#838A96',
            fill='#E01B49',
            fill_alpha=0.4,
            values=[math.sin(float(x) / 10) * 1.9 for x in range(0, 62, 2)])
        plot.set_halo_size(1)
        plot.set_width(2)
        plot.set_dot_size(4)

        chart = openFlashChart.template("Area_Hollow chart")
        chart.set_y_axis(min=-2, max=2, steps=2, offset=False)
        chart.set_x_axis(labels=x_axis_labels(rotate='diagonal'), steps=2)
        chart.add_element(plot)

        return chart.encode()
Beispiel #10
0
    def area_line(self):
        plot = Area_Line(
            colour='#C4B86A',
            fill='#C4B86A',
            fill_alpha=0.7,
            values=[math.sin(float(x) / 10) * 1.9 for x in range(0, 62, 2)])
        plot.set_halo_size(1)
        plot.set_width(2)
        plot.set_dot_size(4)

        chart = openFlashChart.template("Area_Line chart")
        chart.set_y_axis(min=-2, max=2, steps=2, offset=True)
        chart.set_x_axis(labels=x_axis_labels(
            labels=['%d' % i for i in range(0, 62, 2)],
            steps=4,
            rotate='vertical'),
                         steps=2)
        chart.add_element(plot)

        return chart.encode()
Beispiel #11
0
def _stacked_bars_graph(env, key, x_axis, query=None, title=None):
    ticket_stats, keys = _get_stacked_bar_chart_stats(env, key, x_axis, query)

    plot = Bar_Stack()

    # Add the keys to the plot
    key_colours = {}
    for i, key_value in enumerate(keys):
        key_colours[key_value] = COLOURS[i]
        if key:
            plot.append_keys(COLOURS[i], key_value, 13)

    for x_axis_value, tickets_per_key in ticket_stats.iteritems():
        stack = []
        for i, (key_value, number_of_tickets) in enumerate(tickets_per_key.iteritems()):
            stack.append(
                bar_stack_value(number_of_tickets, key_colours[key_value], _get_stacked_bar_tooltip(key, key_value))
            )
        plot.append_stack(stack)

    chart_div_id = _create_chart_div_id()
    on_click_function_name = "on_click_%s" % (chart_div_id,)
    plot["on-click"] = on_click_function_name
    plot["on-click-text"] = "#key#"

    if title is None:
        key_string = ""
        if key:
            key_string = " and %s" % (key,)
        title = "Tickets by %s%s" % (x_axis, key_string)

    chart = _create_chart(title, plot)
    if ticket_stats.keys():
        chart.set_x_axis(labels=x_axis_labels(labels=ticket_stats.keys(), size=13))
        chart.set_y_axis(min=0, max=_get_stacked_bar_max_y_value(ticket_stats))

    return (
        chart,
        chart_div_id,
        _create_stacked_bar_on_click_html(env, key, x_axis, ticket_stats, query, on_click_function_name),
    )
Beispiel #12
0
def _stacked_bars_graph(env, key, x_axis, query=None, title=None):
    ticket_stats, keys = _get_stacked_bar_chart_stats(env, key, x_axis, query)

    plot = Bar_Stack()

    # Add the keys to the plot
    key_colours = {}
    for i, key_value in enumerate(keys):
        key_colours[key_value] = COLOURS[i]
        if key:
            plot.append_keys(COLOURS[i], key_value, 13)

    for x_axis_value, tickets_per_key in ticket_stats.iteritems():
        stack = []
        for i, (key_value,
                number_of_tickets) in enumerate(tickets_per_key.iteritems()):
            stack.append(
                bar_stack_value(number_of_tickets, key_colours[key_value],
                                _get_stacked_bar_tooltip(key, key_value)))
        plot.append_stack(stack)

    chart_div_id = _create_chart_div_id()
    on_click_function_name = 'on_click_%s' % (chart_div_id, )
    plot['on-click'] = on_click_function_name
    plot['on-click-text'] = '#key#'

    if title is None:
        key_string = ''
        if key:
            key_string = ' and %s' % (key, )
        title = 'Tickets by %s%s' % (x_axis, key_string)

    chart = _create_chart(title, plot)
    if ticket_stats.keys():
        chart.set_x_axis(
            labels=x_axis_labels(labels=ticket_stats.keys(), size=13))
        chart.set_y_axis(min=0, max=_get_stacked_bar_max_y_value(ticket_stats))

    return chart, chart_div_id, \
           _create_stacked_bar_on_click_html(env, key, x_axis, ticket_stats,
                                             query, on_click_function_name)
Beispiel #13
0
	def bar_stack(self):
		plot = Bar_Stack(colours = ['#C4D318', '#50284A', '#7D7B6A'])
		plot.set_tooltip('X label [#x_label#], Value [#val#]<br>Total [#total#]')
		plot.append_keys('#C4D318', 'job1', 13)
		plot.append_keys('#50284A', 'job2', 13)
		plot.append_keys('#7D7B6A', 'job3', 13)
		plot.append_keys('#ff0000', 'job4', 13)
		plot.append_keys('#ff00ff', 'job5', 13)
		
		plot.append_stack([2.5, 5, 2.5])
		plot.append_stack([2.5, 5, 1.25, 1.25])
		plot.append_stack([5, bar_stack_value(5, '#ff0000')])
		plot.append_stack([2, 2, 2, 2, bar_stack_value(2, '#ff00ff')])
		
		chart = openFlashChart.template("Bar_Stack chart", style = '{font-size: 20px; color: #F24062; text-align: center;}')
		chart.set_tooltip(behaviour = 'hover')
		chart.set_x_axis(labels = x_axis_labels(labels = ['Winter', 'Spring', 'Summer', 'Autumn']))
		chart.set_y_axis(min = 0, max = 14, steps = 2)
		chart.add_element(plot)
		
		return chart.encode()
Beispiel #14
0
    def hbar(self):
        months = [
            'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
            'Oct', 'Nov', 'Dec'
        ]

        plot = HBar(colour='#86BBEF')
        plot.set_tooltip('Months: #val#')
        plot.append_values(hbar_value((0, 4), colour='#909090'))
        plot.append_values(hbar_value((4, 8), colour='#909009'))
        plot.append_values(
            hbar_value((8, 11),
                       tooltip='#left# to #right#<br>%s to %s (#val# months)' %
                       (months[8], months[11])))

        chart = openFlashChart.template("HBar chart")
        chart.set_x_axis(offset=False, labels=x_axis_labels(labels=months))
        chart.set_y_axis(offset=True, labels=['one', 'two', 'three'])
        chart.add_element(plot)

        return chart.encode()
def getjsondata(context, records=10, type=None):
    site_encoding = context.plone_utils.getSiteEncoding()
    strpath = "/".join(context.getPhysicalPath())
    portal = context.portal_url.getPortalObject()

    try:
        from ubify.policy.config import contentroot_details
        rootid = contentroot_details['id']
        objRoot = getattr(portal, rootid)
        if context == objRoot:
            strpath = "/".join(portal.getPhysicalPath())
        else:
            strpath = "/".join(context.getPhysicalPath())
    except AttributeError:
        strpath = "/".join(context.getPhysicalPath())

    if type is None:
        raise "No chart type was passed"
    elif type.lower() == "topcontributors":
        chart = template('')
        plot = HBar()
        results = getTopContributors(context, strpath)[:records]
        results.sort(lambda x, y: cmp(x['count'], y['count']), reverse=True)
        objvalues = [k['count'] for k in results if k['count'] > 0]

        users = [j['userid'] for j in results if j['count'] > 0]
        users.reverse()

        xlabels = x_axis_labels()
        xlabels.set_colour("#666666")
        chartsteps = 1.0
        if len(objvalues) > 0:
            chartsteps = getchartsteps(objvalues[-1], objvalues[0])
        chart.set_x_axis(offset=False,
                         labels=xlabels,
                         steps=chartsteps,
                         colour="#cccccc",
                         grid_colour="#f1f1f1")
        chart.set_y_axis(offset=True,
                         labels=users,
                         colour="#666666",
                         grid_colour="#f1f1f1")

        for val in objvalues:
            plot.append_values(
                hbar_value((0, val),
                           tooltip='#right# contributions',
                           colour='#4092D8'))
        chart.add_element(plot)
        chart.set_tooltip(
            stroke=1,
            colour="#1f1f1f",
            bg_colour="#292929",
            title_style="font-size:12px;color:#ffffff;font-weight:bold",
            body_style="font-size:12px;color:#ffffff",
            behaviour="hover")

        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    elif type.lower() == "topcommenters":
        chart = template('')
        plot = HBar()
        results = getTopCommenter(context, strpath)[:records]
        results.sort(lambda x, y: cmp(x['count'], y['count']), reverse=True)
        objvalues = [k['count'] for k in results if k['count'] > 0]

        users = [j['userid'] for j in results if j['count'] > 0]
        users.reverse()

        xlabels = x_axis_labels()
        xlabels.set_colour("#666666")
        chartsteps = 1.0
        if len(objvalues) > 0:
            chartsteps = getchartsteps(objvalues[-1], objvalues[0])
        chart.set_x_axis(offset=False,
                         labels=xlabels,
                         steps=chartsteps,
                         colour="#cccccc",
                         grid_colour="#f1f1f1")
        chart.set_y_axis(offset=True,
                         labels=users,
                         colour="#666666",
                         grid_colour="#f1f1f1")

        for val in objvalues:
            plot.append_values(
                hbar_value((0, val),
                           tooltip='#right# comments',
                           colour='#57AC0B'))
        chart.add_element(plot)
        chart.set_tooltip(
            stroke=1,
            colour="#1f1f1f",
            bg_colour="#292929",
            title_style="font-size:12px;color:#ffffff;font-weight:bold",
            body_style="font-size:12px;color:#ffffff",
            behaviour="hover")

        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    elif type.lower() == "contentstats":
        #For pie chart
        results = [
            k for k in getContentItemsCount(context, strpath) if k['count'] > 0
        ]
        results.sort(lambda x, y: cmp(x['count'], y['count']), reverse=True)

        chart = template('')
        plot = Pie(start_angle=35,
                   animate=True,
                   values=[
                       pie_value(val=k['count'], label=(k['id'], None, None))
                       for k in results
                   ],
                   colours=[
                       '#4092D8',
                       '#57AC0B',
                       '#CC0000',
                       '#862DFF',
                       '#FF6600',
                       '#00FFF6',
                       '#FF37D2',
                       '#5251ff',
                       '#F0EA80',
                       '#abff00',
                   ],
                   label_colour='#666666')
        plot.set_tooltip('#label#: #val# of #total#<br>#percent# of 100%')
        plot.set_gradient_fill(True)
        plot.set_no_labels(False)

        chart.add_element(plot)
        chart.set_tooltip(
            stroke=1,
            colour="#1f1f1f",
            bg_colour="#292929",
            title_style="font-size:12px;color:#ffffff;font-weight:bold",
            body_style="font-size:12px;color:#ffffff",
            behaviour="hover")
        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    else:
        raise "Unknown chart type was passed"
Beispiel #16
0
def getjsondata(context,records=10,type=None):
    site_encoding = context.plone_utils.getSiteEncoding()
    strpath = "/".join(context.getPhysicalPath())
    portal = context.portal_url.getPortalObject()
    
    try:
        from ubify.policy.config import contentroot_details
        rootid = contentroot_details['id']                
        objRoot = getattr(portal,rootid)
        if context == objRoot:
            strpath = "/".join(portal.getPhysicalPath())            
        else:
            strpath = "/".join(context.getPhysicalPath())            
    except AttributeError:
        strpath = "/".join(context.getPhysicalPath())
        
    if type is None:
        raise "No chart type was passed"
    elif type.lower() == "topcontributors":
        chart = template('')
        plot = HBar()
        results = getTopContributors(context,strpath)[:records]
        results.sort(lambda x,y: cmp(x['count'],y['count']),reverse=True)
        objvalues = [k['count'] for k in results if k['count'] > 0]

        users = [j['userid'] for j in results if j['count'] > 0]
        users.reverse()

        xlabels = x_axis_labels()
        xlabels.set_colour("#666666")
        chartsteps = 1.0
        if len(objvalues) > 0:
            chartsteps = getchartsteps(objvalues[-1],objvalues[0])
        chart.set_x_axis(offset = False, labels = xlabels,steps = chartsteps,colour="#cccccc",grid_colour="#f1f1f1")
        chart.set_y_axis(offset=True,labels = users,colour="#666666",grid_colour="#f1f1f1")

        for val in objvalues:
            plot.append_values(hbar_value((0, val), tooltip = '#right# contributions', colour = '#4092D8'))
        chart.add_element(plot)
        chart.set_tooltip(stroke=1,colour="#1f1f1f",bg_colour="#292929",title_style="font-size:12px;color:#ffffff;font-weight:bold",body_style="font-size:12px;color:#ffffff",behaviour="hover")

        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    elif type.lower() == "topcommenters":
        chart = template('')
        plot = HBar()
        results = getTopCommenter(context,strpath)[:records]
        results.sort(lambda x,y: cmp(x['count'],y['count']),reverse=True)
        objvalues = [k['count'] for k in results if k['count'] > 0]

        users = [j['userid'] for j in results if j['count'] > 0]
        users.reverse()

        xlabels = x_axis_labels()
        xlabels.set_colour("#666666")
        chartsteps = 1.0
        if len(objvalues) > 0:
            chartsteps = getchartsteps(objvalues[-1],objvalues[0])
        chart.set_x_axis(offset = False, labels = xlabels,steps = chartsteps,colour="#cccccc",grid_colour="#f1f1f1")
        chart.set_y_axis(offset=True,labels = users,colour="#666666",grid_colour="#f1f1f1")
        
        for val in objvalues:
            plot.append_values(hbar_value((0, val), tooltip = '#right# comments', colour = '#57AC0B'))
        chart.add_element(plot)
        chart.set_tooltip(stroke=1,colour="#1f1f1f",bg_colour="#292929",title_style="font-size:12px;color:#ffffff;font-weight:bold",body_style="font-size:12px;color:#ffffff",behaviour="hover")

        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    elif type.lower() == "contentstats":
        #For pie chart
        results = [k for k in getContentItemsCount(context,strpath) if k['count'] > 0]
        results.sort(lambda x,y: cmp(x['count'],y['count']),reverse=True)

        chart = template('')
        plot = Pie(start_angle = 35, animate = True, values = [pie_value(val = k['count'],label = (k['id'],None, None)) for k in results],colours = ['#4092D8', '#57AC0B', '#CC0000', '#862DFF', '#FF6600',  '#00FFF6','#FF37D2', '#5251ff', '#F0EA80', '#abff00',], label_colour = '#666666')
        plot.set_tooltip('#label#: #val# of #total#<br>#percent# of 100%')
        plot.set_gradient_fill(True)
        plot.set_no_labels(False)

        chart.add_element(plot)
        chart.set_tooltip(stroke=1,colour="#1f1f1f",bg_colour="#292929",title_style="font-size:12px;color:#ffffff;font-weight:bold",body_style="font-size:12px;color:#ffffff",behaviour="hover")
        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    else:
        raise "Unknown chart type was passed"
Beispiel #17
0
	def ajax(self, count):
		if int(count) % 3 is 0:
			plot = Line_Dot(text = "line1", fontsize = 20, values = [None, 5, dot_value(1, '#D02020', '#val#<br>Text'), 2, 4, None, None, 2, 7, 5])
		elif int(count) % 3 is 1:
			plot = Line(text = "line2", fontsize = 12, values = range(-4, 7, 1))
		else:
			plot = Bar_Glass(text = "bar1", values = [4, None, -4, 3, bar_glass_value((5, -2), '#333333', 'Special:<br>Top = #top#<br>Bottom = #bottom#'), 7, None, None, -5, 5])
				
		plot.set_tooltip('Title1:<br>Amount = #val#')
		plot.set_on_click('plot1')
		plot.set_line_style(4, 3)
		
		plot.set_colour('#D4C345')
		
		chart = openFlashChart.template("Testing chart: %s" %count, style = '{font-size: 40px; font-family: Times New Roman; color: #A2ACBA; text-align: right;}')

		chart.set_x_axis(stroke = 10, colour = '#165132', tick_height = 30, grid_colour = '#AAEE00', offset = True, steps = 2, labels = x_axis_labels(labels = list('sfwertr56w') + [x_axis_label('custom!!', '#2683CF', 24, 210)], steps = 2))
		chart.set_y_axis(stroke = 5, colour = '#1E33FF', tick_length = 15, grid_colour = '#090305', offset = True, steps = 4, min = -6)
		chart.set_y_axis_right(stroke = 5, colour = '#44FF22', tick_length = 20, grid_colour = '#55ff55', offset = True, steps = 1)

		chart.set_x_legend("x-axis legend", style = '{font-size: 20px; color: #778877}')
		chart.set_y_legend("y-axis legend", style = '{font-size: 22px; color: #778877}')

		chart.set_tooltip(shadow = True, stroke = 4, colour = '#909090', bg_colour = '#FAFAFA', title_style = '{font-size: 14px; color: #CC2A43;}', body_style = '{font-size: 10px; font-weight: bold; color: #000000;}')
		
		chart.add_element(plot)

		return chart.encode()
    def ilp_filtered_bar_stack_0(self):
        event_codes = {'GPU_Arrival':              '#FF6600',
                       'Handler_Deposites_Chocks': '#50284A',
                       'Aircraft_Arrival':         '#339900',
                       'Jet_Bridge_Positioning':   '#6699CC',
                       #'Container_Front_Unloading':'#660000',
                       #'Container_Front_Loading':  '#CC3333',
                       'Push_Back_Positioning':    '#FFF000',
                       #'Container_Back_Loading':   '#FF3333',
                       'Jet_Bridge_Parking':       '#0066CC',
                       'Aircraft_Departure':       '#99FF33',
                       'VRAC_Back_Unloading':      '#FF99FF',
                       #'Refuelling':               '#FF6600',
                       'VRAC_Back_Loading':        '#9933FF',
                       'No_Event':                 '#FFFFFF' 
                       }

        plot = Bar_Stack(colours = ['#C4D318', '#50284A', '#7D7B6A','#ff0000','#ff00ff'])
    
        for eve in event_codes:
            plot.append_keys(event_codes[eve], eve, 13)

        vid = 0    
        # Get ground truth
        gt_file = '/usr/not-backed-up/cofriend/data/progol/clean_qtc/global_model_ILP/' + 'ground_truth.p';     
        gt = pickle.load(open(gt_file))
        gt_event_lists = gt['event_lists']
        # Only add first video ground truth
        videos = [gt_event_lists[vid]]
        
        # Now the retrieved events
        ilp_file = '/usr/not-backed-up/cofriend/data/progol/clean_qtc/new_gt_with_zone_1protos_oct/' + 'retrieved_ins_ILP_vis_filtered_events_0.p';
        re = pickle.load(open(ilp_file))
        re_event_ins_lists = re['event_lists']
        ind = 0
        for e in re_event_ins_lists:
            videos.append(e)
            ind += 1
            if ind > 7:
                break
                      
        ind = 0
        for e in videos:
            e.sort()
            # val for each strip in a stack is just the length of the strip.
            # So just keep on laying strips in the stack with length equal to length of interval
            # First start with empty event
            stack   = []            
            val     = e[0][0]
            colour  = event_codes['No_Event']
            tooltip = '(%d, %d)' %(0, e[0][0])
            stack.append(bar_stack_value(val, colour, tooltip))
        
            for i in range(len(e)):                
                val = e[i][1] - e[i][0]
                colour = event_codes.get(e[i][2],'#FFFFFF')
                tooltip = '%s <br> Intv: (%d, %d)' %(e[i][2], e[i][0], e[i][1])
                stack.append(bar_stack_value(val, colour, tooltip))
                
                if i != len(e) - 1:
                    # Add empty event after every event
                    val = e[i+1][0] - e[i][1]
                    colour  = event_codes['No_Event']
                    tooltip = '(%d, %d)' %(e[i][1], e[i+1][0])
                    stack.append(bar_stack_value(val, colour, tooltip))
            ind += 1
                   
            plot.append_stack(stack)
            
        chart = openFlashChart.template("ILP Video One", style = '{font-size: 20px; color: #F24062; text-align: center;}')
        chart.set_tooltip(behaviour = 'hover')
        chart.set_bg_colour('#FFFFFF')

        # Prepare x_lables
        xlabels = []
        for i in xrange(len(videos)):
            if i == 0:
                xlabels.append('GT')
            else:    
                xlabels.append('ins_' + repr(i))            
            
        chart.set_x_axis(labels = x_axis_labels(labels = xlabels))
        chart.set_y_axis(min = 0, max = 35000, steps = 500)
        chart.add_element(plot)

        return chart.encode()
Beispiel #19
0
    def my_bar_stack(self):
        event_codes = {'GPU_Arrival':              '#FF6600',
                       'Handler_Deposites_Chocks': '#50284A',
                       'Aircraft_Arrival':         '#339900',
                       'Jet_Bridge_Positioning':   '#6699CC',
                       'Container_Front_Unloading':'#660000',
                       'Container_Front_Loading':  '#CC3333',
                       'Push_Back_Positioning':    '#FFF000',
                       'Container_Back_Loading':   '#FF3333',
                       'Jet_Bridge_Parking':       '#0066CC',
                       'Aircraft_Departure':       '#99FF33',
                       'VRAC_Back_Unloading':      '#FF99FF',
                       'Refuelling':               '#FF6600',
                       'VRAC_Back_Loading':        '#9933FF',
                       'No_Event':                 '#CCCCCC' 
                       }
        gt_file = '/usr/not-backed-up/cofriend/data/progol/clean_qtc/global_model/' + 'ground_truth.p';     
        gt = pickle.load(open(gt_file))
        gt_event_lists = gt['event_lists']
    
        plot = Bar_Stack(colours = ['#C4D318', '#50284A', '#7D7B6A','#ff0000','#ff00ff'])
        
        for eve in event_codes:
            plot.append_keys(event_codes[eve], eve, 13)

        videos = gt_event_lists
        for e in videos:
            # val for each strip in a stack is just the length of the strip.
            # So just keep on laying strips in the stack with length equal to length of interval
            # First start with empty event
            stack   = []            
            val     = e[0][0]
            colour  = event_codes['No_Event']
            tooltip = '(%d, %d)' %(0, e[0][0])
            stack.append(bar_stack_value(val, colour, tooltip))
            

            for i in range(len(e)):
                val = e[i][1] - e[i][0]
                colour = event_codes[e[i][2]]
                tooltip = '%s <br> Intv: (%d, %d)' %(e[i][2], e[i][0], e[i][1])
                stack.append(bar_stack_value(val, colour, tooltip))
                
                if i != len(e) - 1:
                    # Add empty event after every event
                    val = e[i+1][0] - e[i][1]
                    colour  = event_codes['No_Event']
                    tooltip = '(%d, %d)' %(e[i][1], e[i+1][0])
                    stack.append(bar_stack_value(val, colour, tooltip))
                   
            plot.append_stack(stack)
            
        chart = openFlashChart.template("Ground Truth", style = '{font-size: 20px; color: #F24062; text-align: center;}')
        chart.set_tooltip(behaviour = 'hover')
        chart.set_bg_colour('#FFFFFF')

        # Prepare x_lables
        xlabels = []
        for i in xrange(len(videos)):
            xlabels.append('vid_' + repr(i))            
            
        chart.set_x_axis(labels = x_axis_labels(labels = xlabels))
        chart.set_y_axis(min = 0, max = 35000, steps = 500)
        chart.add_element(plot)

        return chart.encode()
Beispiel #20
0
    def ajax(self, count):
        if int(count) % 3 is 0:
            plot = Line_Dot(text="line1",
                            fontsize=20,
                            values=[
                                None, 5,
                                dot_value(1, '#D02020', '#val#<br>Text'), 2, 4,
                                None, None, 2, 7, 5
                            ])
        elif int(count) % 3 is 1:
            plot = Line(text="line2", fontsize=12, values=range(-4, 7, 1))
        else:
            plot = Bar_Glass(
                text="bar1",
                values=[
                    4, None, -4, 3,
                    bar_glass_value(
                        (5, -2), '#333333',
                        'Special:<br>Top = #top#<br>Bottom = #bottom#'), 7,
                    None, None, -5, 5
                ])

        plot.set_tooltip('Title1:<br>Amount = #val#')
        plot.set_on_click('plot1')
        plot.set_line_style(4, 3)

        plot.set_colour('#D4C345')

        chart = openFlashChart.template(
            "Testing chart: %s" % count,
            style=
            '{font-size: 40px; font-family: Times New Roman; color: #A2ACBA; text-align: right;}'
        )

        chart.set_x_axis(stroke=10,
                         colour='#165132',
                         tick_height=30,
                         grid_colour='#AAEE00',
                         offset=True,
                         steps=2,
                         labels=x_axis_labels(
                             labels=list('sfwertr56w') +
                             [x_axis_label('custom!!', '#2683CF', 24, 210)],
                             steps=2))
        chart.set_y_axis(stroke=5,
                         colour='#1E33FF',
                         tick_length=15,
                         grid_colour='#090305',
                         offset=True,
                         steps=4,
                         min=-6)
        chart.set_y_axis_right(stroke=5,
                               colour='#44FF22',
                               tick_length=20,
                               grid_colour='#55ff55',
                               offset=True,
                               steps=1)

        chart.set_x_legend("x-axis legend",
                           style='{font-size: 20px; color: #778877}')
        chart.set_y_legend("y-axis legend",
                           style='{font-size: 22px; color: #778877}')

        chart.set_tooltip(
            shadow=True,
            stroke=4,
            colour='#909090',
            bg_colour='#FAFAFA',
            title_style='{font-size: 14px; color: #CC2A43;}',
            body_style='{font-size: 10px; font-weight: bold; color: #000000;}')

        chart.add_element(plot)

        return chart.encode()