Skip to content

Instantly share code, notes, and snippets.

@induprasad
induprasad / LAPP_DisplayChart.app
Created May 3, 2018
Application to Display the Chart component
View LAPP_DisplayChart.app
<aura:application extends="force:slds">
<c:LCMP_DisplayChart />
</aura:application>
@induprasad
induprasad / LCMP_DisplayChart.cmp
Created May 3, 2018
The LCMP_DisplayChart component used to send the values to be displayed to the strike component
View LCMP_DisplayChart.cmp
<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
Component which uses strike resources to draw the chart
View LCMP_StrikeChart.cmp
<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
Helper of the LCMP_DisplayChart component
View LCMP_DisplayChartHelper.js
({
//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
Controller of LCMP_DisplayChart component
View LCMP_DisplayChartController.js
({
getResponse: function(component, event, helper) {
helper.getCases(component);
}
})
@induprasad
induprasad / LCMP_DisplayChart.cmp
Created May 3, 2018
Component used to pass values to the strike component
View LCMP_DisplayChart.cmp
<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}" />
View LCMP_StrikeChart.css
.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
Renderer of the LCMP_StrikeChart component
View LCMP_StrikeChartRenderer.js
({
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
Helper of LCMP_StrikeChart component
View LCMP_StrikeChartHelper.js
({
//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 Apr 25, 2018
Controller of the LCMP_Strike component
View LCMP_StrikeChartController.js
({
//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);