vicky07

2nd level drill down problem

Recommended Posts

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

Share this post


Link to post
Share on other sites

Hi Vicky,

 

In order to change the chart type for the child chart you need to use configureLink API method to set the child chart type, you can also set different chart at a different level, provided the datastructure for each chart is correct.

Provide the configureLink() API method parameter as below :

myChart.configureLink([ { type: 'bar2d' }, { type: 'line' }, { type: 'pie2d' } ]);

Sample for reference : http://jsfiddle.net/muw1L4k5/1/

 

Thanks,

Akash.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now