Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@induprasad
induprasad / LAPP_DisplayChart.app
Created May 3, 2018 13:41
Application to Display the Chart component
<aura:application extends="force:slds">
<c:LCMP_DisplayChart />
</aura:application>
@induprasad
induprasad / LCMP_DisplayChart.cmp
Created May 3, 2018 13:30
The LCMP_DisplayChart component used to send the values to be displayed to the strike component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" controller="LCC_CaseResults">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<aura:attribute name="barData" type="Object[]" />
<aura:attribute name="accountName" type="String" default="" />
<aura:attribute name="divLength" type="String" default="4" />
<aura:attribute name="opencases" type="String" default="Open Cases" />
<aura:attribute name="closedcases" type="String" default="Closed Cases" />
<aura:attribute name="totalcases" type="String" default="Total Cases" />
@induprasad
induprasad / LCMP_StrikeChart.cmp
Created May 3, 2018 13:28
Component which uses strike resources to draw the chart
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" >
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<ltng:require scripts="/resource/StrikeCmpResource" afterScriptsLoaded="{!c.onInit}"/>
<aura:attribute name="scriptsLoaded" type="Boolean" default="{!false}"/>
<aura:attribute name="chartRendered" type="Boolean" default="{!false}" description="Flag to display the loading spinner."/>
<aura:attribute name="triggerRedraw" type="Boolean" access="private" default="{!false}" description="Flag that triggers redraw of the chart."/>
<aura:attribute name="displayAxis" type="Boolean" access="private" default="{!false}" description="Flag that triggers displaying the left and bottom axis labels."/>
@induprasad
induprasad / LCMP_DisplayChartHelper.js
Created May 3, 2018 13:23
Helper of the LCMP_DisplayChart component
({
//Generic Method to perform server calls
callToServer: function(component, method, callback, params) {
component.set("v.showSpinner", true);
var action = component.get(method);
action.setStorable();
if(params) {
action.setParams(params);
}
action.setCallback(this, function(response) {
@induprasad
induprasad / LCMP_DisplayChartController.js
Created May 3, 2018 13:20
Controller of LCMP_DisplayChart component
({
getResponse: function(component, event, helper) {
helper.getCases(component);
}
})
@induprasad
induprasad / LCMP_DisplayChart.cmp
Created May 3, 2018 13:18
Component used to pass values to the strike component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" controller="LCC_CaseResults">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<aura:attribute name="barData" type="Object[]" />
<aura:attribute name="accountName" type="String" default="" />
<aura:attribute name="divLength" type="String" default="4" />
<aura:attribute name="opencases" type="String" default="Open Cases" />
<aura:attribute name="closedcases" type="String" default="Closed cases" />
<aura:attribute name="totalcases" type="String" default="{!$Label.c.CLR417CCCTotalCases}" />
.THIS .sc-axis-label {
color: #bfbebe;
}
.THIS .sc-axis-value {
color: white;
font-size: 13px;
}
.THIS .sc-tooltip {
@induprasad
induprasad / LCMP_StrikeChartRenderer.js
Created May 3, 2018 13:03
Renderer of the LCMP_StrikeChart component
({
rerender: function (component, helper) {
this.superRerender();
if (!component.get('v.scriptsLoaded') || component.get('v.chartRendered')) {
return;
}
//make sure threshold isn't a string
component.get('v.thresholdValue', parseInt(component.get('v.thresholdValue')));
var containerWidth = component.find('chartContainer').getElement().clientWidth;
@induprasad
induprasad / LCMP_StrikeChartHelper.js
Created May 3, 2018 12:53
Helper of LCMP_StrikeChart component
({
//Function which draws the bar chart
barChart: function (component, helper) {
component.set('v.displayAxis', true);
var dataset = component.get("v.data"); //The data retrieved from the controller or parent component
var color = helper.getColors(); //Setting the colors to the bars
//Setting the orientation of the chart as vertical, can also be turned to horizontal
var isVertical = component.get('v.orientation') === 'vertical';
@induprasad
induprasad / LCMP_StrikeChartController.js
Last active April 25, 2018 06:33
Controller of the LCMP_Strike component
({
//Function called on Init
onInit: function (component, event, helper) {
var data = component.get("v.data");
component.set('v.scriptsLoaded', true);
component.set('v.triggerRedraw', !component.get('v.triggerRedraw'));
component.resize = $A.getCallback(function () {
if (component.isValid()) {
component.set('v.fontSize', helper.determineFontSize(component.get('v.containerWidth')));
component.set('v.chartRendered', false);