Notification

Icon
Error

How To Add A Google Line Chart Widget - Adding a Google Chart which reads data from a CSV File

Posted: Wednesday, November 11, 2020 5:02:23 PM(UTC)
Andy.S

Andy.S

Member Original PosterPosts: 38
0
Like
This may be of use to you if you want to include data from a 3rd party or trend style information not included in Lansweeper and draw a Google Chart to display the data, in the example below it displays AD information disabled / stale assets which would usually be automatically deleted from Lansweeper after 60 days, I run a powershell script to create a CSV file with data format (ADResults.CSV) :

Code:
Date,Total_Computers,Total_Computers_Enabled,Total_Computers_Disabled,Total_Servers,Total_Servers_Enabled,Total_Servers_Disabled,Total_Stale_Enabled_Assets_90_Days,Total_Newly_Created_24HRS
07/11/2020 12:00:00,2000,2300,100,200,140,176,22,13
08/11/2020 12:00:01,2010,2300,150,216,140,176,51,0
09/11/2020 11:13:28,2020,2301,110,219,143,176,41,4
09/11/2020 12:00:00,2000,2400,110,219,143,176,41,5


The Custome Widget is as follows, you will need to download loader.js and jquery.csv.js :

Code:
<%@ Page Language="C#" AutoEventWireup="true" Inherits="LS.BaseControl" %>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="LS.Enums" %>

<%@ Import Namespace="LS" %>

<% Response.CacheControl = "no-cache";%>

<% Response.AddHeader("Pragma", "no-cache"); %>

<% Response.Expires = -1; %>

<%  LS.User.Current().CheckUserWebsiteAccess(); %>



<script type="text/javascript" src="/WidgetsCustom/loader.js"></script> 

   <script src="/WidgetsCustom/jquery.csv.js"> </script>


<script type="text/javascript">
    google.load('visualization', '1.0', {'packages':['corechart']});
    google.setOnLoadCallback(BasicLine);

    function BasicLine() {
        $.get("/WidgetsCustom/ADResults.csv", function(csvString) {
            var arrayData = $.csv.toArrays(csvString, 
                                          {onParseValue: $.csv.hooks.castToScalar}),
                data      = new google.visualization.arrayToDataTable(arrayData),


    options = {
    title: 'Active Directory Asset Count',
    width: '100%',
    height: '100%',
    legend: {
        position: "right",color: "#000",
            fontName: "sans-serif",
            fontSize: 11
    },
    hAxis: {
        title: 'Date',
        titleTextStyle: {
            color: "#000",
            fontName: "sans-serif",
            fontSize: 16,
            bold: true,
            italic: false
 
        }
    },
    vAxis: {scaleType: 'log',
        title: 'Asset Count',
        titleTextStyle: { 
            color: "#000",
            fontName: "sans-serif",
            fontSize: 16,
            bold: true,
            italic: false
 
        }
    },
    annotations: {
        alwaysOutside: true,
        textStyle: {
            fontSize: 14,
            auraColor: 'none'
        }
    }
};
               
                chart     = new google.visualization
                              .LineChart(document.getElementById('chart_div'));
            chart.draw(data, options);
        },
        'text');
    }
</script>


    <div id="chart_div" style="width: 1500px; height: 800px;"></div>


 
<%  

              
;%>  

  








</div>




Active Discussions

Lansweeper Trying to make a custom report that sorts assets by state
by  mzipperer   Go to last post Go to first unread
Last post: Yesterday at 5:36:52 PM(UTC)
Lansweeper Report - All Assets with Specfic Default Gateway
by  RC62N  
Go to last post Go to first unread
Last post: Yesterday at 4:18:08 PM(UTC)
Report Center Windows update report
by  ToeJoe   Go to last post Go to first unread
Last post: 11/24/2020 3:39:00 PM(UTC)
Lansweeper Report - assets
by  Andy.S  
Go to last post Go to first unread
Last post: 11/23/2020 2:42:01 PM(UTC)
Report Center Default Browser and Version
by  hlee@fugro.com   Go to last post Go to first unread
Last post: 11/19/2020 3:50:51 PM(UTC)
Lansweeper Run Report on PCs from a list
by  RC62N  
Go to last post Go to first unread
Last post: 11/16/2020 4:23:12 PM(UTC)