DotNetSlackers: ASP.NET News for lazy Developers

Thursday, October 8, 2015

Generate semitransparent Stacked Range bar chart



This sample demonstrates one of the ways to generate semitransparent Stacked Range bar chart. 
The table consists of following columns and data 



This table data has to be represented in the graphical manner as below
  1. Gross and net as stacked bar charts,
  2. ExpectedPerformance to be shown as green/ red block depending on the scores last semester has
  3. If ExpectedPerformance > ScoreLastSemester display green block 
  4. If ExpectedPerformance < ScoreLastSemester display red block
  5. Since the ScoreLastSemester and ScoreCurrentSemester are stacked in chart, the ExpectedPerformance on top should be displayed as semitransparent
The solution for the above requirements is as below.
The sample is developed using Microsoft SQL Server 2012->Sql server data tools
Step 1. Create Report server Project
Step 2. Right click Shared Datasource
  1. Create new datasource pointing to correct database or used shared datasource. 
  2. Test the connection
Step 3. Right click dataset
  1. Create shared DataSet that uses newly created data source or use existing one
  2. Write the applicable Select query for the table
Step 4. Right click Reports
  1. Add->New Item -> Report-> give appropriate name to report and click ok
Step 5. Once the report is open,
  1. Right click on the design area
  2. Insert Chart, select the Stacked Bar chart
  3. Choose the proper dataset
  4. Drag and drop the chart wherever applicable, resize if needed
Step 6. To achieve the stacked bar chart for the score last and current semester
  1. Drag and drop the two fields ScoreLastSemester, ScoreCurrentSemester in the values of Chart Data(you get this option when you click on chart)
  2. Drag and drop the Subject in the Category groups
    c. Preview the report. By default we get the preview as follows

        
  3. Step 7. To customize the graph for the values and colors for the scores last and current year
    a. Select item from values, right click -> Select series Properties
    b. For ScoreLastSemester -> Change value field [Sum(ScoreLastSemester)] to [ScoreLastSemester]
        Go to Axes and Chart Area, change the horizontal axis from Primary to secondary
    c. For ScoreCurrentSemester -> Change value field [Sum(ScoreCurrentSemester)] to [ScoreCurrentSemester]
    d. Click on ScoreLastSemester in the Properties, change the color from Automatic to CornflowerBlue(or any preferred)
    e. Click on ScoreCurrentSemester in the properties, change the color from Automatic to LightGrey(or any preferred)



    Step 8. To get the Expected performance to display green/red based on the value of score last and current year
    a. Select the Chart->Chart Data -> Values Click on + sign to add the ExpectedPerformance column
    This is alternative to drag and drop it from the report Data-> dataset section to Chart Data->Values section
      




    Step 9. Go to Series Properties of ExpectedPerformance column
    a. For ExpectedPerformance -> Change value field [Sum(ExpectedPerformance)] to [ExpectedPerformance]
    b. Go to Axes and Chart Area, change the vertical axis from Primary to secondary
    Step 10. While on Series properties of ExpectedPerformance
    a. Change the Chart type to Range type
    b. Click on the low that got added to the ExpectedPerformance
      
    c. Click Expression and type
    =Fields!ExpectedPerformance.Value-(Fields!ExpectedPerformance.Value-Fields!ScoreLastSemester.Value)
    d. Set the Color as Expression below
    =switch (Fields!ExpectedPerformance.Value - Fields!ScoreLastSemester.Value >0,"Green" , Fields!ExpectedPerformance.Value-Fields!ScoreLastSemester.Value<0,"Red")
    e. Go to preview, the green and red bars overlap the Score values. So there is need to set it semi transparent




    Step 11. To get the Semitransparent effect

    a. Go to Chart Properties-> Set the Palette property to SemiTransparent
    b. Change the ExpectedPerformance color to No Color
    The Preview will show default color for ExpectedPerformance with semitransparent effect
    c. To set the color back to Green/Red depending on the ScoreLastSemester value,
    Set the ExpectedPerformance
    BackgroundgradientEndcolor to =switch (Fields!ExpectedPerformance.Value-Fields!ScoreLastSemester.Value >0,"Green" , Fields!ExpectedPerformance.Value-Fields!ScoreLastSemester.Value<0,"Red")
    BackgroundGradientType to DiagonalLeft
    d. The data labels can be displayed on the chart by using show data labels for respective values
    e. The Chart titles and Axis titles can be changed by setting appropriate properties
    Preview is as below
     



Wednesday, October 7, 2015

Search API – Orchard Harvest 2015

In which we figure out the amount of a narcissist Sébastien truly is: he watches his own particular sessions from earlier years, and takes in a great deal doing as such ;)

Seek in Orchard is executed through three modules:

Orchard.Indexing recognizes changes from substance handlers, procedures changes in a foundation undertaking, and designs lists in the dashboard.

Lucene executes filed substance and hunt over the Lucene library.

Orchard.Search showcases query items on the front end and in the dashboard.

In Orchard.Search, there is a formula that sets up a file on all pages and blog entries in the website. It's a snappy and simple approach to setup seek on your site. The other method for doing this is to physically make a record from the dashboard and after that design pursuit to utilize it.

Inquiry can likewise be arranged to show things in indexed lists utilizing an alternate showcase sort than the default "Synopsis". This makes it conceivable to totally tweak the using so as to render of indexed lists the relating interchange format.

It is conceivable to make a different list to use with pursuit from the dashboard. This is helpful if the front-end has unpublished substance that ought not be appeared on the front-end, but rather ought to completely be discovered when seeking from the dashboard.

Making separate files can likewise be valuable on the off chance that you need to actualize focused on inquiry, for instance a learning base hunt that is unique in relation to an item seek.

On the off chance that you need to execute custom indexing of substance from code, you can make a handler and call OnIndexing<SomePart> with a Lambda that characterizes how to record a given part. This is the manner by which the TermsPart in scientific categorizations can record scientific classification terms. This is additionally how the body part gets disinfected to uproot HTML label markup before indexing.

Luke.net is an application that peruses Lucene lists. This is a pleasant approach to check if and how a file was manufactured.

ISearchService gives you a chance to perform seeks on an Orchard file from code, while IIndexProvider gives you a chance to actualize custom records rather than Lucene.

Sébastien demonstrated to make a custom pursuit API controller that questions the record, applies some faceted channels and custom request, then yields the outcomes as a JSON archive. The faceted pursuit is done utilizing GetBits on the hunt manufacturer. You can approach the aftereffect of that for the quantity of results that match any specific worth for the feature. This is the way destinationido.com executed its faceted hunt.

At last, Seb demonstrated to do geolocated seeks, which I had no clue Lucene could do. Obviously you can, the length of you have arranges: quite recently check every file section from your quest developer for the separation with the point you are attempting to channel around.

All these custom channels are being connected against the file, instead of the genuine database, so it's all quick. This is truth be told genuinely near the guide/diminish APIs that are accessible in DecentCMS and the Orchard 2.0 models.

Furthermore, the jetlag is at last kicking in. Unless it's Sébastien who made me so sluggish. This blog entry was composed while dozing, so on the off chance that you detect any glaring errors, how about we point the finger at it on th

DOT NET MVC 6 Tag Helpers

Taylor Mullen was here to present the label assistants that will be added to ASP.NET MVC 6, fundamentally to supplant HTML partners. Label aides are html tag-like bits of C# code. Since they are basically C#, you can get every one of the advantages of the IDE, for example, IntelliSense and refactoring.

Out of the container, there will be label assistants for structures, names, inputs, that comprehend extra properties. For instance, <label asp-for="Email"> will carry on like @Html.LabelFor(m => m.Email).

The <environment> tag can shroud or show parts of the page in light of environment variables, for example, investigate mode.

A typical perception is that these label aides are doing on the server side what Angular does on the customer side.

Label aide source code can as of now be found in the MVC source code repo:

https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNet.Mvc.TagHelpers

To start utilizing label aides as a part of all perspectives, they can be added to _ViewImports.cshtml with a couple utilizing and @AddTagHelpers orders.

With a specific end goal to fabricate a label aide, you should do nothing more than actualize ITagHelper. This interface has an Order perused just property, and a ProcessAsync system that does the genuine work.

public class EmailTagHelper: TagHelper {
  public string MailTo {get;set;}
  public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) {
    output.TagName = "a";
    var email = MailTo + "@contoso.com";
    output.Attributes["href"] = "mailto:" + email;
    output.Content.SetContent(MailTo);

    return base.ProcessAsync(context, output);
  }
}
This can then be used as follows:
<email mail-to="support"><email/>
 
Next, Taylor demonstrated to fabricate a markdown label assistant. This one 
uses the label's substance as the information for the markdown. Since Razor 
is currently completely offbeat, he needs to understand that substance utilizing 
anticipate context.GetChildContent(). 

After that, Taylor indicated how see segments can actualize something like 
Orchard's shapes, utilizing label aides for more pleasant markup. His label 
assistant is getting IViewComponentHelper as a constructor-infused reliance, 
and after that utilizing that to conjure his shape-like perspective segment. 
 
He additionally needed to do property infusion for his perspective connection.
The entire thing is somewhat more unpredictable than Orchard's shapes, however
he get full IntelliSense on the label assistant. It additionally makes it 
conceivable to have discretionary C# expressions in property estimations.
The included many-sided quality included appears as though it could without 
much of a stretch be settled with a decent base class. 

Taylor then demonstrated to change his markdown label aide into a label 
characteristic aide, with the goal that you can do <ul markdown> and have the 
label's substance be sustained into the markdown parser utilizing a 
[HtmlTargetElement("*", Attributes("markdown")] quality. 

In the event that you need to conceal a property from the label aide, you can 
utilize [HtmlAttributeNotBound]. 

On account of the way label assistants are architected, as bits of C# that 
improve the perspective code, it is conceivable to have more than one label
aide focusing on the same HTML component. Taylor showed that by applying a 
Bold and the markdown label assistant that he made some time recently.
This clarifies why the label partner interface has an Order property.