Skip to content

Instantly share code, notes, and snippets.

View dranney-sugarcrm's full-sized avatar

David Ranney dranney-sugarcrm

View GitHub Profile
<?php
/**
* copy_prod_sqs_to_dev.php
*
* Now that heartbeats are sent to an SQS queue it's a lot harder to get test data. The dev SQS queue occasionally
* gets stuff from test on-demand instances. If you're trying to do testing that can mean waiting around for hours
* until maybe something comes in.
*
* This script simply takes everything currently in the production SQS queue and copies it to the dev SQS queue.
*
@dranney-sugarcrm
dranney-sugarcrm / api-chart-view.js
Created February 6, 2017 21:38
Full JavaScript for API example
({
plugins: ['Chart'],
className: 'api-chart-view',
chartDataArr: [],
total: 0,
initialize: function (options) {
this._super('initialize', [options]);
this.chart = nv.models.lineChart()
.x(function (d) {
return d.x;
@dranney-sugarcrm
dranney-sugarcrm / api-chart-view.js
Created February 6, 2017 21:35
Dynamically add elements to DOM and display new chart
({
...
renderChart: function () {
if (!this.isChartReady()) {
return;
}
var self = this;
var id_val = "";
var selector_str = "";
@dranney-sugarcrm
dranney-sugarcrm / api-chart-view.js
Created February 6, 2017 20:32
Call API to populate data
({
...
loadData: function() {
var self = this;
var url = app.api.buildURL('Accounts/get_line_chart_data');
app.api.call('read', url, null, {
success: function (response) {
_.each(response, function (data, key) {
self.chartDataArr.push(data);
});
<div id="chart-section">
</div>
@dranney-sugarcrm
dranney-sugarcrm / chartInfoAPI.php
Created February 6, 2017 20:23
Custom API to provide LineChart data
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
require_once 'clients/base/api/ModuleApi.php';
class chartInfoAPI extends ModuleApi
{
public function registerApiRest()
{
@dranney-sugarcrm
dranney-sugarcrm / multi-chart-view.js
Last active February 6, 2017 22:05
Make three calls to display three charts
({
...
renderChart: function () {
if (!this.isChartReady()) {
return;
}
d3.select(this.el).select('#example-chart1 svg')
.datum(this.bluered)
.transition().duration(500)
@dranney-sugarcrm
dranney-sugarcrm / multi-chart-view.js
Last active February 6, 2017 19:37
Populate data for multiple charts
({
...
loadData: function() {
this.bluered = {
data: [
{
key: "Blue Stuff",
values: [
{
x: 1, y: 10
@dranney-sugarcrm
dranney-sugarcrm / multi-chart-view.hbs
Created February 6, 2017 19:21
Set up handlebars file for a multi chart view
<div id="example-chart1">
<svg></svg>
</div>
<div id="example-chart2">
<svg></svg>
</div>
<div id="example-chart3">
<svg></svg>
</div>
@dranney-sugarcrm
dranney-sugarcrm / single-chart-view.js
Last active February 6, 2017 19:04
Complete single chart JavaScript file
({
plugins: ['Chart'],
className: 'single-chart-view',
chartData: {},
total: 0,
initialize: function (options) {
this._super('initialize', [options]);
this.chart = nv.models.lineChart()
.x(function (d) {
return d.widget_points;