vicky07
Members-
Content count
2 -
Joined
-
Last visited
About vicky07
-
Rank
Forum Newbie
-
Hi, I am using Django. I am able to succeed in the first drill-down and the linked chart is displaying the data correctly. But when I click on the data plots in the linked chart it is showing "No Data to display". I am sharing my code below. views.py def chart1(request): dataSource = {} dataSource['chart'] = { "caption": "Regional Sales", "showValues": "0", "theme": "fusion" } dataSource['data'] = [] dataSource['linkeddata'] = [] sbc = MTD.pdobjects.all() sbc_df = sbc.to_dataframe().reset_index(drop=True)#Trying to use filtered model for dataframe sbc_df['Sales_Value']=sbc_df['Sales_Value'].astype(float) rgn_gb=sbc_df.groupby('RGN')['Sales_Value'].sum().reset_index() RGN=list(rgn_gb['RGN']) RGN_val=list(rgn_gb['Sales_Value']) sbc_gb=pandas.pivot_table(sbc_df,index=['Channel','RGN'],values=['Sales_Value'],aggfunc='sum').reset_index() vert_gb=pandas.pivot_table(sbc_df,index=['Vertical','Channel','RGN'],values=['Sales_Value'],aggfunc='sum').reset_index() for i in range(len(RGN)): data = {} data['label'] = RGN data['value'] = RGN_val data['link'] = 'newchart-json-'+ RGN dataSource['data'].append(data) linkData = {} linkData['id'] = RGN linkedchart = {} linkedchart['chart'] = { "caption" : "Channelwise Sales " + RGN , "showValues": "0", "theme": "fusion", } linkedchart['data'] = [] sbc_filtered=sbc_gb[sbc_gb.RGN == RGN] Channel_list=list(sbc_filtered['Channel']) Channel_val=list(sbc_filtered['Sales_Value']) for k in range(len(sbc_filtered)): arrDara = {} arrDara['label'] = Channel_list[k] arrDara['value'] = Channel_val[k] arrDara['link'] = 'newchart-json-'+ Channel_list[k] linkedchart['data'].append(arrDara) linkData1 = {} linkData1['id'] = Channel_list[k] linkedchart1 = {} linkedchart1['chart'] = { "caption" : "Verticalwise Sales" + Channel_list[k] , "showValues": "0", "theme": "fusion", } linkedchart1['data'] = [] sbc2_filtered=vert_gb[(vert_gb.RGN == RGN) & (vert_gb.Channel == Channel_list[k])] Vertical_list=list(sbc2_filtered['Vertical']) Vertical_val=list(sbc2_filtered['Sales_Value']) for j in range(len(sbc2_filtered)): darrDara = {} darrDara['label'] = Vertical_list[j] darrDara['value'] = Vertical_val[j] linkedchart1['data'].append(darrDara) linkData1['linkedchart'] = linkedchart1 dataSource['linkeddata'].append(linkData1) linkData['linkedchart'] = linkedchart dataSource['linkeddata'].append(linkData) column2D = FusionCharts("column2D", "ex1" , "700", "400", "chart-1", "json", dataSource) return render(request, 'table.html',{'output':column2D.render()}) I cannot figure out where I am going wrong. I believe that there is no problem with indentation. Please help me to resolve this. Thanks Vicky
-
Problem in displaying different chart types using drilldown in fusionchartsXT
vicky07 posted a topic in General usage
I want to display the parent chart in bar2d and the child chart in pie2d. But both the parent and child charts are rendered in the same type. Also I used configureLink() method to specify my child chart type. But it is throwing an error like 'str' object has no attribute 'configure link'. I am using Django. The code that I have tried is: Views.py def drilldown(request): drilldownobj = FusionCharts( 'column2d', 'chart-container', '600', '400', 'drilldown-chart', 'json', {"chart": { "caption": "North American Population", "subcaption": "USA & Canada", "xaxisname": "Country (Click to drill down)", "theme": "fusion" }, "data": [ { "label": "United States", "value": "310380000", "link": "newchart-json-usa" }, { "label": "Canada", "value": "34020000", "link": "newchart-json-can" } ], "linkeddata": [ { "id": "usa", "linkedchart":{ "chart": { "caption": "Population by Religion", "subcaption": "USA", "showpercentintooltip": "1", "enablemultislicing": "0", "startingangle": "90", "theme": "fusion" }, "data": [ { "label": "Christian", "value": "78.30" }, { "label": "Muslim", "value": "0.90 " }, { "label": "Hindu", "value": ".60" }, { "label": "Buddhist", "value": "1.20" }, { "label": "Jewish", "value": "1.80" }, { "label": "Others", "value": "17.20" } ] } }, { "id": "can", # "type":"pie2d", "linkedchart": { "chart": { "caption": "Population by Religion", "subcaption": "Canada", "showpercentintooltip": "1", "startingangle": "90", "theme": "fusion" }, "data": [ { "label": "Christian", "value": "72" }, { "label": "Muslim", "value": "2.1" }, { "label": "Hindu", "value": "1.4" }, { "label": "Buddhist", "value": ".8" }, { "label": "Jewish", "value": "1.72" }, { "label": "Others", "value": "24.70" } ] } } ] }).render() drilldownobj.configureLink({ type: "pie2d", overlayButton: { message: 'Back to parent chart', bgColor: '#999999', borderColor: '#cccccc' } }).render() drilldown_dict ={'drilldown':drilldownobj} return render(request, 'drilldown.html',context=drilldown_dict) .html: {% extends "base.html" %} {% block body %} <section class="content-header"> <h1><strong>drilldown</strong></h1> <br> <div class="row"> <div class="col-md-6"> <div id="drilldown-chart">{{ drilldown|safe }}</div> </div> {% endblock %} Please help me to resolve this. Thanks