Example #1
0
	def bar(self):
		plot = Bar(text = "bar1", values = range(9, 0, -1))
		
		chart = openFlashChart.template("Bar chart")
		chart.add_element(plot)

		return chart.encode()	
Example #2
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()
Example #3
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()
Example #4
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()
Example #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()
Example #6
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()
Example #7
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()
Example #8
0
    def line_hollow(self):
        plot1 = Line_Hollow(values=[
            math.sin(float(x) / 10) * 1.9 + 4 for x in range(0, 62, 2)
        ])
        plot2 = Line_Hollow(values=[
            math.sin(float(x) / 10) * 1.9 + 7 for x in range(0, 62, 2)
        ])
        plot3 = Line_Hollow(values=[
            math.sin(float(x) / 10) * 1.9 + 10 for x in range(0, 62, 2)
        ])

        plot1.set_halo_size(3)
        plot2.set_halo_size(1)
        plot3.set_halo_size(0)

        plot1.set_width(1)
        plot2.set_width(2)
        plot3.set_width(3)

        plot1.set_dot_size(4)
        plot2.set_dot_size(4)
        plot3.set_dot_size(6)

        chart = openFlashChart.template("Line_Hollow chart")
        chart.set_y_axis(min=0, max=15, steps=5)
        chart.add_element(plot1)
        chart.add_element(plot2)
        chart.add_element(plot3)

        return chart.encode()
Example #9
0
    def bar(self):
        plot = Bar(text="bar1", values=range(9, 0, -1))

        chart = openFlashChart.template("Bar chart")
        chart.add_element(plot)

        return chart.encode()
Example #10
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()
Example #11
0
	def bar_filled(self):
		plot = Bar_Filled(values = range(9, 0, -1) + [bar_value((5, 3), '#AAAAAA', 'Special:<br>Top = #top#<br>Bottom = #bottom#')], colour = '#E2D66A', outline = '#577261')
		
		chart = openFlashChart.template("Bar_Filled chart",)
		chart.add_element(plot)
		chart.set_bg_colour('#FFFFFF')

		return chart.encode()
Example #12
0
	def bar_filled(self):
		plot = Bar_Filled(values = range(9, 0, -1) + [bar_value((5, 3), '#AAAAAA', 'Special:<br>Top = #top#<br>Bottom = #bottom#')], colour = '#E2D66A', outline = '#577261')
		
		chart = openFlashChart.template("Bar_Filled chart",)
		chart.add_element(plot)
		chart.set_bg_colour('#FFFFFF')

		return chart.encode()
Example #13
0
	def bar_glass(self):
		plot = Bar_Glass(values = range(-5, 5, 2) + [bar_glass_value(5, '#333333', 'Special:<br>Top = #top#<br>Bottom = #bottom#')])
		
		chart = openFlashChart.template("Bar_Glass chart")
		chart.set_y_axis(min = -6, max = 6)
		chart.add_element(plot)
		
		return chart.encode()
Example #14
0
	def bar_glass(self):
		plot = Bar_Glass(values = range(-5, 5, 2) + [bar_glass_value(5, '#333333', 'Special:<br>Top = #top#<br>Bottom = #bottom#')])
		
		chart = openFlashChart.template("Bar_Glass chart")
		chart.set_y_axis(min = -6, max = 6)
		chart.add_element(plot)
		
		return chart.encode()
Example #15
0
	def bar_sketch(self):
		plot1 = Bar_Sketch(values = range(10, 0, -1) + [bar_sketch_value(5, '#333333', 'Special:<br>Top = #top#')], colour = '#81AC00', outline = '#567300')
		plot2 = Bar_Sketch(values = [bar_sketch_value(5, '#333333', 'Special:<br>Top = #top#')] + range(10, 0, -1), colour = '#81ACFF', outline = '#5673FF')
		
		chart = openFlashChart.template("Bar_Sketch chart", style = '{color: #567300; font-size: 14px}')
		chart.add_element(plot1)
		chart.add_element(plot2)
		
		return chart.encode()
Example #16
0
	def bar_sketch(self):
		plot1 = Bar_Sketch(values = range(10, 0, -1) + [bar_sketch_value(5, '#333333', 'Special:<br>Top = #top#')], colour = '#81AC00', outline = '#567300')
		plot2 = Bar_Sketch(values = [bar_sketch_value(5, '#333333', 'Special:<br>Top = #top#')] + range(10, 0, -1), colour = '#81ACFF', outline = '#5673FF')
		
		chart = openFlashChart.template("Bar_Sketch chart", style = '{color: #567300; font-size: 14px}')
		chart.add_element(plot1)
		chart.add_element(plot2)
		
		return chart.encode()
Example #17
0
	def bar_3d(self):
		plot = Bar_3d(values = range(-8, 8, 2) + [bar_3d_value(5, '#333333', 'Special:<br>Top = #top#<br>Bottom = #bottom#')])
		plot.set_colour('#D54C78')
		
		chart = openFlashChart.template("Bar_3d chart")
		chart.set_y_axis(min = -8, max = 8)
		chart.set_x_axis(colour = '#909090', three_d = 5, labels = list('qp#m^fur'))
		chart.add_element(plot)
		
		return chart.encode()
Example #18
0
	def bar_3d(self):
		plot = Bar_3d(values = range(-8, 8, 2) + [bar_3d_value(5, '#333333', 'Special:<br>Top = #top#<br>Bottom = #bottom#')])
		plot.set_colour('#D54C78')
		
		chart = openFlashChart.template("Bar_3d chart")
		chart.set_y_axis(min = -8, max = 8)
		chart.set_x_axis(colour = '#909090', three_d = 5, labels = list('qp#m^fur'))
		chart.add_element(plot)
		
		return chart.encode()
Example #19
0
def get_chart(request,style,date_start,date_end):
    raw_data = get_chart_vars(request,date_start,date_end)
    var1 = []
    var2 = []
    dates = []
    if raw_data['variable1'] != None:
        var_legend = raw_data['variable1_name']
        for items in raw_data['variable1']:
            var1.append(int(items[1]))
            dates.append(str(items[0]))
    if raw_data['variable2'] != None:
        var_legend = raw_data['variable2_name']
        for items in raw_data['variable2']:
            var2.append(int(items[1]))	
    chart = openFlashChart.template('')
    chart.set_bg_colour(colour='#ffffff')
    if len(var1) > 0:
        range_y1_min = round(min(var1)*0.95,0)
        range_y1_max = round(max(var1)*1.05,0)
        range_y1_steps = round(round(max(var1)*1.05,0)/10,0)
    else:
        range_y1_min = 0
        range_y1_max = 0
        range_y1_steps = 0
    if len(var2) > 0:
        range_y2_min = round(min(var2)*0.95,0)
        range_y2_max = round(max(var2)*1.05,0)
        range_y2_steps = round(round(max(var2)*1.05,0)/10,0)
    else:
        range_y2_min = 0
        range_y2_max = 0
        range_y2_steps = 0
    chart.set_y_axis(min = range_y1_min, max = range_y1_max, steps = range_y1_steps)
    chart.set_x_axis(labels = {'labels':dates, 'rotate':'vertical'})
    if style == 'lines':
        plot1 = Line(text = raw_data['variable1_name'], fontsize = 20, values = var1)
        plot2 = Line(text = raw_data['variable2_name'], fontsize = 20, values = var2)
        plot2['axis'] = "right"
        plot2.set_colour('#54b928')
        chart.set_y_axis_right(min = range_y2_min, max = range_y2_max, steps = range_y2_steps)
        if request.GET.get('onevar',None) == None:
            chart.add_element(plot2)
    elif style == 'pie':
        plot1 = Pie(text = raw_data['variable1_name'], fontsize = 20, values = var1, colours = ['#4f8dbc','#54b928'])
    elif style == 'columns':
        plot1 = Bar_Filled(text = raw_data['variable1_name'], fontsize = 20, values = var1)
        plot2 = Bar_Filled(text = raw_data['variable2_name'], fontsize = 20, values = var2)
        plot2['axis'] = "right"
        plot2.set_colour('#54b928')		
        chart.set_y_axis_right(min = range_y2_min, max = range_y2_max, steps = range_y2_steps)
        if request.GET.get('onevar',None) == None:
            chart.add_element(plot2)
    plot1.set_colour('#4f8dbc')
    chart.add_element(plot1)
    return HttpResponse(chart.encode())
Example #20
0
	def pie(self):
		plot = Pie(start_angle = 35, animate = True, values = [2, 3, pie_value(6.5, ('hello (6.5)', '#FF33C9', 24))], colours = ['#D01F3C', '#356AA0', '#C79810'], label_colour = '#432BAF')
		plot.set_tooltip('#val# of #total#<br>#percent# of 100%')
		plot.set_gradient_fill(True)
		plot.set_on_click('plot1')
		plot.set_no_labels(False)
		
		chart = openFlashChart.template("Pie chart")
		chart.add_element(plot)
		
		return chart.encode()
Example #21
0
	def pie(self):
		plot = Pie(start_angle = 35, animate = True, values = [2, 3, pie_value(6.5, ('hello (6.5)', '#FF33C9', 24))], colours = ['#D01F3C', '#356AA0', '#C79810'], label_colour = '#432BAF')
		plot.set_tooltip('#val# of #total#<br>#percent# of 100%')
		plot.set_gradient_fill(True)
		plot.set_on_click('plot1')
		plot.set_no_labels(False)
		
		chart = openFlashChart.template("Pie chart")
		chart.add_element(plot)
		
		return chart.encode()
Example #22
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()
Example #23
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()
Example #24
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()
Example #25
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()
Example #26
0
	def radar(self):
		plot = Area_Hollow(colour = '#45909F', fill = '#45909F', fill_alpha = 0.4, values = [3, 4, 5, 4, 3, 3, 2.5])
		plot.set_width(1)
		plot.set_dot_size(4)
		plot.set_halo_size(1)
		plot.set_loop()
	
		chart = openFlashChart.template("Radar chart")
		chart.set_bg_colour('#DFFFEC')
		chart.set_radar_axis(max = 5, colour = '#EFD1EF', grid_colour = '#EFD1EF', labels = list('012345'), spoke_labels = list('1234567'))
		chart.set_tooltip(behaviour = 'proximity')
		chart.add_element(plot)

		return chart.encode()
Example #27
0
	def radar(self):
		plot = Area_Hollow(colour = '#45909F', fill = '#45909F', fill_alpha = 0.4, values = [3, 4, 5, 4, 3, 3, 2.5])
		plot.set_width(1)
		plot.set_dot_size(4)
		plot.set_halo_size(1)
		plot.set_loop()
	
		chart = openFlashChart.template("Radar chart")
		chart.set_bg_colour('#DFFFEC')
		chart.set_radar_axis(max = 5, colour = '#EFD1EF', grid_colour = '#EFD1EF', labels = list('012345'), spoke_labels = list('1234567'))
		chart.set_tooltip(behaviour = 'proximity')
		chart.add_element(plot)

		return chart.encode()
Example #28
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()
Example #29
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()
Example #30
0
	def scatter(self):
		radians = [math.radians(degree) for degree in xrange(0, 360, 5)]
		values = [scatter_value(('%.2f' %math.sin(radian), '%.2f' %math.cos(radian))) for radian in radians]
	
		plot1 = Scatter(colour = '#FFD600', values = [scatter_value((0, 0))])
		plot2 = Scatter(colour = '#D600FF', values = values)
		
		plot1.set_dot_size(10)
		plot2.set_dot_size(3)
		
		chart = openFlashChart.template("Scatter chart")
		chart.set_x_axis(min = -2, max = 3)
		chart.set_y_axis(min = -2, max = 2)
		chart.add_element(plot1)
		chart.add_element(plot2)
		
		return chart.encode()
Example #31
0
	def scatter(self):
		radians = [math.radians(degree) for degree in xrange(0, 360, 5)]
		values = [scatter_value(('%.2f' %math.sin(radian), '%.2f' %math.cos(radian))) for radian in radians]
	
		plot1 = Scatter(colour = '#FFD600', values = [scatter_value((0, 0))])
		plot2 = Scatter(colour = '#D600FF', values = values)
		
		plot1.set_dot_size(10)
		plot2.set_dot_size(3)
		
		chart = openFlashChart.template("Scatter chart")
		chart.set_x_axis(min = -2, max = 3)
		chart.set_y_axis(min = -2, max = 2)
		chart.add_element(plot1)
		chart.add_element(plot2)
		
		return chart.encode()
Example #32
0
	def scatter_line(self):
		from random import randint
		
		x_values = [0]
		while x_values[-1] < 25:
			x_values.append(x_values[-1] + float(randint(5, 15))/10)
			
		values = [scatter_value((x, float(randint(-15, 15))/10)) for x in x_values]
	
		plot = Scatter_Line(colour = '#FFD600', values = values)
		plot.set_dot_size(3)
		
		chart = openFlashChart.template("Scatter_Line chart")
		chart.set_x_axis(min = 0, max = 25)
		chart.set_y_axis(min = -10, max = 10)
		chart.add_element(plot)
		
		return chart.encode()
Example #33
0
	def scatter_line(self):
		from random import randint
		
		x_values = [0]
		while x_values[-1] < 25:
			x_values.append(x_values[-1] + float(randint(5, 15))/10)
			
		values = [scatter_value((x, float(randint(-15, 15))/10)) for x in x_values]
	
		plot = Scatter_Line(colour = '#FFD600', values = values)
		plot.set_dot_size(3)
		
		chart = openFlashChart.template("Scatter_Line chart")
		chart.set_x_axis(min = 0, max = 25)
		chart.set_y_axis(min = -10, max = 10)
		chart.add_element(plot)
		
		return chart.encode()
Example #34
0
    def line(self):
        plot1 = Line(text="line1", fontsize=20, values=range(0, 10))
        plot2 = Line(text="line2", fontsize=06, values=range(10, 0, -1))
        plot3 = Line(text="line3", fontsize=12, values=range(-5, 5))

        plot1.set_line_style(4, 3)
        plot2.set_line_style(5, 5)
        plot3.set_line_style(4, 8)

        plot1.set_colour('#D4C345')
        plot2.set_colour('#C95653')
        plot3.set_colour('#8084FF')

        chart = openFlashChart.template("Line chart")
        chart.set_y_axis(min=-6, max=10)

        chart.add_element(plot1)
        chart.add_element(plot2)
        chart.add_element(plot3)

        return chart.encode()
Example #35
0
	def line(self):
		plot1 = Line(text = "line1", fontsize = 20, values = range(0,10))
		plot2 = Line(text = "line2", fontsize = 06, values = range(10,0, -1))
		plot3 = Line(text = "line3", fontsize = 12, values = range(-5,5))
		
		plot1.set_line_style(4, 3)
		plot2.set_line_style(5, 5)
		plot3.set_line_style(4, 8)
		
		plot1.set_colour('#D4C345')
		plot2.set_colour('#C95653')
		plot3.set_colour('#8084FF')
		
		chart = openFlashChart.template("Line chart")
		chart.set_y_axis(min = -6, max = 10)
		
		chart.add_element(plot1)
		chart.add_element(plot2)
		chart.add_element(plot3)

		return chart.encode()
Example #36
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()
Example #37
0
    def pie(self, search_result, title):
        plot = Pie(start_angle=35, animate=True, label_colour='#432BAF')
        values = []
        colours = []
        count = 0
        for row in search_result:
            count += 1
            values.append(pie_value(int(row[1]), (row[0], None, None)))
            colours.append(colorArr[count / len(colorArr)])
        if not search_result:
            values.append(pie_value(1, ("None", None, None)))
            colours.append(colorArr[count / len(colorArr)])
        plot.set_values(values=values)
        plot.colours = colours
        plot.set_tooltip('#val# of #total#<br>#percent# of 100%')
        plot.set_gradient_fill(True)
        plot.set_on_click('plot1')
        plot.set_no_labels(False)

        chart = openFlashChart.template(u'' + title + '')
        chart.add_element(plot)

        return chart.encode()
Example #38
0
	def pie(self,search_result,title):
		plot = Pie(start_angle = 35, animate = True,  label_colour = '#432BAF')
		values = []
		colours = []
		count = 0
		for row in search_result:
			count+=1
			values.append(pie_value(int(row[1]),(row[0],None,None)))
			colours.append(colorArr[count/len(colorArr)])
		if not search_result:
			values.append(pie_value(1,("None",None,None)))
			colours.append(colorArr[count/len(colorArr)])
		plot.set_values(values=values)
		plot.colours = colours
		plot.set_tooltip('#val# of #total#<br>#percent# of 100%')
		plot.set_gradient_fill(True)
		plot.set_on_click('plot1')
		plot.set_no_labels(False)

		chart = openFlashChart.template(u''+title+'')
		chart.add_element(plot)

		return chart.encode()
Example #39
0
	def line_hollow(self):
		plot1 = Line_Hollow(values = [math.sin(float(x)/10) * 1.9 + 4 for x in range(0, 62, 2)])
		plot2 = Line_Hollow(values = [math.sin(float(x)/10) * 1.9 + 7 for x in range(0, 62, 2)])
		plot3 = Line_Hollow(values = [math.sin(float(x)/10) * 1.9 + 10 for x in range(0, 62, 2)])
		
		plot1.set_halo_size(3)
		plot2.set_halo_size(1)
		plot3.set_halo_size(0)
		
		plot1.set_width(1)
		plot2.set_width(2)
		plot3.set_width(3)
		
		plot1.set_dot_size(4)
		plot2.set_dot_size(4)
		plot3.set_dot_size(6)
		
		chart = openFlashChart.template("Line_Hollow chart")
		chart.set_y_axis(min = 0, max = 15, steps = 5)
		chart.add_element(plot1)
		chart.add_element(plot2)
		chart.add_element(plot3)
		
		return chart.encode()
Example #40
0
def data(request, xen_id):
    from random import randint

    print "chamado para o id", xen_id
    xenHost = XenHost.objects.filter(id=xen_id)[0]

    data = "{ elements : ["

        # Obtem na base estatisticas por host
    querySetByHost = XenHostStatistic.objects.filter(xenHost=xenHost)
    #querySetByHostAndTime = querySetByHost.filter(date__range=(horaLimite, horaAtual))
    virtualMachinesStatistics = querySetByHost.order_by('-date')[:10]
    values = []
    x_max = 0

    data = data + "type: 'line', values: ["
    hora_referencia = timegm(virtualMachinesStatistics[len(virtualMachinesStatistics)-1].date.timetuple())
    for guestStat in virtualMachinesStatistics:
        #vm_guest = VirtualMachine(realMachine=host, vm_id=guestStat['vm_id'], weight=guestStat['cpu_average'])
        y = guestStat.cpu
        x = timegm(guestStat.date.timetuple())-hora_referencia
        values.append(value((y)))
        if x > x_max:
            x_max = x

    data = data + "], title : { text: 'Three lines example' }, y_axis: { min: 0, max: 20, steps: 5 }}"
    plot = Line(colour = '#FFD600', values = values)
    plot.set_dot_size(3)

    chart = openFlashChart.template(str(xenHost.name))
    #chart.set_x_axis(min = 0, max = x_max, steps=x_max/10)
    chart.set_y_axis(min = 0, max = 100, steps=10)
    
    chart.add_element(plot)

    return HttpResponse(chart.encode())
Example #41
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"
Example #42
0
def _create_chart(title, *elements):
    chart = openFlashChart.template(title)
    for element in elements:
        chart.add_element(element)
    return chart
Example #43
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"
    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()
Example #45
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()
Example #46
0
def _create_chart(title, *elements):
    chart = openFlashChart.template(title)
    for element in elements:
        chart.add_element(element)
    return chart