Ejemplo n.º 1
0
def adminruby(request):
    dataSource = OrderedDict()

    # The `chartConfig` dict contains key-value pairs data for chart attribute
    chartConfig = OrderedDict()
    chartConfig["caption"] = ""
    #chartConfig["subCaption"] = "In MMbbl = One Million barrels"
    chartConfig["xAxisName"] = "Rooms"
    chartConfig["yAxisName"] = "Available"
    chartConfig["numberSuffix"] = ""
    chartConfig["theme"] = "fusion"

    # The `chartData` dict contains key-value pairs data
    chartData = OrderedDict()
    avl1 = get_available('single')
    avl2 = get_available('double')
    avl3 = get_available('luxury')
    avl4 = get_available('deluxe')
    avl5 = get_available('executive')
    avl6 = get_available('presidential')

    chartData["Single"] = avl1
    chartData["Double"] = avl2
    chartData["Deluxe"] = avl3
    chartData["Luxury"] = avl4
    chartData["Executive"] = avl5
    chartData["Presidential"] = avl6

    dataSource["chart"] = chartConfig
    dataSource["data"] = []
    
    # Convert the data in the `chartData` array into a format that can be consumed by FusionCharts. 
    # The data for the chart should be in an array wherein each element of the array is a JSON object
    # having the `label` and `value` as keys.

    # Iterate through the data in `chartData` and insert in to the `dataSource['data']` list.
    for key, value in chartData.items():
        data = {}
        data["label"] = key
        data["value"] = value
        dataSource["data"].append(data)


    # Create an object for the column 2D chart using the FusionCharts class constructor
    # The chart data is passed to the `dataSource` parameter.
    column2D = FusionCharts("column2d", "ex1" , "800", "400", "chart-1", "json", dataSource)

    return  render(request, 'app/adminanalytics.html', {'output' : column2D.render(), 'chartTitle': 'Available Rooms'})
Ejemplo n.º 2
0
def adminruby(request):
    if 'admin' in request.session:
        dataSource = OrderedDict()
        chartConfig = OrderedDict()
        chartConfig["caption"] = ""
        chartConfig["xAxisName"] = "Rooms"
        chartConfig["yAxisName"] = "Available"
        chartConfig["numberSuffix"] = ""
        chartConfig["theme"] = "fusion"

        chartData = OrderedDict()
        avl1 = len(get_rooms('single'))
        avl2 = len(get_rooms('double'))
        avl3 = len(get_rooms('luxury'))
        avl4 = len(get_rooms('deluxe'))
        avl5 = len(get_rooms('executive'))
        avl6 = len(get_rooms('presidential'))

        chartData["Single"] = avl1
        chartData["Double"] = avl2
        chartData["Deluxe"] = avl3
        chartData["Luxury"] = avl4
        chartData["Executive"] = avl5
        chartData["Presidential"] = avl6

        dataSource["chart"] = chartConfig
        dataSource["data"] = []

        for key, value in chartData.items():
            data = {}
            data["label"] = key
            data["value"] = value
            dataSource["data"].append(data)
        column2D = FusionCharts("column2d", "ex1", "800", "400", "chart-1",
                                "json", dataSource)
        return render(request, 'app/adminanalytics.html', {
            'output': column2D.render(),
            'chartTitle': 'Available Rooms'
        })
    else:
        return render(request, 'app/adminlogin.html')
Ejemplo n.º 3
0
def vmFusionChart(vm_records):
    # Syntax for the constructor - FusionCharts("type of chart", "unique chart id", "width of chart", "height of chart", "div id to render the chart", "type of data", "actual data")

    # Chart data is passed to the `dataSource` parameter, as dict, in the form of key-value pairs.
    dataSource = {}
    # setting chart cosmetics
    dataSource['chart'] = {
        "caption": "VM List by Unshared MB",
        "paletteColors": "#0075c2",
        "bgColor": "#ffffff",
        "borderAlpha": "20",
        "canvasBorderAlpha": "0",
        "usePlotGradientColor": "0",
        "plotBorderAlpha": "10",
        "showXAxisLine": "1",
        "xAxisLineColor": "#999999",
        "showValues": "0",
        "divlineColor": "#999999",
        "divLineIsDashed": "1",
        "showAlternateHGridColor": "0"
    }

    dataSource['data'] = []
    # The data for the chart should be in an array wherein each element of the array is a JSON object as
    # `label` and `value` keys.
    # Iterate through the data in `Country` model and insert in to the `dataSource['data']` list.
    for key in vm_records.all():
        data = {}
        data['label'] = key.rvt_vi_vm
        data['value'] = key.rvt_vi_unshared_mb
        dataSource['data'].append(data)

        # Create an object for the Column 2D chart using the FusionCharts class constructor
    column2D = FusionCharts("column2D", "ex1", "100%", "400", "chart-1",
                            "json", dataSource)
    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return column2D
Ejemplo n.º 4
0
def salesanalysis(request):
    price = BookingHistory.objects.aggregate(Sum('amount'))
    amount = 0
    for k, v in price.items():
        amount = v
    chartObj = FusionCharts('angulargauge', 'ex1', '600', '400', 'chart-1', 'json', """{
    "chart": {
    "captionpadding": "0",
    "origw": "320",
    "origh": "300",
    "gaugeouterradius": "115",
    "gaugestartangle": "270",
    "gaugeendangle": "-25",
    "showvalue": "1",
    "valuefontsize": "30",
    "majortmnumber": "13",
    "majortmthickness": "2",
    "majortmheight": "13",
    "minortmheight": "7",
    "minortmthickness": "1",
    "minortmnumber": "1",
    "showgaugeborder": "0",
    "theme": "fusion"
    },
    "colorrange": {
    "color": [
      {
        "minvalue": "0",
        "maxvalue": "5000000",
        "code": "#999999"
      },
      {
        "minvalue": "1500",
        "maxvalue": "10000000",
        "code": "#F6F6F6"
      }
    ]
  },
  "dials": {
    "dial": [
      {
        "value": """ + str(amount) + """,
        "bgcolor": "#F20F2F",
        "basewidth": "8"
      }
    ]
  },
  "annotations": {
    "groups": [
      {
        "items": [
          {
            "type": "text",
            "id": "text",
            "text": "INR",
            "x": "$gaugeCenterX",
            "y": "$gaugeCenterY + 40",
            "fontsize": "20",
            "color": "#555555"
          }
        ]
      }
    ]
  }
}""")
    return render(request, 'app/salesanalysis.html', {'output': chartObj.render()})