Sencha touch charts 2: Dynamically create chart and load series from the store? - charts

I want to create a scatter chart dynamically and load the series by fetching the data from the store. Is there any method to do that? I did the following:
var myChart = Ext.create('Ext.chart.Chart',{
id:'myChart',
renderTo:'myPanel',
axes:[], // blank because i need to add axes from store
series:[] // blank because i need to add series from store
:
:
});
for(conditions){
myChart.config.axes[0].fields.push(record[cnt].data.fieldName);
var series = {
type:'scatter',
axis:['right', 'bottom'],
xField:'myXfield',
yField:record[cnt].data.yfieldVal
}
myChart.config.series.push(series);
}//for loop ends
myChart.redraw();
Iam not able to see the chart with the plots that are dynamically added.
Any help will be appriciated!
Thanks!

I realized how to address the issue. I declared Global variables for the store name and other related fields. I created the get and set methods. These are defined in app.js file. I was able to set the values dynamically to these global variables using set methods and use the assigned values using the get methods. I hope someone will be able to use this technique if required.

Related

Adding and removing Measures dynamically in sapui5 VizFrame

I would like to change Measures dynamically in my VizFrame like in ChartDemo App from sapui5 docs [link below].
https://sapui5.netweaver.ondemand.com/test-resources/sap/viz/demokit/chartdemo/index.html
So when I click to one of my five checkboxes the proper Measure will be added or removed in case of unchecking.
I have one json from which I get data.
I've tried with this code:
if(oCheckBox.getSelected()){
oVizFrame.removeFeed(feedValuesAxis);
feedValuesAxis.setValues("ValueFromJSON");
oVizFrame.addFeed(feedValuesAxis);
}
But it causes error:
[50005] - valueAxis : does not meet the minimum or maximum number of
feeds definition.
I am using SAP UI5 version 1.28.
I have one VizFrame, one Dataset with all Measures and two FeedItem one for values and one for Dimension.
I guess I have to create a binding, right? But how should I do it? Thanks a lot for any pieces of advice.
Simply, I have missed array when putting value into setValues() method.
So the answer is:
feedValuesAxis.setValues(["ValueFromJSON"]);

Get all series from a chart with Google Apps Script

I have a sheet with 30 charts and I'm trying to iterate over all of them updating the colors of the background and the series.
Even though I could do it blindly, I'd rather be able to look at all the series in a chart first so that I could add extra logic based on the number of series, if it is already using one of my custom colors, title, etc. The problem is that I couldn't find a way to get the series from a chart.
Given that I can modify the series with setOptions I thought something like sheet.getCharts()[0].getOptions().get('series') would work, but it returns Access to class "(class)" is prohibited. when I try to log it.
Any advice on how to get an object where I can read information about the series in a chart?
its like hashmap (key/value) when you set option put key and value and when you get it try to use json to get the oject value too
function myfunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var len = sheet.getCharts().length;
for(var i=0;i<len;i++){
var bg=sheet.getCharts()[i].getOptions().get('backgroundColor.fill');
var s=sheet.getCharts()[i].getOptions().get('series.0.color');
}
}

ZK Charts, clearing the chart

I am using ZK charts in my project. I am having line type charts. And using addSeries on my chats. But when I want refresh charts as in when user if fetching new Data, I am not sure how to clear the graph. Please help.
For example, if you are using series to add points on the chart (in my example I am using Float values) you can empty data displayed by setting an empty list to the series, like this:
chart.getSeries().setData(new ArrayList<Float>());
this one worked for me,
just write this line before populating your chart
chart.getSeries().setData(0);
To do that just call the method
chart.invalidate();

Sugarcrm calculated field

I am using Version 6.5.16 (Build 1082) of sugarcrm, I created 2 fields Points redeemed and Accumulated points. I would want to create another field balance point (Accumulated points-points redeemed), may I know how do I use the calculated field to calculate the balance point which will generate automatically when i key in point redeem and accumulated point?
click the "calculated value" checkbox for the field definition in Studio, edit the formula for the calculated field
subtract($accumulated_points_c,$redeemed_points_c)
(change the field names to match yours)
Without Sugar Logic you'll need to create JavaScript on the page to do this. See this page for adding JavaScript to views: https://www.atcoresystems.com/blog/adding-custom-javascript-to-a-sugarcrm-view
If you can adjust your requirement and do this calculation upon saving the record instead of doing it live on the page, you can use a logic hook. I find these to be much cleaner and easier. Create your logic file:
<?php
// custom/modules/MyModule/calc_balance_points.php
class calc_balance_point{
function calc_balance_point(&$bean,$event,$args){
$bean->balance_point_c = $bean->accumulated_points_c - $bean->redeemed_points_c;
}
}
Then adjust your logic hook definition to include it. This file likely already exists, so add this reference to the before_save hooks
<?php
// custom/modules/MyModule/logic_hooks.php
$hook_array = Array();
$hook_array['before_save'] = Array();
$hook_array['before_save'] = Array(1,'Calculate Points Balance','custom/modules/MyModule/calc_balance_points.php','calc_balance_point','calc_balance_point');
Also I found a good article about adding custom calculated fields.
http://forums.sugarcrm.com/attachments/f3/9793d1361300845-calculated-field-sugarcrm-ce-customagingfield.pdf
From this forum discussion
http://forums.sugarcrm.com/f3/calculated-field-sugarcrm-ce-85291/

dojox chart update/destroy does not work after dojo.byId

I created a dojo chart using;
var pieChart = new dojox.charting.Chart2D("pieChart");
Afterwards I want to update/destroy this chart. SO I do;
var pieChart = dojo.byId("pieChart");
pieChart.destroy();
This seems to be not functional. Am I doing something wrong here?
best
I ran into this same problem, where I created the chart in one place and then wanted to destroy it in another, but I didn't have a reference to the chart object. The only solution I found is to empty the DOM node you used to make the chart:
dojo.empty("pieChart");
As you're using dojox so dojo.byId will not return javascript object try using dijit.byId I think it'll work as suggested below:
var pieChart = dijit.byId("pieChart");
pieChart.destroy();
the same problem I was facing with dojox.form.BusyButton after a great effort I found this...
The second variable will reference DOM object, not the javascript object that store chart object.
var pieChart = new dojox.charting.Chart2D("pieChart");
pieChartDom = dojo.byId("pieChart"); //you cannot destroy,
pieChart.destroy(); //you can destroy, this is original variable
I hope it helps.