コード例 #1
0
def chart(request):

    data = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/different-plot-type-for-each-variable-measure-data.json').text
    schema = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/different-plot-type-for-each-variable-measure-schema.json').text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute("caption", """{ 
                                        text: 'Sales Performance'
                                      }""")

    timeSeries.AddAttribute("yAxis", """[{
                                        plot: {
                                                value: 'Sale Amount',
                                                type: 'area'
                                            },
                                            title: 'Sale Amount',
                                            format: {
                                                prefix: '$'
                                            }
                                        }, {
                                            plot: {
                                                value: 'Units Sold',
                                                type: 'column'
                                            },
                                            title: 'Units Sold'
                                    }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json", timeSeries)

     # returning complete JavaScript and HTML code, which is used to generate chart in the browsers. 
    return  render(request, 'index.html', {'output' : fcChart.render(), 'chartTitle': "Different plot type for each variable (measure)"})
コード例 #2
0
def chart(request):

    data = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/line-chart-with-time-axis-data.json').text
    schema = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/line-chart-with-time-axis-schema.json').text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute("caption", """{ 
                                        text: 'Sales Analysis'
                                        }""")

    timeSeries.AddAttribute("subcaption", """{ 
                                    text: 'Grocery'
                                    }""")

    timeSeries.AddAttribute("yAxis", """[{
                                            plot: {
                                            value: 'Grocery Sales Value',
                                            type: 'line'
                                            },
                                            format: {
                                            prefix: '$'
                                            },
                                            title: 'Sale Value'
                                        }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json", timeSeries)

     # returning complete JavaScript and HTML code, which is used to generate chart in the browsers. 
    return  render(request, 'index.html', {'output' : fcChart.render(), 'chartTitle': "Line chart with time axis"})
コード例 #3
0
def chart(request):

    data = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/column-line-combination-data.json'
    ).text
    schema = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/column-line-combination-schema.json'
    ).text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute(
        "caption", """{ 
                                        text: 'Web visits & downloads'
                                      }""")

    timeSeries.AddAttribute(
        "subcaption", """{ 
                                    text: 'since 2015'
                                    }""")

    timeSeries.AddAttribute(
        "yAxis", """[{
                                            plot: [{
                                                value: 'Downloads',
                                                type: 'column'
                                                }, {
                                                value: 'Web Visits',
                                                type: 'line'
                                                }]
                                        }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json",
                           timeSeries)

    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return render(
        request, 'index.html', {
            'output': fcChart.render(),
            'chartTitle': "Column and line combination on time axis"
        })
コード例 #4
0
def chart(request):

    data = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/candlestick-chart-data.json'
    ).text
    schema = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/candlestick-chart-schema.json'
    ).text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute(
        "caption", """{ 
											text: 'Apple Inc. Stock Price'
										}""")

    timeSeries.AddAttribute(
        "yAxis", """[{
										  plot: {
											value: {
											  open: 'Open',
											  high: 'High',
											  low: 'Low',
											  close: 'Close'
											},
											type: 'candlestick'
										  },
										  format: {
											prefix: '$'
										  },
										  title: 'Stock Value'
                                        }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json",
                           timeSeries)

    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return render(request, 'index.html', {
        'output': fcChart.render(),
        'chartTitle': "Interactive candlestick chart"
    })
コード例 #5
0
def chart(request):

    data = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/plotting-two-variable-measures-data.json').text
    schema = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/plotting-two-variable-measures-schema.json').text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute("caption", """{ 
								text: 'Cariaco Basin Sampling'
							  }""")

    timeSeries.AddAttribute("subcaption", """{ 
                                    text: 'Analysis of O₂ Concentration and Surface Temperature'
                                    }""")

    timeSeries.AddAttribute("yAxis", """[{
											plot: [{
											  value: 'O2 concentration',
											  connectNullData: true
											}],
											min: '3',
											max: '6',
											title: 'O₂ Concentration (mg/L)'  
										  }, {
											plot: [{
											  value: 'Surface Temperature',
											  connectNullData: true
											}],
											min: '18',
											max: '30',
											title: 'Surface Temperature (°C)'
                                        }]""");	

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json", timeSeries)

     # returning complete JavaScript and HTML code, which is used to generate chart in the browsers. 
    return  render(request, 'index.html', {'output' : fcChart.render(), 'chartTitle': "Plotting two variables (measures)"})
コード例 #6
0
def chart(request):

    data = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/column-chart-with-time-axis-data.json'
    ).text
    schema = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/column-chart-with-time-axis-schema.json'
    ).text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute("chart", """{ 
											showLegend: 0
										}""")

    timeSeries.AddAttribute(
        "caption", """{ 
                                        text: 'Daily Visitors Count of a Website'
                                    }""")

    timeSeries.AddAttribute(
        "yAxis", """[{
                                            plot: {
                                            value: 'Daily Visitors',
                                            type: 'column'
                                            },
                                            title: 'Daily Visitors (in thousand)'
                                        }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json",
                           timeSeries)

    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return render(request, 'index.html', {
        'output': fcChart.render(),
        'chartTitle': "Column chart with time axis"
    })
コード例 #7
0
def chart(request):
    data = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/adding-a-reference-line-data.json'
    ).text
    schema = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/adding-a-reference-line-schema.json'
    ).text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute(
        "caption", """{ 
								text: 'Temperature readings in Italy'
							  }""")

    timeSeries.AddAttribute(
        "yAxis", """[{
										  plot: 'Temperature',
										  title: 'Temperature',
										  format:{
											suffix: '°C',
										  },
										  referenceLine: [{
											label: 'Controlled Temperature',
											value: '10'
										  }]
                                        }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json",
                           timeSeries)

    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return render(request, 'index.html', {
        'output': fcChart.render(),
        'chartTitle': "Adding a reference line"
    })
コード例 #8
0
def chart(request):

    data = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/single-event-overlay-data.json'
    ).text
    schema = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/single-event-overlay-schema.json'
    ).text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute(
        "caption", """{ 
                                        text: 'Interest Rate Analysis'
                                    }""")

    timeSeries.AddAttribute(
        "subCaption", """{ 
                                        text: 'Federal Reserve (USA)'
                                    }""")

    timeSeries.AddAttribute(
        "yAxis", """[{
                                            plot: 'Interest Rate',
                                            format:{
                                            suffix: '%'
                                            },
                                            title: 'Interest Rate'
                                        }]""")

    timeSeries.AddAttribute(
        "xAxis", """{
                                        plot: 'Time',
                                        timemarker: [{
                                        start: 'Mar-1980',
                                        label: 'US inflation peaked at 14.8%.',
                                        timeFormat: ' %b -%Y',
                                        style: {
                                            marker:
                                            {
                                                fill: '#D0D6F4'
                                            }
                                        }
                                    }, {
                                        start: 'May-1981',
                                        label: 'To control inflation, the Fed started {br} raising interest rates to over {br} 20%.',
                                        timeFormat: '%b-%Y'
                                        }, {
                                        start: 'Jun-1983',
                                        label: 'By proactive actions of Mr.Volcker, {br} the inflation falls to 2.4% {br} from the peak of over 14% {br} just three years ago.',
                                        timeFormat: '%b-%Y',
                                        style: {
                                            marker: {
                                            fill: '#D0D6F4'
                                            }
                                        }
                                        }, {
                                        start: 'Oct-1987',
                                        label: 'The Dow Jones Industrial Average lost {br} about 30% of it’s value.',
                                        timeFormat: '%b-%Y',
                                        style: {
                                            marker: {
                                            fill: '#FBEFCC'
                                            }
                                        }
                                        }, {
                                        start: 'Jan-1989',
                                        label: 'George H.W. Bush becomes {br} the 41st president of US!',
                                        timeFormat: '%b-%Y'
                                        }, {
                                        start: 'Aug-1990',
                                        label: 'The oil prices spiked to $35 {br} per barrel from $15 per barrel {br} because of the Gulf War.',
                                        timeFormat: '%b-%Y'
                                        }, {
                                        start: 'Dec-1996',
                                        label: 'Alan Greenspan warns of the dangers {br} of \"irrational exuberance\" in financial markets, {br} an admonition that goes unheeded',
                                        timeFormat: '%b-%Y'
                                        }, {
                                        start: 'Sep-2008',
                                        label: 'Lehman Brothers collapsed!',
                                        timeFormat: '%b-%Y'
                                        },{
                                        start: 'Mar-2009',
                                        label: 'The net worth of US households {br} stood at a trough of $55 trillion.',
                                        timeFormat: '%b-%Y',
                                        style: {
                                            marker: {
                                            fill: '#FBEFCC'
                                            }
                                        }
                                        }, {
                                        start: 'Oct-2009',
                                        label: 'Unemployment rate peaked {br} in given times to 10%.',
                                        timeFormat: '%b-%Y'
                                        }]
                                    }""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json",
                           timeSeries)

    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return render(request, 'index.html', {
        'output': fcChart.render(),
        'chartTitle': "Single event overlay"
    })
コード例 #9
0
def chart(request):

    data = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/date-range-event-overlay-data.json'
    ).text
    schema = requests.get(
        'https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/date-range-event-overlay-schema.json'
    ).text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute(
        "caption", """{ 
								text: 'Interest Rate Analysis'
							  }""")

    timeSeries.AddAttribute(
        "subCaption", """{ 
                                        text: 'Federal Reserve (USA)'
                                    }""")

    timeSeries.AddAttribute(
        "yAxis", """[{
                                            plot: 'Interest Rate',
                                            format:{
                                            suffix: '%'
                                            },
                                            title: 'Interest Rate'
                                        }]""")

    timeSeries.AddAttribute(
        "xAxis", """{
                                        plot: 'Time',
                                        timemarker: [{
                                            start: 'Jul-1981',
                                            end: 'Nov-1982',
                                            label: 'Economic downturn was triggered by {br} tight monetary policy in an effort to {br} fight mounting inflation.',
                                            timeFormat: '%b-%Y'
                                        }, {
                                            start: 'Jul-1990',
                                            end: 'Mar-1991',
                                            label: 'This eight month recession period {br} was characterized by a sluggish employment recovery, {br} most commonly referred to as a jobless recovery.',
                                            timeFormat: '%b-%Y'
                                        }, {
                                            start: 'Jun-2004',
                                            end: 'Jul-2006',
                                            label: 'The Fed after raising interest rates {br} at 17 consecutive meetings, ends its campaign {br} to slow the economy and forestall inflation.',
                                            timeFormat: '%b-%Y'
                                        }, {
                                            start: 'Dec-2007',
                                            end: 'Jun-2009',
                                            label: 'Recession caused by the worst {br} collapse of financial system in recent {br} times.',
                                            timeFormat: '%b-%Y'
                                        }]
                                    }""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-1", "json",
                           timeSeries)

    # returning complete JavaScript and HTML code, which is used to generate chart in the browsers.
    return render(request, 'index.html', {
        'output': fcChart.render(),
        'chartTitle': "Date range event overlay"
    })
コード例 #10
0
def chart(request):

    data = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/annotating-single-data-point-data.json').text
    schema = requests.get('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/annotating-single-data-point-schema.json').text

    fusionTable = FusionTable(schema, data)
    timeSeries = TimeSeries(fusionTable)

    timeSeries.AddAttribute("caption", """{ 
											text: 'Interest Rate Analysis'
										}""")

    timeSeries.AddAttribute("subCaption", """{ 
                                        text: 'Federal Reserve (USA)'
                                    }""")
    
    timeSeries.AddAttribute("yAxis", """[{
                                            plot: 'Interest Rate',
                                            format:{
                                                suffix: '%'
                                            },
                                            title: 'Interest Rate'
                                        }]""")

    timeSeries.AddAttribute("dataMarker", """[{
                                        seriesName: 'Interest Rate',
                                        time: 'Mar-1980',
                                        identifier: 'H',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'As a part of credit control program, under the leadership of Paul Volcker, the Fed tightened the money supply, allowing the federal fund rates to approach 20 percent.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'Aug-1982',
                                        identifier: 'L',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'The FED eases off the monetary brakes, allowing interest rates to fall and the economy to begin a strong recovery.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'Oct-1987',
                                        identifier: 'L',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'The FED is forced to ease rate after the stock market crash.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'May-1989',
                                        identifier: 'H',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'Liquidity problem forced the Fed to increase rate to nearly 10%.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'Sept-1992',
                                        identifier: 'L',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'To fight the jobless economy growth the Fed had to reduce the interest rate to 3%.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'Jun-2003',
                                        identifier: 'L',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'Struggling to revive the economy, the FED cuts it’s benchmark rate to 1%.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'Sep-2007',
                                        identifier: 'L',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'Fed started reducing the Federal Fund Rate.'
                                        }, {
                                        seriesName: 'Interest Rate',
                                        time: 'Dec-2008',
                                        identifier: 'L',
                                        timeFormat: '%b-%Y',
                                        tooltext: 'Fed reduced the interest rates to sub 0.25% to manage the menace of longest economic downturn since World War 2'
                                        }]""")

    # Create an object for the chart using the FusionCharts class constructor
    fcChart = FusionCharts("timeseries", "ex1", 700, 450, "chart-2", "json", timeSeries)

     # returning complete JavaScript and HTML code, which is used to generate chart in the browsers. 
    return  render(request, 'index.html', {'output' : fcChart.render(), 'chartTitle': "Annotating single data point"})