Beispiel #1
0
def index():
    # Instantiate the ExportConfig class and add the required configurations
    export_config = ExportConfig()

# Provide path of the chart configuration which we have defined above.
# You can also pass the same object as serialized JSON.
    export_config["chartConfig"] = open("C:/Users/a563684/Documents/Angular/testrouting/src/app/home/chart-config-file1.json",'r').read()

# ATTENTION - Pass the path of the dashboard template
    export_config["templateFilePath"] = "C:/Users/a563684/Documents/Angular/testrouting/src/app/home/dashboard-template.html"

# Provide port and host of FusionExport Service
    export_server_host = "127.0.0.1"
    export_server_port = 1337

# Instantiate the ExportManager class
    em = ExportManager(export_server_host, export_server_port)

# Call the export() method with the export_config as its argument
    em.export(export_config, output_dir=".", unzip = True)
    return "Hello, Fusion"
Beispiel #2
0
#!/usr/bin/env python

from fusionexport import ExportManager, ExportConfig  # Import sdk

# Instantiate the ExportConfig class and add the required configurations
export_config = ExportConfig()
export_config["chartConfig"] = "chart-config-file.json"
export_config["quality"] = "best"

# Provide port and host of FusionExport Service
export_server_host = "127.0.0.1"
export_server_port = 1337

# Instantiate the ExportManager class
em = ExportManager(export_server_host, export_server_port)
# Call the export() method with the export config and the output location
exported_files = em.export(export_config, "./exports")
print(exported_files)
Beispiel #3
0
def chart(request):

    #Chart data is passed to the `dataSource` parameter, like a dictionary in the form of key-value pairs.
    dataSource = OrderedDict()

    # The `chartConfig` dict contains key-value pairs of data for chart attribute
    chartConfig = OrderedDict()
    chartConfig["caption"] = "MY EXPENDITURE"
    chartConfig["subCaption"] = "Powered by Bon-Appetite"
    chartConfig["xAxisName"] = "DATE"
    chartConfig["yAxisName"] = "AMOUNT"
    chartConfig["theme"] = "candy"

    current_user = request.user
    datem = datetime.today().strftime("%Y-%m")
    #month=datetime.today().strftime("%b")
    dataset = bill.objects.filter(uid=current_user.username,
                                  date__contains=datem).values('bill', 'date')
    dataSource["chart"] = chartConfig
    dataSource["data"] = []

    for entry in dataset:
        usero = {}
        usero["label"] = entry['date']
        usero["value"] = int(entry['bill'])
        dataSource["data"].append(usero)

    line2D = FusionCharts("line", "Hello", "600", "400", "container", "json",
                          dataSource)

    # Instantiate the ExportConfig class and add the required configurations
    export_config = ExportConfig()

    # Provide path of the chart configuration which we have defined above.
    # You can also pass the same object as serialized JSON.
    d = [{
        "type": "line",
        "renderAt": "container",
        "width": "600",
        "height": "400",
        "dataFormat": "json",
        "dataSource": dataSource
    }]
    export_config.set('chartConfig', d)
    export_config.set("outputFile", current_user.username)

    export_server_host = "127.0.0.1"
    export_server_port = 1337

    em = ExportManager(export_server_host, export_server_port)

    em.export(export_config,
              output_dir="C:\\Users\\Neha\\sem5\\zom\\bonbon",
              unzip=True)
    bill.img = "C:\\Users\\Neha\\sem5\\zom\\bonbon\\man.png"

    html_content = render_to_string('mail.html')
    #html_content= '<b> This is your expenditure : </b> <img src="cid:C:\\Users\\Neha\\sem5\\zom\\export.png" >'
    text_content = strip_tags(html_content)

    # create the email, and attach the HTML version as well.
    subject = 'Thank you for registering to our site'
    email_from = settings.EMAIL_HOST_USER
    recipient_list = ['*****@*****.**', '*****@*****.**']
    msg = EmailMultiAlternatives(subject, text_content, email_from,
                                 recipient_list)
    msg.attach_alternative(html_content, "text/html")
    msg.send()

    return render(request, 'graph.html', {'output': line2D.render()})