Problem in rendering Multiple Drilldown in fusioncharts - django

I am using Django. I want use the drilldown feature in fusioncharts. I am able to get the first drilldown correctly. But when I code for the second drilldown it is showing "No data to display". Also the following code renders all the charts in the same type. But I want to render the child charts in different types. I am sharing the snippet below.
def chart(request):
dataSource = {}
dataSource['chart'] = {
"caption": "Top 10 Most Populous Countries",
"showValues": "0",
"theme": "zune"
}
dataSource['data'] = []
dataSource['linkeddata'] = []
sbc = MTD.pdobjects.values('Vertical', 'Channel','Brand','Sales_Value')
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)
chn_gb=sbc_df.groupby('Channel')['Sales_Value'].sum().reset_index()
channel=list(chn_gb['Channel'])
channel_val=list(chn_gb['Sales_Value'])
sbc_gb=pandas.pivot_table(sbc_df,index=['Vertical','Channel'],values=['Sales_Value'],aggfunc='sum').reset_index()
brd_gb=pandas.pivot_table(sbc_df,index=['Vertical','Channel','Brand'],values=['Sales_Value'],aggfunc='sum').reset_index()
for i in range(len(channel)):
data = {}
data['label'] = channel[i]
data['value'] = channel_val[i]
data['link'] = 'newchart-json-'+ channel[i]
dataSource['data'].append(data)
linkData2 = {}
linkData2['id'] = channel[i]
linkedchart2 = {}
linkedchart2['chart'] = {
"caption" : "Top 10 Most Populous Cities - " + channel[i] ,
"showValues": "0",
"theme": "fusion",
}
linkedchart2['data'] = []
sbc_filtered=sbc_gb[sbc_gb.Channel == channel[i]]
vertical_list=list(sbc_filtered['Vertical'])
vertical_val=list(sbc_filtered['Sales_Value'])
for k in range(len(sbc_filtered)):
arrDara2 = {}
arrDara2['label'] = vertical_list[k]
arrDara2['value'] = vertical_val[k]
arrDara2['link'] = 'newchart-json-'+ vertical_list[k]
linkedchart2['data'].append(arrDara2)
linkData1 = {}
# Inititate the linkData for cities drilldown
linkData1['id'] = vertical_list[k]
linkedchart1 = {}
linkedchart1['chart'] = {
"caption" : "Top 10 Most Populous Cities - " + vertical_list[k] ,
"showValues": "0",
"theme": "fusion",
}
linkedchart1['data'] = []
brd_filtered=brd_gb[(brd_gb.Channel == channel[i]) & (brd_gb.Vertical== vertical_list[k])]
brd_list=list(brd_filtered['Brand'])
brd_val=list(brd_filtered['Sales_Value'])
for j in range(len(brd_filtered)):
arrDara1 = {}
arrDara1['label'] = brd_list[j]
arrDara1['value'] = brd_val[j]
linkedchart1['data'].append(arrDara1)
linkData1['linkedchart'] = linkedchart1
dataSource['linkeddata'].append(linkData1)
linkData2['linkedchart'] = linkedchart2
dataSource['linkeddata'].append(linkData2)
print(dataSource)
column2D = FusionCharts("column2D", "ex1" , "700", "400", "chart-1", "json", dataSource)
return render(request, 'table.html',{'output':column2D.render()})
Kindly help me to achieve the successive drilldown correctly.
Thanks

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, here is how you can do
myChart.configureLink([
{ type: 'bar2d' },
{ type: 'line' },
{ type: 'pie2d' }
]);
Here is a demo - http://jsfiddle.net/x0c2wo7k/
Please note the above sample is using plain javascript

Related

Compose desktop(JVM) BasicTextField, Korean input duplicating

I'm implementing a simple search input field on Compose desktop.
My code looks as below.
BasicTextField(
modifier = Modifier.align(Alignment.CenterVertically).onPreviewKeyEvent {
if(it.key == Key.Enter && it.type == KeyEventType.KeyDown){
println("enter down: $textFieldState")
true
}else {
false
}
},
value = textFieldState,
onValueChange = { input ->
textFieldState = input
},
textStyle = TextStyle(
fontSize = 14.sp,
textAlign = TextAlign.Start,
fontWeight = FontWeight.Normal,
fontFamily = NotoSans,
color = Color.Black
),
maxLines = 1,
decorationBox = { innerTextField ->
Row(modifier = Modifier.fillMaxWidth()) {
if (textFieldState.isEmpty()) {
Text(
text = "Search with user name.",
fontSize = 14.sp,
color = Color(0xFF909ba9),
textAlign = TextAlign.Start,
fontWeight = FontWeight.Normal,
fontFamily = NotoSans,
modifier = Modifier.fillMaxWidth()
.align(Alignment.CenterVertically),
)
}
}
innerTextField()
}
)
This code will create a textfield which has 1 max lines.
It works without any problem on english inputs.
But when I type in Korean inputs, keys such as space, enter, or even numbers will duplicate the last Korean character. For example, in english, if I type in H, I, !,
it will be HII!.
Is there some locale settings that can be done to the textField?
I found no working solution in here or in the Compose multiplatform git issue page. I found a workaround using SwingPanel and JTextField.
SwingPanel(background = Color(0xFFf5f6f6), modifier = Modifier.fillMaxSize(), factory = {
//Some JTextfield I've obtaines from stackoverflow to show place holder text.
//Can be replaced to JTextField(columnCount:Int)
HintTextField("Enter in name",1).apply {
background = java.awt.Color(0xf5, 0xf6, 0xf6)
border = null
}
}, update = {
//SimpleDocumentListener is an implementation of DocumentListener.
//Which means it can be replaced by it.
it.document.addDocumentListener(object : SimpleDocumentListener{
override fun update(e: DocumentEvent) {
try{
val text = it.text
textFieldState = text
} catch(e : Exception) {
e.printStackTrace()
}
}
})
//I need an enter key to trigger some search logics.
//textFieldState seems to print the value as I intended
it.addKeyListener(object : KeyAdapter(){
override fun keyPressed(e: KeyEvent?) {
if(e?.keyCode == KeyEvent.VK_ENTER){
println("ENTER : $textFieldState")
}
}
})
})
Really hope the compose multiplatform team comes up with a better solution.

Terraform aws_cloudfront_cache_policy pass multiple cookies to cookies_config

I can't seem to pass multiple cookies in the "items" list when in "cookies_config -> cookies"
Here is my variable:
variable "cache_policy_defaults" {
type = object({
name = string
comment = string
default_ttl = number
max_ttl = number
min_ttl = number
cookie_behavior = string
cookies_to_forward = optional(list(string))
header_behavior = string
headers_to_forward = optional(list(string))
query_string_behavior = string
query_strings_to_forward = optional(list(string))
}
)
default = {
name = ""
comment = ""
default_ttl = 60
max_ttl = 60
min_ttl = 60
cookie_behavior = "none"
cookies_to_forward = []
header_behavior = "none"
headers_to_forward = []
query_string_behavior = "none"
query_strings_to_forward = []
}
}
Here are my locals:
locals {
origin_id = "origin_${local.origin_config.domain_name}"
origin_config = merge(var.origin_defaults, var.origin_settings)
restrictions = merge(var.restrictions_defaults, var.restrictions_settings)
default_cache_behavior = merge(var.default_cache_behavior_defaults, var.default_cache_behavior_settings)
cache_policy = merge(var.cache_policy_defaults, var.cache_policy_settings)
cache_policy_name = "cache_policy_${var.name}"
}
Here is my tfvars:
"cache_policy_settings": {
"min_ttl": 30,
"max_ttl": 30,
"default_ttl": 30,
"cookie_behavior": "whitelist",
"cookies_to_forward": ["123", "456"]
}
Here is my main.tf:
resource "aws_cloudfront_cache_policy" "this" {
name = lookup(local.cache_policy, local.cache_policy.name, local.cache_policy_name)
comment = local.cache_policy.comment
default_ttl = local.cache_policy.default_ttl
max_ttl = local.cache_policy.max_ttl
min_ttl = local.cache_policy.min_ttl
parameters_in_cache_key_and_forwarded_to_origin {
cookies_config {
cookie_behavior = local.cache_policy.cookie_behavior
dynamic "cookies" {
for_each = local.cache_policy.cookies_to_forward != null ? local.cache_policy.cookies_to_forward : null
content {
items = local.cache_policy.cookies_to_forward
}
}
}
headers_config {
header_behavior = local.cache_policy.header_behavior
dynamic "headers" {
for_each = local.cache_policy.headers_to_forward != null ? local.cache_policy.headers_to_forward : null
content {
items = local.cache_policy.headers_to_forward
}
}
}
query_strings_config {
query_string_behavior = local.cache_policy.query_string_behavior
dynamic "query_strings" {
for_each = local.cache_policy.query_strings_to_forward != null ? local.cache_policy.query_strings_to_forward : null
content {
items = local.cache_policy.query_strings_to_forward
}
}
}
}
}
The docs state
items: (Required) A list of item names (cookies, headers, or query strings).
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_cache_policy#items
However, the list does not accept multiple items.
Error: Too many list items
on main.tf line 57, in resource "aws_cloudfront_cache_policy" "this":
57: cookies_config {
Attribute supports 1 item maximum, but config has 2 declared.
It seems that I should just be able to pass a list of items? If I change the my input list to only contain a single value, then it works.
Here is the trick:
for_each = local.cache_policy.cookies_to_forward != null ? [1] : null
This tells Terraform to create exactly one block by making the true value of the ternary [1].
Thanks Jason for putting me on the right track.

#Django - 'list' object has no attribute 'id'

I have this code,
def delivery_date(request):
today = datetime.today().date()
results = [get(today)]
stages = Stage.objects.prefetch_related('Stage').all()
for i in range(3):
results.append(get(results[i]))
results = [{'date': i} for i in results]
stages = [{'menu': s} for s in stages]
for i in results:
for stage in stages:
stage['id'] = stage['menu'].id
stage['name'] = stage['menu'].name
stage['desc'] = stage['menu'].desc
stage['menu'] = stage['menu'].Stage.filter(
delivery_date__exact=i['date'])
stage['menu'] = serializers.serialize('python', stage['menu'])
i['menu'] = stages
i['date'] = i['date'].strftime('%b %-d')
return JsonResponse(results, safe=False)
But the results says,
this image
But if the results has only one date, it works.
Like this,
def delivery_date(request):
today = datetime.today().date()
results = [get(today)]
stages = Stage.objects.prefetch_related('Stage').all()
# for i in range(3):
# results.append(get(results[i]))
results = [{'date': i} for i in results]
stages = [{'menu': s} for s in stages]
for i in results:
for stage in stages:
stage['id'] = stage['menu'].id
stage['name'] = stage['menu'].name
stage['desc'] = stage['menu'].desc
stage['menu'] = stage['menu'].Stage.filter(
delivery_date__exact=i['date'])
stage['menu'] = serializers.serialize('python', stage['menu'])
i['menu'] = stages
i['date'] = i['date'].strftime('%b %-d')
return JsonResponse(results, safe=False)
The results,
[
{
"date" : Oct 25,
"menu" : [
{
"menu" : [
{
"model" : backend.product,
"pk" : 13,
"fields" : {
"name" : Tasty Tempeh,
"desc" : Nasi, Ayam, Wortel, Buncis, Bawang Merah, Bawang Putih, Daun Salam, Serai, Minyak Wijen, Minyak Kelapa Sawit.,
"desc_detail" : ,
"delivery_date" : 2019-10-25,
"avatar" : ,
"stage" : 1
}
}
],
"id" : 1,
"name" : Porridge,
"desc" :
}
}
]
What's wrong with my logic? Can Anyone helps?
it is just you missed that menu is a Dict which has a list as value say temp
and that temp file has a dict at its 0 indexes:
use the following :
stage['menu'][0]['id']

How to format hours in grouping summary result in igGrid 2013.2?

I have grid with grouping and I group by one column and then make hours summary on another column like that :
name: "GroupBy",
type: "local",
columnSettings: [
{
columnKey: "codeName",
isGroupBy: true,
},
{
columnKey: "hour",
isGroupBy: false,
summaries: [
{
summaryFunction: "custom",
text: "Hours :",
customSummary: function (valuesList) {
var sumOfHours = 0.0;
var sumOfMinutes = 0.0;
for (i = 0; i < valuesList.length; i++) {
var split = valuesList[i].split(':');
sumOfHours += parseInt(split[0]);
sumOfMinutes += parseInt(split[1]);
}
sumOfHours += parseInt(sumOfMinutes / 60);
var minutesLeft = sumOfMinutes % 60;
return sumOfHours + ":" + minutesLeft;
}
}
]
}
],
summarySettings: {
//summaryFormat: "HH:MM" // What should I write here to get proper formatiing?
}
Now the problem is that whenever I get :
36 hours it displays 360.00 instead of 36:00
165 hours it displays 1,650.00 instead of 165:00
8 hours and 15 minutes it displays 815.00 insted of 8:15
34 hours and 15 minutes it displays as 3,415.00 instead of 34:15
I could not find anywhere in the docs how to display that properly. Can anybody help?
igGridGroupBy summary functions are expected to always return number type, which is not your case. That's why you see this behavior.
What you can do is to override the $.ig.formatter function (before initializing igGrid) which is used in Ignite UI and GroupBy feature for formatting values and inject your logic.
Here is an example:
var origFormatter = $.ig.formatter;
$.ig.formatter = function (val, type, format) {
if (format === "myFormat") {
return val;
}
return origFormatter.apply(arguments);
}
// Initialize igGrid here
And then set the summarySettings.summaryFormat = "myFormat" so that your logic kicks in.

Create vTiger Sales Order fails due to MANDATORY_FIELDS_MISSING "message":"Mandatory Fields Missing

I'm trying to create a SalesOrder via WebServices but it always fails due to missing mandatory fields.
I'm sending the following fields.
The error message does not specify the missing fields
I'm using vTiger 6.0.0
How can I figure it out
salesOrder.subject = fullDescription
salesOrder.sostatus = "delivered"
salesOrder.account_id ='11x28'
salesOrder.bill_street = shipping.address.street
salesOrder.bill_city = shipping.address.city
salesOrder.bill_state = shipping.address.state
salesOrder.bill_code = shipping.address.postalCode
salesOrder.bill_country = shipping.address.postalCode
salesOrder.ship_street = shipping.address.street
salesOrder.ship_city = shipping.address.city
salesOrder.ship_state = shipping.address.state
salesOrder.ship_code = shipping.address.postalCode
salesOrder.ship_country = shipping.address.postalCode
salesOrder.invoicestatus = "Created"
salesOrder.productid = selectedServices[0].id
salesOrder.quantity = 1
salesOrder.listprice = selectedServices[0].unit_price
//
salesOrder.comment= ""
salesOrder.tax1 = ""
salesOrder.tax2 = "10.000"
salesOrder.tax3 = "6.000"
salesOrder.pre_tax_total = "876.00"
salesOrder.currency_id = "21x1"
salesOrder.conversion_rate = "1.000"
salesOrder.tax4 = ""
salesOrder.duedate = "2014-12-12"
salesOrder.carrier = "FedEx"
salesOrder.pending = ""
salesOrder.txtAdjustment = "-21.00000000"
salesOrder.salescommission = "5.000"
salesOrder.exciseduty = "0.000"
salesOrder.hdnGrandTotal = "995.16000000"
salesOrder.hdnSubTotal = "876.00000000"
salesOrder.hdnTaxType = "group"
salesOrder.hdndiscountamount = "0"
salesOrder.hdnS_H_Percent = "21"
salesOrder.discount_percent = "25.000"
salesOrder.discount_amount = ""
salesOrder.terms_conditions = "- Unless "
salesOrder.enable_recurring = "0"
I was missing the LineItems. Please notice that it has to be CamelCase
"LineItems": [
{
"productid": "25x142",
"listprice": "299.00000000",
"quantity": "1"
}
],
you missed the mandatory field "Assigned TO"