def test_multiBarHorizontalChart(self): """Test multi Bar Horizontal Chart""" type = "multiBarHorizontalChart" chart = multiBarHorizontalChart(name=type, height=350) nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] chart.add_serie(y=ydata, x=xdata) chart.add_serie(y=ydata2, x=xdata) chart.buildhtml()
def multi_bar_chart(): type = "multiBarHorizontalChart" chart = multiBarHorizontalChart(name=type, height=350) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildhtml() return chart.htmlcontent
""" Examples for Python-nvd3 is a Python wrapper for NVD3 graph library. NVD3 is an attempt to build re-usable charts and chart components for d3.js without taking away the power that d3.js gives you. Project location : https://github.com/areski/python-nvd3 """ from nvd3 import multiBarHorizontalChart import random # Open File for test output_file = open('test_multiBarHorizontalChart.html', 'w') type = "multiBarHorizontalChart" chart = multiBarHorizontalChart(name=type, height=350) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildhtml() output_file.write(chart.htmlcontent) # ---------------------------------------
xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent() output_file.write(chart.htmlcontent) # --------------------------------------- type = "multiBarHorizontalChart" chart = multiBarHorizontalChart(height=400, width=800, jquery_on_ready=True) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent() output_file.write(chart.htmlcontent) # ---------------------------------------
xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent() output_file.write(chart.htmlcontent) #--------------------------------------- type = "multiBarHorizontalChart" chart = multiBarHorizontalChart(name=type, height=350, jquery_on_ready=True) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent() output_file.write(chart.htmlcontent) #---------------------------------------
xdata = [start_time + x * 1000000000 for x in xdata] ydata = [i + random.randint(1, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent() output_file.write(chart.htmlcontent) #--------------------------------------- type = "multiBarHorizontalChart" chart = multiBarHorizontalChart(height=350, jquery_on_ready=True) chart.set_containerheader("\n\n<h2>" + type + "</h2>\n\n") nb_element = 10 xdata = list(range(nb_element)) ydata = [random.randint(-10, 10) for i in range(nb_element)] ydata2 = [x * 2 for x in ydata] extra_serie = {"tooltip": {"y_start": "", "y_end": " Calls"}} chart.add_serie(name="Count", y=ydata, x=xdata, extra=extra_serie) extra_serie = {"tooltip": {"y_start": "", "y_end": " Min"}} chart.add_serie(name="Duration", y=ydata2, x=xdata, extra=extra_serie) chart.buildcontent() output_file.write(chart.htmlcontent) #---------------------------------------