问:
SfCharts not displaying using Xamarin forms for windows 8.1
Hi i am just trying to display a simple chart using syncfusion in my windows application in Xamarin forms. The code i currently have compiles fine however when i run it only a blank screen is displayed.
here is the code i have:</p>

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Syncfusion.SfChart.XForms;
using Syncfusion.Compression;

namespace WiMation.SMAG.Desktop.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class PatrolReport : ContentPage
    {
        public PatrolReport()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);
            this.BindingContext = new ViewModel();

            SfChart chart = new SfChart();

            //Initializing Primary Axis
            CategoryAxis primaryAxis = new CategoryAxis();

            chart.PrimaryAxis = primaryAxis;

            //Initializing Secondary Axis
            NumericalAxis secondaryAxis = new NumericalAxis();

            chart.SecondaryAxis = secondaryAxis;

            Content = chart;
        }
   }
}
</code>```

答:
Syncfusion has stopped to providing support for Xamarin Forms.Windows 8.1 and Xamarin Forms Windows Phone from product version v14.3.0.52
This is mentioned in their release notes
Link:https://help.syncfusion.com/xamarin/release-notes/v14.4.0.15?type=all#common

So, if you have installed any of product version above v14.3.0.52, Syncfusion.SfChart.WinRT and Syncfusion.SfChart.XForms.WinRT assemblies will not available in your Windows 8.1 project. Therefore, SfChart has not been displayed in output.

If you want to use Xamarin.Forms Windows 8.1, then you must use product version v14.3.0.52. So that, Syncfusion.SfChart.WinRT and Syncfusion.SfChart.XForms.WinRT assemblies will be included in your Windows 8.1 project.

Otherwise, you can Xamarin.Forms UWP platform instead of Windows 8.1.

Body:
Hi i am just trying to display a simple chart using syncfusion in my windows application in Xamarin forms. The code i currently have compiles fine however when i run it only a blank screen is displayed.
here is the code i have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Syncfusion.SfChart.XForms;
using Syncfusion.Compression;

namespace WiMation.SMAG.Desktop.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class PatrolReport : ContentPage
    {
        public PatrolReport()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);
            this.BindingContext = new ViewModel();

            SfChart chart = new SfChart();

            //Initializing Primary Axis
            CategoryAxis primaryAxis = new CategoryAxis();

            chart.PrimaryAxis = primaryAxis;

            //Initializing Secondary Axis
            NumericalAxis secondaryAxis = new NumericalAxis();

            chart.SecondaryAxis = secondaryAxis;

            Content = chart;
        }
   }
}


来源: stackexchange

问:
Grouping and remove from list
I have following type

```<code>public class Parameter
{
   public string Name {get;set;}
   public string PathType {get;set;}
}
</code>```

My parameter list like:

```<code>List<Parameter> params = new List<Parameter>();
params.Add(new Parameter{ Name ="A", PathType ="path" });
params.Add(new Parameter{ Name ="B", PathType ="query" });
params.Add(new Parameter{ Name ="C", PathType ="path" });
params.Add(new Parameter{ Name ="C", PathType ="query" });
params.Add(new Parameter{ Name ="D", PathType ="path" });
params.Add(new Parameter{ Name ="D", PathType ="query" });
params.Add(new Parameter{ Name ="D", PathType ="body" });
</code>```

I need to find parameters that have the same Name (like: C and D) where PathType equals path and query. Sorry for my English, it is a little bit difficult to explain. I want to find

```<code> Name ="C", PathType ="path"
 Name ="C", PathType ="query"
 Name ="D", PathType ="path"
 Name ="D", PathType ="query"
</code>```

Then remove all where PathType = "query". Finally result should be

```<code>Name ="A", PathType ="path"
Name ="B", PathType ="query"
Name ="C", PathType ="path"
Name ="D", PathType ="path"
Name ="D", PathType ="body"
</code>```

My code

```<code>var groupedParams = params.GroupBy(a => a.Name, StringComparer.InvariantCultureIgnoreCase).ToDictionary(t => t.Key);
foreach (var parameter in params) {
    if (groupedParams.ContainsKey(parameter.Name)) {
        var temp = groupedParams[parameter.Name];
        if (temp.Count(x => x.PathType.ToLower() == "path") == 1 && temp.Count(x => x.PathType.ToLower() == "query") == 1) {
            params.Remove(parameter);
        }
    }
}
</code>```

I need to group by name but remove only when there are path and query for that name.
Please suggest how can I do in in other way? Thanks

答:
You could do that with this LINQ statement:</p>

```<code>var cleanedParams = params.Where(p => p.PathType != "query" ||
    !params.Any(p2 => p2.Name == p.Name && p2.PathType != "query")).ToList();
</code>```

ContentLicense: CC BY-SA 3.0

Title: Grouping and remove from list

Body:
I have following type

public class Parameter
{
   public string Name {get;set;}
   public string PathType {get;set;}
}

My parameter list like:

List<Parameter> params = new List<Parameter>();
params.Add(new Parameter{ Name ="A", PathType ="path" });
params.Add(new Parameter{ Name ="B", PathType ="query" });
params.Add(new Parameter{ Name ="C", PathType ="path" });
params.Add(new Parameter{ Name ="C", PathType ="query" });
params.Add(new Parameter{ Name ="D", PathType ="path" });
params.Add(new Parameter{ Name ="D", PathType ="query" });
params.Add(new Parameter{ Name ="D", PathType ="body" });

I need to find parameters that have the same Name (like: C and D) where PathType equals path and query. Sorry for my English, it is a little bit difficult to explain. I want to find

 Name ="C", PathType ="path"
 Name ="C", PathType ="query"
 Name ="D", PathType ="path"
 Name ="D", PathType ="query"

Then remove all where PathType = "query". Finally result should be

Name ="A", PathType ="path"
Name ="B", PathType ="query"
Name ="C", PathType ="path"
Name ="D", PathType ="path"
Name ="D", PathType ="body"

My code

var groupedParams = params.GroupBy(a => a.Name, StringComparer.InvariantCultureIgnoreCase).ToDictionary(t => t.Key);
foreach (var parameter in params) {
    if (groupedParams.ContainsKey(parameter.Name)) {
        var temp = groupedParams[parameter.Name];
        if (temp.Count(x => x.PathType.ToLower() == "path") == 1 && temp.Count(x => x.PathType.ToLower() == "query") == 1) {
            params.Remove(parameter);
        }
    }
}

I need to group by name but remove only when there are path and query for that name.
Please suggest how can I do in in other way? Thanks

Body:
You could do that with this LINQ statement:

var cleanedParams = params.Where(p => p.PathType != "query" ||
    !params.Any(p2 => p2.Name == p.Name && p2.PathType != "query")).ToList();


问:
How would you tail call optimize this Clojure function that builds a tree?
I have some maps

```<code>(def m1 [{:a 1, :b 2, :c 0}
         {:a 1, :b 3, :c 0}
         {:a 1, :b 0, :c 2}
         {:a 1, :b 3, :c 1}
         {:a 1, :b 0, :c 3}])
</code>```

which I can recursively group with this function

```<code>(defn group [ks coll]
  (if (empty? ks) coll
      (let [gs (group-by #(select-keys % [(first ks)]) coll)]
        (map (fn [[k v]] {k (group (rest ks) v)}) (dissoc gs {})))))
</code>```

to produce the expected result:

```<code>(group [:a :b :c] m1)
</code>```

=>

```<code>({{:a 1} ({{:b 2} ({{:c 0} [{:a 1, :b 2, :c 0}]})}
          {{:b 3} ({{:c 0} [{:a 1, :b 3, :c 0}]}
                   {{:c 1} [{:a 1, :b 3, :c 1}]})}
          {{:b 0} ({{:c 2} [{:a 1, :b 0, :c 2}]}
                   {{:c 3} [{:a 1, :b 0, :c 3}]})})})
</code>```

How could you rewrite a function like this that has map in the last position as it needs to follow multiple paths, to be tail call optimized using recur?

答:
Well, it turns out to be surprisingly complex.  I managed to implement something like the above using loop/recur, but I had to introduce a bunch of helper functions to keep it somewhat readable:

```<code>(defn group-recur [ks coll]
  (let [split-map (fn [m]
                    (->> m
                         (into [])
                         (map (partial apply hash-map))))
        dissoc-non-map (fn [m k]
                         (let [l (drop-last k)]
                           (if-not (map? (get-in m k))
                             (if (empty? l)
                               (dissoc m (last k))
                               (update-in m l dissoc (last k)))
                             m)))
        updater (fn [r k v]
                  (let [s (split-map k)]
                    (-> r
                        (dissoc-non-map (drop-last s))
                        (assoc-in s v))))]
  (loop [k ks
         h []
         r {}]
    (if (not-empty k)
      (let [all (conj h (first k))
            grouped (dissoc (group-by #(select-keys % all) coll) {})]
        (->> grouped
             (reduce-kv updater r)
             (recur (rest k)
                    all)))
      r))))
</code>```

It returns a tree of maps, instead of the collections you used above (which I think is more logical).  The basic premise is that you pass along the result map and update it as you go along.  That's why the dissoc-non-map is there, appareantly you can't assoc-in in a map if there is already another non-map value present on a higher level.

The loop requires 3 arguments: the list of keys still to process, the key/value pairs that we've currently processed (i.e. the current "position in the tree" if you will) and the resulting map tree.

An alternative (an possibly simpler) implementation could pass along two maps: one with the final result, and one with the intermediate values.  That should eliminate the need for the dissoc-non-map.

Body:
I have some maps

(def m1 [{:a 1, :b 2, :c 0}
         {:a 1, :b 3, :c 0}
         {:a 1, :b 0, :c 2}
         {:a 1, :b 3, :c 1}
         {:a 1, :b 0, :c 3}])

which I can recursively group with this function

(defn group [ks coll]
  (if (empty? ks) coll
      (let [gs (group-by #(select-keys % [(first ks)]) coll)]
        (map (fn [[k v]] {k (group (rest ks) v)}) (dissoc gs {})))))

to produce the expected result:

(group [:a :b :c] m1)

=>

({{:a 1} ({{:b 2} ({{:c 0} [{:a 1, :b 2, :c 0}]})}
          {{:b 3} ({{:c 0} [{:a 1, :b 3, :c 0}]}
                   {{:c 1} [{:a 1, :b 3, :c 1}]})}
          {{:b 0} ({{:c 2} [{:a 1, :b 0, :c 2}]}
                   {{:c 3} [{:a 1, :b 0, :c 3}]})})})

How could you rewrite a function like this that has map in the last position as it needs to follow multiple paths, to be tail call optimized using recur?

Body:
Well, it turns out to be surprisingly complex.  I managed to implement something like the above using loop/recur, but I had to introduce a bunch of helper functions to keep it somewhat readable:

(defn group-recur [ks coll]
  (let [split-map (fn [m]
                    (->> m
                         (into [])
                         (map (partial apply hash-map))))
        dissoc-non-map (fn [m k]
                         (let [l (drop-last k)]
                           (if-not (map? (get-in m k))
                             (if (empty? l)
                               (dissoc m (last k))
                               (update-in m l dissoc (last k)))
                             m)))
        updater (fn [r k v]
                  (let [s (split-map k)]
                    (-> r
                        (dissoc-non-map (drop-last s))
                        (assoc-in s v))))]
  (loop [k ks
         h []
         r {}]
    (if (not-empty k)
      (let [all (conj h (first k))
            grouped (dissoc (group-by #(select-keys % all) coll) {})]
        (->> grouped
             (reduce-kv updater r)
             (recur (rest k)
                    all)))
      r))))

It returns a tree of maps, instead of the collections you used above (which I think is more logical).  The basic premise is that you pass along the result map and update it as you go along.  That's why the dissoc-non-map is there, appareantly you can't assoc-in in a map if there is already another non-map value present on a higher level.

The loop requires 3 arguments: the list of keys still to process, the key/value pairs that we've currently processed (i.e. the current "position in the tree" if you will) and the resulting map tree.

An alternative (an possibly simpler) implementation could pass along two maps: one with the final result, and one with the intermediate values.  That should eliminate the need for the dissoc-non-map.


问:
How to propagate -Verbose to module functions?
According to answers like this one and my own experience, Powershell can take care of propagating -Verbose (and -Debug) automatically, which is very convenient. However this stops working when the functions which I want to propagate verbosity to are in a module. Code used for testing this:

Create a directory called Mod somewhere, suppose in c:, and add 2 files:

File c:\Mod\Functions.ps1:

```<code>function Show-VerbosityB { [cmdletbinding()]Param()
  Write-Output "Show-VerbosityB called"
  Write-Verbose "Show-VerbosityB is Verbose"
}
</code>```

File c:\Mod\Mod.psd1:

```<code>@{
ModuleVersion = '1.0.0.0'
NestedModules = @('Functions.ps1')
FunctionsToExport = @('*-*')
}
</code>```

Now crate the main script, say c:\Foo.ps1:

```<code>Import-Module c:\Mod

function Show-VerbosityA { [cmdletbinding()]Param()
  Write-Output "Show-VerbosityA called"
  Write-Verbose "Show-VerbosityA is Verbose"
}

function Show-Verbosity { [cmdletbinding()]Param()
  Write-Output "Show-Verbosity called"
  Write-Verbose "Show-Verbosity is Verbose"
  Write-Output "Testing propagation"
  Show-VerbosityA
  Show-VerbosityB
}

Show-Verbosity -Verbose
</code>```

Results in

```<code>PS> . C:\Foo.ps1
Show-Verbosity called
VERBOSE: Show-Verbosity is Verbose
Testing propagation
Show-VerbosityA called
VERBOSE: Show-VerbosityA is Verbose
Show-VerbosityB called
</code>```

Why is the Write-Verbose in the module's function skipped, why does propagation not behave like it does for Show-VerbosityA? (If I just dot-source Functions.ps1 instead of importing the module, the line VERBOSE: Show-VerbosityB is Verbose is printed). I could make propagation manual by e.g. calling Show-VerbosityB -Verbose:$PSBoundParameters['Verbose']. Or are there other, preferrably shorter, ways? It is quite messy if functions behave differently depending on whether they are part of a module or dot-sourced.

答:
The reason this is happening is because the $VerbosePreference is not propagated when the module is called.
I modified your script to explicitly print the value at the same points you are outputting via Write-Verbose and Write-Output.

This powershell.org post proposes adding this to the module, which worked like a charm for me:

```<code>if (-not $PSBoundParameters.ContainsKey('Verbose'))
{
    $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference')
}
</code>```

One of the comments mentions bug report with link (it doesn't exist or I don't have permissions to view)

The issue is discussed in a TechNet post, with a link to a Get-CallerPreferance function that addresses this issue.

Module:

```<code>function Show-VerbosityB { [cmdletbinding()]Param()

    <# uncomment to get verbose preference from caller, when verbose switch not explicitly used.
    if (-not $PSBoundParameters.ContainsKey('Verbose'))
    {
        $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference')
    }
    #>

    Write-Output "`nShow-VerbosityB called"
    Write-output "Global pref: $($global:VerbosePreference)"
    Write-output "Script pref: $($script:VerbosePreference)"
    Write-output "Effect pref: $VerbosePreference"
    Write-Verbose "Show-VerbosityB is Verbose"
}
</code>```

Caller:

```<code>Import-Module C:\Mod

Write-output "On startup: $VerbosePreference"

function Show-VerbosityA { [cmdletbinding()]Param()
  Write-Output "`nShow-VerbosityA called"
  Write-output "Global pref: $($global:VerbosePreference)"
  Write-output "Script pref: $($script:VerbosePreference)"
  Write-output "Effect pref: $VerbosePreference"
  Write-Verbose "Show-VerbosityA is Verbose"
}

function Show-Verbosity { [cmdletbinding()]Param()
  Write-Output "`nShow-Verbosity called"
  Write-output "Global pref: $($global:VerbosePreference)"
  Write-output "Script pref: $($script:VerbosePreference)"
  Write-output "Effect pref: $VerbosePreference"
  Write-Verbose "Show-Verbosity is Verbose"
  Write-Output "`nTesting propagation"
  Show-VerbosityA
  Show-VerbosityB
}

Show-Verbosity -Verbose
</code>```

Body:
According to answers like this one and my own experience, Powershell can take care of propagating -Verbose (and -Debug) automatically, which is very convenient. However this stops working when the functions which I want to propagate verbosity to are in a module. Code used for testing this:

Create a directory called Mod somewhere, suppose in c:, and add 2 files:

File c:\Mod\Functions.ps1:

function Show-VerbosityB { [cmdletbinding()]Param()
  Write-Output "Show-VerbosityB called"
  Write-Verbose "Show-VerbosityB is Verbose"
}

File c:\Mod\Mod.psd1:

@{
ModuleVersion = '1.0.0.0'
NestedModules = @('Functions.ps1')
FunctionsToExport = @('*-*')
}

Now crate the main script, say c:\Foo.ps1:

Import-Module c:\Mod

function Show-VerbosityA { [cmdletbinding()]Param()
  Write-Output "Show-VerbosityA called"
  Write-Verbose "Show-VerbosityA is Verbose"
}

function Show-Verbosity { [cmdletbinding()]Param()
  Write-Output "Show-Verbosity called"
  Write-Verbose "Show-Verbosity is Verbose"
  Write-Output "Testing propagation"
  Show-VerbosityA
  Show-VerbosityB
}

Show-Verbosity -Verbose

Results in

PS> . C:\Foo.ps1
Show-Verbosity called
VERBOSE: Show-Verbosity is Verbose
Testing propagation
Show-VerbosityA called
VERBOSE: Show-VerbosityA is Verbose
Show-VerbosityB called

Why is the Write-Verbose in the module's function skipped, why does propagation not behave like it does for Show-VerbosityA? (If I just dot-source Functions.ps1 instead of importing the module, the line VERBOSE: Show-VerbosityB is Verbose is printed). I could make propagation manual by e.g. calling Show-VerbosityB -Verbose:$PSBoundParameters['Verbose']. Or are there other, preferrably shorter, ways? It is quite messy if functions behave differently depending on whether they are part of a module or dot-sourced.

Body:
The reason this is happening is because the $VerbosePreference is not propagated when the module is called.
I modified your script to explicitly print the value at the same points you are outputting via Write-Verbose and Write-Output.

This powershell.org post proposes adding this to the module, which worked like a charm for me:

if (-not $PSBoundParameters.ContainsKey('Verbose'))
{
    $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference')
}

One of the comments mentions bug report with link (it doesn't exist or I don't have permissions to view)

The issue is discussed in a TechNet post, with a link to a Get-CallerPreferance function that addresses this issue.

Module:

function Show-VerbosityB { [cmdletbinding()]Param()

    <# uncomment to get verbose preference from caller, when verbose switch not explicitly used.
    if (-not $PSBoundParameters.ContainsKey('Verbose'))
    {
        $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference')
    }
    #>

    Write-Output "`nShow-VerbosityB called"
    Write-output "Global pref: $($global:VerbosePreference)"
    Write-output "Script pref: $($script:VerbosePreference)"
    Write-output "Effect pref: $VerbosePreference"
    Write-Verbose "Show-VerbosityB is Verbose"
}

Caller:

Import-Module C:\Mod

Write-output "On startup: $VerbosePreference"

function Show-VerbosityA { [cmdletbinding()]Param()
  Write-Output "`nShow-VerbosityA called"
  Write-output "Global pref: $($global:VerbosePreference)"
  Write-output "Script pref: $($script:VerbosePreference)"
  Write-output "Effect pref: $VerbosePreference"
  Write-Verbose "Show-VerbosityA is Verbose"
}

function Show-Verbosity { [cmdletbinding()]Param()
  Write-Output "`nShow-Verbosity called"
  Write-output "Global pref: $($global:VerbosePreference)"
  Write-output "Script pref: $($script:VerbosePreference)"
  Write-output "Effect pref: $VerbosePreference"
  Write-Verbose "Show-Verbosity is Verbose"
  Write-Output "`nTesting propagation"
  Show-VerbosityA
  Show-VerbosityB
}

Show-Verbosity -Verbose


问:
Disabled points not hide. [Highcharts]
nice to meet you.
I have a problem with my Chart.

I have a DB with some hiring process data. The process have many status: "ENDED","WORKING","STANDBY","CANCELLED". The process only have once at time.

I needed to use Stacked Column because if used normal one it let me tiny bars.

I have got all I wanted, but when I click in legend, the data category remains if there are not in the extremes.

Here the gif showing what I mean

And here's the code:

```<code> var ch = Highcharts.chart('barChartContainer', {
    chart: {
        type: 'column'
    },
    credits: {
      enabled:false
    },
    title: {
        text: 'Detalles'
    },

    xAxis:{
      type: "category"
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Tiempo (dias)'
        }
    },
    tooltip: {
        headerFormat: '<span style="font-size:10px"></span><table>',
        pointFormat: '<tr><td style="color:{point.color};padding:0">Tiempo: </td>' +
            '<td style="padding:0"><b>{point.y} dias</b></td></tr>',
        footerFormat: '</table>',
        shared: true,
        useHTML: true
    },
    plotOptions: {
        column: {
            stacking: "normal",
            pointPadding: 0.2,
            borderWidth: 0,
            events: {
                      legendItemClick: function () {
                          return this.visible ? 'visible' : 'hidden';
                        }
                      }}}

    });

  var seriesArray = [];
<?php
$sqlEstados = mysqli_query($con,"SELECT DISTINCT (estado) as nombre_estado from proceso order by nombre_estado");
while ($rowEstados = mysqli_fetch_array($sqlEstados)){
  ?> ch.addSeries({name:"<?php echo $rowEstados['nombre_estado']?>", color: "    <?php echo $rowEstados['nombre_estado'] == "FINALIZADO" ? '#00C851' : ($rowEstados['nombre_estado'] == "WORKING" ? '#ffbb33' : (($rowEstados['nombre_estado'] == "PARADO" ? '#ff4444' :  '#33b5e5'))); ?>"});
<?php
} //INFLANDO LAS SERIES 03/07/2017 -> QUEDA INFLAR LAS CATEGORIAS CON OTRA FUNCION QUE DEVUELVA [[nombre,valor]]
 $sql = mysqli_query($con,"SELECT timestampdiff(DAY,fecha_creacion, IFNULL(fecha_cerrado,NOW())) as t_diff_dias, (SELECT MAX(timestampdiff(DAY,fecha_creacion, IFNULL(fecha_cerrado,NOW()))) from proceso where not (estado='FINALIZADO' and fecha_cerrado IS NULL) ) as max_dias, id_proceso, proceso,estado from proceso where not (estado='FINALIZADO' and fecha_cerrado IS NULL)  ORDER BY id_proceso desc");
while ($rowSQL = mysqli_fetch_array($sql))
{
  $var;
  switch ($rowSQL['estado']) {
    case 'FINALIZADO':
      $var = 1;
      break;
    case 'WORKING':
      $var = 3;
      break;
    case 'PARADO':
      $var = 2;
      break;
    default:
      $var = 0;
      break;
  }
echo "ch.series[".$var."].addPoint([\"".$rowSQL['proceso']."\",".$rowSQL['t_diff_dias']."]);";
}
?>
</code>```

Thank you in advice.

EDIT: Thank you, I try something different. But I appreciate your support

答:
remove event from column also stacking,
it works by default.
if your series data is fine then there will be no problem

```<code> series: [
            {
        name: 'A1',
     data: [0,2,0,58,3]
    },
            {
        name: 'A2',
     data: [0,22,0,42,0]
    },
            {
        name: 'A3',
     data: [0,2,0,11,0]
    },
]
</code>```

this  have 5 data columns in x axis and 3 series .
just if you need to check, my chart code, ignore the extra code

```<code>var q=jQuery.noConflict();
q(function () {
   q('#container3').highcharts({

chart: {
        type: 'column'
    },
    title: {
        text: 'Staff  Stats '
    },
    xAxis: {
        categories: [
            'Done',
            'New',
            'Working',
            'Pending',
            'Calls',
        ],
        crosshair: true
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Stats '
        }
    },
    tooltip: {
        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
        pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
        footerFormat: '</table>',
        shared: true,
        useHTML: true
    },
    plotOptions: {
        column: {
            pointPadding: 0,
            borderWidth: 0
        }
    },
    series: [
        {
         name: 'A1',
         data: [0,2,0,58,3]
        },
        {
         name: 'A2',
         data: [0,22,0,42,0]
        },
        {
         name: 'A3',
         data: [0,2,0,11,0]
        },
    ]
   });
});
</code>```

Title: Disabled points not hide. [Highcharts]

Body:
nice to meet you.
I have a problem with my Chart.

I have a DB with some hiring process data. The process have many status: "ENDED","WORKING","STANDBY","CANCELLED". The process only have once at time.

I needed to use Stacked Column because if used normal one it let me tiny bars.

I have got all I wanted, but when I click in legend, the data category remains if there are not in the extremes.

Here the gif showing what I mean

And here's the code:

 var ch = Highcharts.chart('barChartContainer', {
    chart: {
        type: 'column'
    },
    credits: {
      enabled:false
    },
    title: {
        text: 'Detalles'
    },

    xAxis:{
      type: "category"
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Tiempo (dias)'
        }
    },
    tooltip: {
        headerFormat: '
',
        pointFormat: '
Tiempo: 	' +
            '{point.y} dias
',
        footerFormat: '
',
        shared: true,
        useHTML: true
    },
    plotOptions: {
        column: {
            stacking: "normal",
            pointPadding: 0.2,
            borderWidth: 0,
            events: {
                      legendItemClick: function () {
                          return this.visible ? 'visible' : 'hidden';
                        }
                      }}}

    });

  var seriesArray = [];
<?php
$sqlEstados = mysqli_query($con,"SELECT DISTINCT (estado) as nombre_estado from proceso order by nombre_estado");
while ($rowEstados = mysqli_fetch_array($sqlEstados)){
  ?> ch.addSeries({name:"<?php echo $rowEstados['nombre_estado']?>", color: "    <?php echo $rowEstados['nombre_estado'] == "FINALIZADO" ? '#00C851' : ($rowEstados['nombre_estado'] == "WORKING" ? '#ffbb33' : (($rowEstados['nombre_estado'] == "PARADO" ? '#ff4444' :  '#33b5e5'))); ?>"});
<?php
} //INFLANDO LAS SERIES 03/07/2017 -> QUEDA INFLAR LAS CATEGORIAS CON OTRA FUNCION QUE DEVUELVA [[nombre,valor]]
 $sql = mysqli_query($con,"SELECT timestampdiff(DAY,fecha_creacion, IFNULL(fecha_cerrado,NOW())) as t_diff_dias, (SELECT MAX(timestampdiff(DAY,fecha_creacion, IFNULL(fecha_cerrado,NOW()))) from proceso where not (estado='FINALIZADO' and fecha_cerrado IS NULL) ) as max_dias, id_proceso, proceso,estado from proceso where not (estado='FINALIZADO' and fecha_cerrado IS NULL)  ORDER BY id_proceso desc");
while ($rowSQL = mysqli_fetch_array($sql))
{
  $var;
  switch ($rowSQL['estado']) {
    case 'FINALIZADO':
      $var = 1;
      break;
    case 'WORKING':
      $var = 3;
      break;
    case 'PARADO':
      $var = 2;
      break;
    default:
      $var = 0;
      break;
  }
echo "ch.series[".$var."].addPoint([\"".$rowSQL['proceso']."\",".$rowSQL['t_diff_dias']."]);";
}
?>

Thank you in advice.

EDIT: Thank you, I try something different. But I appreciate your support

Body:
remove event from column also stacking,
it works by default.
if your series data is fine then there will be no problem

 series: [
            {
        name: 'A1',
     data: [0,2,0,58,3]
    },
            {
        name: 'A2',
     data: [0,22,0,42,0]
    },
            {
        name: 'A3',
     data: [0,2,0,11,0]
    },
]

this  have 5 data columns in x axis and 3 series .
just if you need to check, my chart code, ignore the extra code

var q=jQuery.noConflict();
q(function () {
   q('#container3').highcharts({

chart: {
        type: 'column'
    },
    title: {
        text: 'Staff  Stats '
    },
    xAxis: {
        categories: [
            'Done',
            'New',
            'Working',
            'Pending',
            'Calls',
        ],
        crosshair: true
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Stats '
        }
    },
    tooltip: {
        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
        pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
            '<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
        footerFormat: '</table>',
        shared: true,
        useHTML: true
    },
    plotOptions: {
        column: {
            pointPadding: 0,
            borderWidth: 0
        }
    },
    series: [
        {
         name: 'A1',
         data: [0,2,0,58,3]
        },
        {
         name: 'A2',
         data: [0,22,0,42,0]
        },
        {
         name: 'A3',
         data: [0,2,0,11,0]
        },
    ]
   });
});


问:
Display an MVC view in the Umbraco Backend
I found this article here :
http://jondjones.com/learn-umbraco-cms/umbraco-developers-guide/customising-umbraco-ui/how-to-display-an-mvc-view-in-the-umbraco-backend

It covers exactly what i want to do( display an mvc view in the umbraco backend in a section), however i can't seem to get it to work, and the article author is uncontactable.

I'm hoping someone might know this exact process and be able to go into more detail for me. The particular parts i am struggling with is the author does not describe where anything goes, what usings his code has, and what to do with the routeconfig if you don't already have one in an umbraco project. Added to this there are inconsistencies with the authors naming conventions in the examples, causing further confusion.

If anyone has done this before, please could you go into detail in how you use MVC to display a view, in a section, in the umbraco backend.

答:
So i am still working on and improving the tools in the project,
But this extension i created for umbraco has everything you need to be able to create a new custom section that uses MVC to display pages.

https://github.com/Wolfkhan66/Escc.Umbraco.EditorTools

When possible i will try to write a up a short tutorial that covers the absolute basics to create a custom MVC umbraco section.

for now if you have a look at this project, the very basics you need to make a new section are the following classes and files.

```<code>App_Start -> RouteConfig.cs
lang -> en-US.xml, en.xml
EditorTools -> EditorToolsSection.cs, EditorToolsTree.cs, StartUpHandler.cs
</code>```

The ***Section.cs class file allows you to create an instance of the new section.
The ***Tree.cs class file allows you to add the navigation tree nodes you see on any of the umbraco sections.
The StartUpHandler.cs is to register your RouteConfig to allow MVC to work.
The lang files allow you to merely change the name that is displayed for your section. Without it your section will appear is [example] instead of example.

A few things i have noticed while creating this project, Creating controllers and nodes in the tree with the same name as umbraco sections sometimes causes a conflict. e.g. having a node in the tree class called ContentNode will break and not work. so in my tree i named it ContentToolsNode.

To keep your extension contained it is best to have your views without your extension folder. however by default your actionresults will look at the root level of the project for a view folder. as such you must provide a string in your returned actionresults to point them to the correct view within your extension folder.
e.g.

```<code>return View("~/App_Plugins/EditorTools/Views/Content/Index.cshtml", model);
</code>```

If you navigate to your new section and find your navigation tree is missing. Try deleting the custom sections key in the trees.config file found in the Config folder and rebuilding the project. The next time you navigate to the custom section it should regenerate a new key and display the navigation tree.

As the project is a work in progress and i am still making improvements, if you clone it you may find it has some umbraco files missing ( mostly config files . simply uninstall the umbracocms, umbraco.modelsbuilder and the umbracocms.core packages and delete any missing files in the project. You should then be able reinstall the umbracocms package. I have tried to document the installation progress in the readme.

I hope this helps some people, Happy Coding!

Body:
So i am still working on and improving the tools in the project,
But this extension i created for umbraco has everything you need to be able to create a new custom section that uses MVC to display pages.

https://github.com/Wolfkhan66/Escc.Umbraco.EditorTools

When possible i will try to write a up a short tutorial that covers the absolute basics to create a custom MVC umbraco section.

for now if you have a look at this project, the very basics you need to make a new section are the following classes and files.

App_Start -> RouteConfig.cs
lang -> en-US.xml, en.xml
EditorTools -> EditorToolsSection.cs, EditorToolsTree.cs, StartUpHandler.cs

The ***Section.cs class file allows you to create an instance of the new section.
The ***Tree.cs class file allows you to add the navigation tree nodes you see on any of the umbraco sections.
The StartUpHandler.cs is to register your RouteConfig to allow MVC to work.
The lang files allow you to merely change the name that is displayed for your section. Without it your section will appear is [example] instead of example.

A few things i have noticed while creating this project, Creating controllers and nodes in the tree with the same name as umbraco sections sometimes causes a conflict. e.g. having a node in the tree class called ContentNode will break and not work. so in my tree i named it ContentToolsNode.

To keep your extension contained it is best to have your views without your extension folder. however by default your actionresults will look at the root level of the project for a view folder. as such you must provide a string in your returned actionresults to point them to the correct view within your extension folder.
e.g.

return View("~/App_Plugins/EditorTools/Views/Content/Index.cshtml", model);

If you navigate to your new section and find your navigation tree is missing. Try deleting the custom sections key in the trees.config file found in the Config folder and rebuilding the project. The next time you navigate to the custom section it should regenerate a new key and display the navigation tree.

As the project is a work in progress and i am still making improvements, if you clone it you may find it has some umbraco files missing ( mostly config files . simply uninstall the umbracocms, umbraco.modelsbuilder and the umbracocms.core packages and delete any missing files in the project. You should then be able reinstall the umbracocms package. I have tried to document the installation progress in the readme.

I hope this helps some people, Happy Coding!


问:
Adding delay or something between hundred of promises
I'm using node for requesting app details from another website but the problem i'm facing is, it sends hundreds ( or maybe thousands ) of request, and then I get error and I receive nothing.

Read comments in code for info...

```<code>// I'm reading links from another file using 'fs'
fs.readFile('./google_apps/GAME_ACTION.json', 'utf8', function (err, data) {
    if (err) throw err;

    obj = JSON.parse(data);
    // creating a empty array
    var promiseStack = [];

    for (var index in obj['GAME_ACTION']) {
        var linksArray = obj['GAME_ACTION'][index];
        linksArray.forEach( function(link, index) {
            var appID = link.match(/id=.*/g)
            var instr = appID.toString();

            var appIDSliced = instr.slice(3)
            // Here appIDSliced is ID, which is sliced from a link
            // there are thousands on link in this file which I opened

            console.log('sending') // for testing purpose

            // here i'm pushing promises into that empty array
            // store.app({id: appIDSliced}) is a promise I guess because I can use .then() on it...
            // and store.app sends request to another website from which it receives an object in return.
            // (Variable store is from another file 'require()' above in my node app fie )
            promiseStack.push( store.app({id: appIDSliced}))

        });
    }

    // After pushing all promises into array, now i'm trying to resolve them using Promise.all
    Promise.all(promiseStack).then((responses) => {
        console.log("Dealing with responses")

        // Dealing with response (which is an object coming)
        responses.map(response => {
            var title = response.title
            var package_name = response.appId
            var appCategory = response.primaryGenre
            var appSize = parseFloat((response.size/1024)/1024).toFixed(2)
            var developerName = response.developer
            var developerWebsite = response.developerWebsite
            if (typeof developerWebsite == 'undefined') {
                developerWebsite = "N/A"
            }
            var appPrice = response.price
            var lastUpdated = response.updated
            var contentRating = response.contentRating
            if (typeof contentRating == 'undefined') {
                contentRating = "N/A"
            }
            var userRating = response.score
            if (typeof userRating == 'undefined') {
                userRating = "N/A"
            }
            var dataRow = [appID, title, package_name, appCategory, appSize, developerName, developerWebsite, appPrice, lastUpdated, contentRating, userRating]
            var dataToAdd = [dataRow];
            console.log("Appending now")

            // here i'm using google API to append that into my sheet on google
            authentication.authenticate().then((auth)=>{
                appendData(auth, dataToAdd);
            });
        })
    })
})
</code>```

See the image below ... Those are the Errors I receive on my console
It keep logging 'sending' like for 80 secs and then I get error "UnhandledPromiseRejectionWarning" where I just get stuck for 2 mins and I keep pressing 'CTRL+C'.

Thanks.

答:
async.each may be more appropriate in your case, check the async.each

Promise.all() doesnt seem right in this case, because method returns a single Promise that resolves when all of the promises in the iterable argument have resolved or when the iterable argument contains no promises. It rejects with the reason of the first promise that rejects. promise.all

I have tried to rewrite your code with async, there few assumptions I have made, this is the general example you probably may tune it for you logic.

```<code>var async = require('async');
fs.readFile('./google_apps/GAME_ACTION.json', 'utf8', function (err, data) {
    if (err) throw err;

    var obj = JSON.parse(data);
    async.each(obj['GAME_ACTION'], function(linksArray, callback){
        linksArray.forEach( function(link,) {
            var appID = link.match(/id=.*/g);
            var instr = appID.toString();

            var appIDSliced = instr.slice(3);

            console.log('sending') // for testing purpose
            // I am assuming that store.app() is asyncronous and get a callback
            store.app({id: appIDSliced}, function(err, response){
                if (err){
                    console.log('something bad happend');
                    callback();
                }
                else{
                        var title = response.title;
                        var package_name = response.appId;
                        var appCategory = response.primaryGenre;
                        var appSize = parseFloat((response.size/1024)/1024).toFixed(2);
                        var developerName = response.developer;
                        var developerWebsite = response.developerWebsite;
                        if (typeof developerWebsite == 'undefined') {
                            developerWebsite = "N/A"
                        }
                        var appPrice = response.price;
                        var lastUpdated = response.updated;
                        var contentRating = response.contentRating;
                        if (typeof contentRating == 'undefined') {
                            contentRating = "N/A"
                        }
                        var userRating = response.score;
                        if (typeof userRating == 'undefined') {
                            userRating = "N/A"
                        }
                        var dataRow = [appID, title, package_name, appCategory, appSize, developerName, developerWebsite, appPrice, lastUpdated, contentRating, userRating]
                        var dataToAdd = [dataRow];
                        console.log("Appending now");

                        authentication.authenticate().then((auth)=>{
                            appendData(auth, dataToAdd);
                        });
                    callback();
                }
            });
        });
    }, function (err) {

    });

});
</code>```

Body:
I'm using node for requesting app details from another website but the problem i'm facing is, it sends hundreds ( or maybe thousands ) of request, and then I get error and I receive nothing.

Read comments in code for info...

// I'm reading links from another file using 'fs'
fs.readFile('./google_apps/GAME_ACTION.json', 'utf8', function (err, data) {
    if (err) throw err;

    obj = JSON.parse(data);
    // creating a empty array
    var promiseStack = [];

    for (var index in obj['GAME_ACTION']) {
        var linksArray = obj['GAME_ACTION'][index];
        linksArray.forEach( function(link, index) {
            var appID = link.match(/id=.*/g)
            var instr = appID.toString();

            var appIDSliced = instr.slice(3)
            // Here appIDSliced is ID, which is sliced from a link
            // there are thousands on link in this file which I opened

            console.log('sending') // for testing purpose

            // here i'm pushing promises into that empty array
            // store.app({id: appIDSliced}) is a promise I guess because I can use .then() on it...
            // and store.app sends request to another website from which it receives an object in return.
            // (Variable store is from another file 'require()' above in my node app fie )
            promiseStack.push( store.app({id: appIDSliced}))

        });
    }

    // After pushing all promises into array, now i'm trying to resolve them using Promise.all
    Promise.all(promiseStack).then((responses) => {
        console.log("Dealing with responses")

        // Dealing with response (which is an object coming)
        responses.map(response => {
            var title = response.title
            var package_name = response.appId
            var appCategory = response.primaryGenre
            var appSize = parseFloat((response.size/1024)/1024).toFixed(2)
            var developerName = response.developer
            var developerWebsite = response.developerWebsite
            if (typeof developerWebsite == 'undefined') {
                developerWebsite = "N/A"
            }
            var appPrice = response.price
            var lastUpdated = response.updated
            var contentRating = response.contentRating
            if (typeof contentRating == 'undefined') {
                contentRating = "N/A"
            }
            var userRating = response.score
            if (typeof userRating == 'undefined') {
                userRating = "N/A"
            }
            var dataRow = [appID, title, package_name, appCategory, appSize, developerName, developerWebsite, appPrice, lastUpdated, contentRating, userRating]
            var dataToAdd = [dataRow];
            console.log("Appending now")

            // here i'm using google API to append that into my sheet on google
            authentication.authenticate().then((auth)=>{
                appendData(auth, dataToAdd);
            });
        })
    })
})

See the image below ... Those are the Errors I receive on my console
It keep logging 'sending' like for 80 secs and then I get error "UnhandledPromiseRejectionWarning" where I just get stuck for 2 mins and I keep pressing 'CTRL+C'.

Thanks.

Body:
async.each may be more appropriate in your case, check the async.each

Promise.all() doesnt seem right in this case, because method returns a single Promise that resolves when all of the promises in the iterable argument have resolved or when the iterable argument contains no promises. It rejects with the reason of the first promise that rejects. promise.all

I have tried to rewrite your code with async, there few assumptions I have made, this is the general example you probably may tune it for you logic.

var async = require('async');
fs.readFile('./google_apps/GAME_ACTION.json', 'utf8', function (err, data) {
    if (err) throw err;

    var obj = JSON.parse(data);
    async.each(obj['GAME_ACTION'], function(linksArray, callback){
        linksArray.forEach( function(link,) {
            var appID = link.match(/id=.*/g);
            var instr = appID.toString();

            var appIDSliced = instr.slice(3);

            console.log('sending') // for testing purpose
            // I am assuming that store.app() is asyncronous and get a callback
            store.app({id: appIDSliced}, function(err, response){
                if (err){
                    console.log('something bad happend');
                    callback();
                }
                else{
                        var title = response.title;
                        var package_name = response.appId;
                        var appCategory = response.primaryGenre;
                        var appSize = parseFloat((response.size/1024)/1024).toFixed(2);
                        var developerName = response.developer;
                        var developerWebsite = response.developerWebsite;
                        if (typeof developerWebsite == 'undefined') {
                            developerWebsite = "N/A"
                        }
                        var appPrice = response.price;
                        var lastUpdated = response.updated;
                        var contentRating = response.contentRating;
                        if (typeof contentRating == 'undefined') {
                            contentRating = "N/A"
                        }
                        var userRating = response.score;
                        if (typeof userRating == 'undefined') {
                            userRating = "N/A"
                        }
                        var dataRow = [appID, title, package_name, appCategory, appSize, developerName, developerWebsite, appPrice, lastUpdated, contentRating, userRating]
                        var dataToAdd = [dataRow];
                        console.log("Appending now");

                        authentication.authenticate().then((auth)=>{
                            appendData(auth, dataToAdd);
                        });
                    callback();
                }
            });
        });
    }, function (err) {

    });

});


问:
Linq to SQL Stored Procedures with Multiple Results
We have followed the approach below to get the data from multiple results using LINQ To SQL

```<code>CREATE PROCEDURE dbo.GetPostByID
(
    @PostID int
)
AS
    SELECT    *
    FROM      Posts AS p
    WHERE     p.PostID = @PostID

    SELECT    c.*
    FROM      Categories AS c
    JOIN      PostCategories AS pc
    ON        (pc.CategoryID = c.CategoryID)
    WHERE     pc.PostID = @PostID
</code>```

The calling method in the class the inherits from DataContext should look like:

```<code>[Database(Name = "Blog")]
public class BlogContext : DataContext
{
    ...

    [Function(Name = "dbo.GetPostByID")]
    [ResultType(typeof(Post))]
    [ResultType(typeof(Category))]
    public IMultipleResults GetPostByID(int postID)
    {
        IExecuteResult result =
            this.ExecuteMethodCall(this,
                  ((MethodInfo)(MethodInfo.GetCurrentMethod())),
                  postID);

        return (IMultipleResults)(result.ReturnValue);
    }
}
</code>```

Notice that the method is decorated not only with the Function attribute that maps to the stored procedure name, but also with the ReturnType attributes with the types of the result sets that the stored procedure returns. Additionally, the method returns an untyped interface of IMultipleResults:

```<code>public interface IMultipleResults : IFunctionResult, IDisposable
{
    IEnumerable<TElement> GetResult<TElement>();
}
</code>```

so the program can use this interface in order to retrieve the results:

```<code>BlogContext ctx = new BlogContext(...);

IMultipleResults results = ctx.GetPostByID(...);

IEnumerable<Post> posts = results.GetResult<Post>();

IEnumerable<Category> categories = results.GetResult<Category>();
</code>```

In the above stored procedures we had two select queries
1. Select query without join
2. Select query with Join

But in the above second select query the data which is displayed is from one of the table i.e. from Categories table. But we have used join and want to display the data table with the results from both the tables i.e. from Categories as well as PostCategories.

Please if anybody can let me know how to achieve this using LINQ to SQL

What is the performance trade-off if we use the above approach vis-à-vis implement the above approach with simple SQL

答:
Just curious, if a Post have have one or many Categories, is it possible to instead of using the for loop, to load the Post.PostCategories with the list of Categories (one to many), all in one shot, using a JOIN?</p>

```<code>var rslt = from p in results.GetResult<Post>()
           join c in results.GetResult<Category>() on p.PostId = c.PostID
           ...
           p.Categories.Add(c)
</code>```

OwnerDisplayName: Gourav

LastEditorDisplayName: tvanfosson

ContentLicense: CC BY-SA 2.5

Body:
We have followed the approach below to get the data from multiple results using LINQ To SQL

CREATE PROCEDURE dbo.GetPostByID
(
    @PostID int
)
AS
    SELECT    *
    FROM      Posts AS p
    WHERE     p.PostID = @PostID

    SELECT    c.*
    FROM      Categories AS c
    JOIN      PostCategories AS pc
    ON        (pc.CategoryID = c.CategoryID)
    WHERE     pc.PostID = @PostID

The calling method in the class the inherits from DataContext should look like:

[Database(Name = "Blog")]
public class BlogContext : DataContext
{
    ...

    [Function(Name = "dbo.GetPostByID")]
    [ResultType(typeof(Post))]
    [ResultType(typeof(Category))]
    public IMultipleResults GetPostByID(int postID)
    {
        IExecuteResult result =
            this.ExecuteMethodCall(this,
                  ((MethodInfo)(MethodInfo.GetCurrentMethod())),
                  postID);

        return (IMultipleResults)(result.ReturnValue);
    }
}

Notice that the method is decorated not only with the Function attribute that maps to the stored procedure name, but also with the ReturnType attributes with the types of the result sets that the stored procedure returns. Additionally, the method returns an untyped interface of IMultipleResults:

public interface IMultipleResults : IFunctionResult, IDisposable
{
    IEnumerable<TElement> GetResult<TElement>();
}

so the program can use this interface in order to retrieve the results:

BlogContext ctx = new BlogContext(...);

IMultipleResults results = ctx.GetPostByID(...);

IEnumerable<Post> posts = results.GetResult<Post>();

IEnumerable<Category> categories = results.GetResult<Category>();

In the above stored procedures we had two select queries
1. Select query without join
2. Select query with Join

But in the above second select query the data which is displayed is from one of the table i.e. from Categories table. But we have used join and want to display the data table with the results from both the tables i.e. from Categories as well as PostCategories.

Please if anybody can let me know how to achieve this using LINQ to SQL

What is the performance trade-off if we use the above approach vis-à-vis implement the above approach with simple SQL

Body:
Just curious, if a Post have have one or many Categories, is it possible to instead of using the for loop, to load the Post.PostCategories with the list of Categories (one to many), all in one shot, using a JOIN?

var rslt = from p in results.GetResult<Post>()
           join c in results.GetResult<Category>() on p.PostId = c.PostID
           ...
           p.Categories.Add(c)


问:
Position of rightView UITextField
Is there a way to adjust the position of a rightView on UITextField? I tried setting the frame on the view (set as rightView) but it didn't change anything.

I'd like to avoid making two views, one as the rightView and one as the rightView's subview where I change the subview's position, if possible.

答:
@Puneet Sharma's answer was great but that would give the need to create a class that would subclass UITextField, what I did instead was create a UIView that would act as a padding.

This code works without the need to subclass

Here's my code, although it's written in Swift 3

```<code>// this is the view I want to see on the rightView
let checkImageView = UIImageView(image: UIImage(named: "check24.png"))
checkImageView.frame = CGRect(x: 0, y: 0, width: 24, height: 24)
checkImageView.curveEdges(12)
checkImageView.contentMode = .scaleAspectFit

// declare how much padding I want to have
let padding: CGFloat = 6

// create the view that would act as the padding
let rightView = UIView(frame: CGRect(
    x: 0, y: 0, // keep this as 0, 0
    width: checkImageView.frame.width + padding, // add the padding
    height: checkImageView.frame.height))
rightView.addSubview(checkImageView)

// set the rightView UIView as the textField's rightView
self.textField.rightViewMode = .whileEditing
self.textField.rightView = rightView
</code>```

What happened here is, that the rightView which is a UIView that has a transparent colored background which then gave the illusion that there is a padding whereas there is not.

Title: Position of rightView UITextField

Body:
@Puneet Sharma's answer was great but that would give the need to create a class that would subclass UITextField, what I did instead was create a UIView that would act as a padding.

This code works without the need to subclass

Here's my code, although it's written in Swift 3

// this is the view I want to see on the rightView
let checkImageView = UIImageView(image: UIImage(named: "check24.png"))
checkImageView.frame = CGRect(x: 0, y: 0, width: 24, height: 24)
checkImageView.curveEdges(12)
checkImageView.contentMode = .scaleAspectFit

// declare how much padding I want to have
let padding: CGFloat = 6

// create the view that would act as the padding
let rightView = UIView(frame: CGRect(
    x: 0, y: 0, // keep this as 0, 0
    width: checkImageView.frame.width + padding, // add the padding
    height: checkImageView.frame.height))
rightView.addSubview(checkImageView)

// set the rightView UIView as the textField's rightView
self.textField.rightViewMode = .whileEditing
self.textField.rightView = rightView

What happened here is, that the rightView which is a UIView that has a transparent colored background which then gave the illusion that there is a padding whereas there is not.

ContentLicense: CC BY-SA 4.0


问:
Adding InfoWindow() on polygon mouseenter, one content for each polygon
I have 2 (or more) Polygons, which work fine. But I would like to add a mouseenter event for each polygon, showing the corresponding infowindow.

I have no Ideia in this context (addGeojson) how to do it

The code:

var mapOptions = {
    zoom: 4,
    scrollwheel: false,
    center: {lat: 30.162129, lng: -117.341888},
};

geos = [{'type': 'Feature', 'geometry': {'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-482.2998046875,39.07890809706475],[-478.388671875,39.198205348894795],[-480.234375,36.10237644873644],[-483.72802734375,36.932330061503144],[-482.2998046875,39.07890809706475]]]}}, {'type': 'Feature', 'geometry': {'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-478.98193359375006,35.60371874069731],[-480.38818359375,33.687781758439364],[-477.31201171875,32.02670629333614],[-476.89453125,34.361576287484176],[-478.98193359375006,35.60371874069731]]]}}];

var map = new google.maps.Map(document.getElementById('map'), mapOptions);
for(var i = 0; i < geos.length; i++) {
 map.data.addGeoJson(geos[i]);
}

map.data.setStyle({
   fillColor: 'orange',
   strokeWeight: 1
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="map" style="width: 400px; height: 400px;">
</div>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script></code>```

JSFIDDLE here

答:
try this modified code, hope it helps.!

```<code>    var mapOptions = {
        zoom: 4,
        scrollwheel: false,
        center: { lat: 37.140962, lng: -121.604583 },
    };

    geos = [{ 'type': 'Feature', 'geometry': { 'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-482.2998046875, 39.07890809706475], [-478.388671875, 39.198205348894795], [-480.234375, 36.10237644873644], [-483.72802734375, 36.932330061503144], [-482.2998046875, 39.07890809706475]]] } }, { 'type': 'Feature', 'geometry': { 'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-478.98193359375006, 35.60371874069731], [-480.38818359375, 33.687781758439364], [-477.31201171875, 32.02670629333614], [-476.89453125, 34.361576287484176], [-478.98193359375006, 35.60371874069731]]] } }];

    var map = new google.maps.Map(document.getElementById('map'), mapOptions);
    for (var i = 0; i < geos.length; i++) {
        var polygon = new google.maps.Data({ map: map });
        polygon.addGeoJson(geos[i]);
        //Call attachPolygonInfoWindow method here
        attachPolygonInfoWindow(polygon);
        polygon.setStyle({
            fillColor: 'orange',
            strokeWeight: 1
        });
    }
</code>```

Method to attach info window with polygon.

```<code> function attachPolygonInfoWindow(polygon) {
        var infoWindow = new google.maps.InfoWindow();
        google.maps.event.addListener(polygon, 'mouseover', function (e) {
            infoWindow.setContent("Polygon");
            var latLng = e.latLng;
            infoWindow.setPosition(latLng);
            infoWindow.open(map);
        });
    }
</code>```

Body:
I have 2 (or more) Polygons, which work fine. But I would like to add a mouseenter event for each polygon, showing the corresponding infowindow.

I have no Ideia in this context (addGeojson) how to do it

The code:

var mapOptions = {
    zoom: 4,
    scrollwheel: false,
    center: {lat: 30.162129, lng: -117.341888},
};

geos = [{'type': 'Feature', 'geometry': {'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-482.2998046875,39.07890809706475],[-478.388671875,39.198205348894795],[-480.234375,36.10237644873644],[-483.72802734375,36.932330061503144],[-482.2998046875,39.07890809706475]]]}}, {'type': 'Feature', 'geometry': {'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-478.98193359375006,35.60371874069731],[-480.38818359375,33.687781758439364],[-477.31201171875,32.02670629333614],[-476.89453125,34.361576287484176],[-478.98193359375006,35.60371874069731]]]}}];

var map = new google.maps.Map(document.getElementById('map'), mapOptions);
for(var i = 0; i < geos.length; i++) {
 map.data.addGeoJson(geos[i]);
}

map.data.setStyle({
   fillColor: 'orange',
   strokeWeight: 1
});

JSFIDDLE here

Body:
try this modified code, hope it helps.!

    var mapOptions = {
        zoom: 4,
        scrollwheel: false,
        center: { lat: 37.140962, lng: -121.604583 },
    };

    geos = [{ 'type': 'Feature', 'geometry': { 'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-482.2998046875, 39.07890809706475], [-478.388671875, 39.198205348894795], [-480.234375, 36.10237644873644], [-483.72802734375, 36.932330061503144], [-482.2998046875, 39.07890809706475]]] } }, { 'type': 'Feature', 'geometry': { 'type': 'Polygon', 'osm_type': 'relation', 'coordinates': [[[-478.98193359375006, 35.60371874069731], [-480.38818359375, 33.687781758439364], [-477.31201171875, 32.02670629333614], [-476.89453125, 34.361576287484176], [-478.98193359375006, 35.60371874069731]]] } }];

    var map = new google.maps.Map(document.getElementById('map'), mapOptions);
    for (var i = 0; i < geos.length; i++) {
        var polygon = new google.maps.Data({ map: map });
        polygon.addGeoJson(geos[i]);
        //Call attachPolygonInfoWindow method here
        attachPolygonInfoWindow(polygon);
        polygon.setStyle({
            fillColor: 'orange',
            strokeWeight: 1
        });
    }

Method to attach info window with polygon.

 function attachPolygonInfoWindow(polygon) {
        var infoWindow = new google.maps.InfoWindow();
        google.maps.event.addListener(polygon, 'mouseover', function (e) {
            infoWindow.setContent("Polygon");
            var latLng = e.latLng;
            infoWindow.setPosition(latLng);
            infoWindow.open(map);
        });
    }


问:
How I spit the line by \n
I want to split the line by \n.

```<code>a = "Id, Name, Age, Address\n123,John,23,\"No:23 21st street\n areacode\npincode\"\n124,Antony,25,\"No:213 29th street\n areacode\npincode\"\n"
</code>```

After splitting the line by \n, the line should be like this.

```<code>a = ["Id, Name, Age, Address", "123,John,23,\"No:23 21st street\n areacode\npincode\"", "124,Antony,25,\"No:213 29th street\n areacode\npincode\"]
</code>```

The commands I tried

```<code>a.scan(/(?!\B"[^"]*)^C?(?:[\n\r]+|\z)(?![^"]*"\B)/)
a.scan(/.+?(?:[\n\r]+|\z)/)
</code>```

答:
Why don't use the split method from String?</p>

```<code>a = "Id, Name, Age, Address\n123,John,23,\"No:23 21st street\n areacode\npincode\"\n124,Antony,25,\"No:213 29th street\n areacode\npincode\"\n"

a.split "\n"

["Id, Name, Age, Address", "123,John,23,\"No:23 21st street", " areacode", "pincode\"", "124,Antony,25,\"No:213 29th street", " areacode", "pincode\""]
</code>```

Title: How I spit the line by \n

Body:
I want to split the line by \n.

a = "Id, Name, Age, Address\n123,John,23,\"No:23 21st street\n areacode\npincode\"\n124,Antony,25,\"No:213 29th street\n areacode\npincode\"\n"

After splitting the line by \n, the line should be like this.

a = ["Id, Name, Age, Address", "123,John,23,\"No:23 21st street\n areacode\npincode\"", "124,Antony,25,\"No:213 29th street\n areacode\npincode\"]

The commands I tried

a.scan(/(?!\B"[^"]*)^C?(?:[\n\r]+|\z)(?![^"]*"\B)/)
a.scan(/.+?(?:[\n\r]+|\z)/)

Body:
Why don't use the split method from String?

a = "Id, Name, Age, Address\n123,John,23,\"No:23 21st street\n areacode\npincode\"\n124,Antony,25,\"No:213 29th street\n areacode\npincode\"\n"

a.split "\n"

["Id, Name, Age, Address", "123,John,23,\"No:23 21st street", " areacode", "pincode\"", "124,Antony,25,\"No:213 29th street", " areacode", "pincode\""]


问:
Git bash folder location under windows 7
I have installed git bash and create few folders using git bash. I wanted to search over Windows explorer but don't know exactly where these folders are actually created

Can please some one help me

答:
start . from command line will open Windows Explorer in your current working directory. It works both in cmd and Git Bash.

By default Git is installed in C:\Program Files (x86)\Git\ bu you can change it at installation time.


问:
How to run Arduino sketch automatically from flash drive?
I will be using an Arduino Gemma board, and I would like it to run a program directly from a USB drive as soon as it is plugged in. I am pretty new to Arduino, I mainly just know Raspberry Pi and Python, so anything would help, thanks.</p>

答: I don't think this is possible.  The ATtiny85 does not act as a USB host and so cannot host a USB flash drive as a "hard disk."  The micro-USB onboard is strictly a power and programming interface.  </p>


问:
How to compare elements consisting of two values? (pareto optimum)
I am pretty new to Python and I want to perform some sort of Pareto optimum. It is somewhat difficult to explain, so I hope my question will be clear enough to understand.

I have the following model which consists of a list of 5 doors (list: ‘doors’) and each door contains two costs (shown in dictionary ‘cost’): [travel distance, delay]. I would like to compare the costs of each door with the costs of another door. However, there is no dominant cost. This means I want a list of doors with the best solution (minimize cost) for both costs.

```<code>doors = ['D1', 'D2', 'D3', 'D4', 'D5']

# cost: [travel distance, delay]
cost = {
'D1': [150, 0],
'D2': [160, 0],
'D3': [170, 1],
'D4': [140, 2],
'D5': [150, 0]
}

def test(doors):
    for s in doors:
        for d in doors:
            if s != d:
                if cost[s][0] < cost[d][0] and cost[s][1] < cost[d][1]:
                    doors.remove(d)
    return doors

print(test(doors))
</code>```

For instance: D1, D2, D5 both have delay cost of 0. If I would only look for the door with minimum delay cost all three doors will do. However, D2 has a travel distance of 160 which is bigger than 150. Therefore, you would never choose D2 (compared to D1 and D5), since it consists of the same delay value and a worse travel distance value. So we would like D2 to be removed from the list.

For travel distance cost, you would choose D4 since it has the lowest travel distance: 140. Although it has the highest delay, there is no door which outperforms D4 due to the low travel distance.

So eventually I want a list with doors for which one of the cost is minimum with the best value for the other cost.
Based on this, I would like to have the following output:

best_doors = [‘D1’, ‘D4’,  ‘D5’].

In my model, I try to compare both costs for two different doors and remove a door if both costs are higher than the costs of the other door, but it does not give me the output I want.

I understand that my function is probably too simple to solve this problem but I don’t know how to solve this otherwise. Does someone have any idea how to solve this? I already looked on the internet to several websites, but nothing seems to really solve my problem.

Your help would be really appreciated!

答:
I'm aware that this may not fully answer your question but I hope it would lead you in the correct direction as this is not a (too) trivial problem (and this is too long to be a comment).

One way to approach this would be to give each cost a "weight" ie how much does it contribute to the decision whether or not to choose a specific door.

Usually this is done by coming up with a formula that appropriately describes the weight of each cost.

In the bellow example I used a formula that gives the distance a weight of 1 and  the delay a weight of 5.

```<code>cost = {
'D1': [150, 0],
'D2': [160, 0],
'D3': [170, 1],
'D4': [140, 2],
'D5': [150, 0]
}

def cost_function(x):
    # x here is a tuple of the form (door_name, [travel distance, delay])
    return x[1][0] + x[1][1] * 5

print(sorted(cost.items(), key=cost_function))
# [('D1', [150, 0]), ('D4', [140, 2]), ('D5', [150, 0]),
#  ('D2', [160, 0]), ('D3', [170, 1])]
</code>```

This cost function achieves the specific order you wanted.

Body:
I am pretty new to Python and I want to perform some sort of Pareto optimum. It is somewhat difficult to explain, so I hope my question will be clear enough to understand.

I have the following model which consists of a list of 5 doors (list: ‘doors’) and each door contains two costs (shown in dictionary ‘cost’): [travel distance, delay]. I would like to compare the costs of each door with the costs of another door. However, there is no dominant cost. This means I want a list of doors with the best solution (minimize cost) for both costs.

doors = ['D1', 'D2', 'D3', 'D4', 'D5']

# cost: [travel distance, delay]
cost = {
'D1': [150, 0],
'D2': [160, 0],
'D3': [170, 1],
'D4': [140, 2],
'D5': [150, 0]
}

def test(doors):
    for s in doors:
        for d in doors:
            if s != d:
                if cost[s][0] < cost[d][0] and cost[s][1] < cost[d][1]:
                    doors.remove(d)
    return doors

print(test(doors))

For instance: D1, D2, D5 both have delay cost of 0. If I would only look for the door with minimum delay cost all three doors will do. However, D2 has a travel distance of 160 which is bigger than 150. Therefore, you would never choose D2 (compared to D1 and D5), since it consists of the same delay value and a worse travel distance value. So we would like D2 to be removed from the list.

For travel distance cost, you would choose D4 since it has the lowest travel distance: 140. Although it has the highest delay, there is no door which outperforms D4 due to the low travel distance.

So eventually I want a list with doors for which one of the cost is minimum with the best value for the other cost.
Based on this, I would like to have the following output:

best_doors = [‘D1’, ‘D4’,  ‘D5’].

In my model, I try to compare both costs for two different doors and remove a door if both costs are higher than the costs of the other door, but it does not give me the output I want.

I understand that my function is probably too simple to solve this problem but I don’t know how to solve this otherwise. Does someone have any idea how to solve this? I already looked on the internet to several websites, but nothing seems to really solve my problem.

Your help would be really appreciated!

Body:
I'm aware that this may not fully answer your question but I hope it would lead you in the correct direction as this is not a (too) trivial problem (and this is too long to be a comment).

One way to approach this would be to give each cost a "weight" ie how much does it contribute to the decision whether or not to choose a specific door.

Usually this is done by coming up with a formula that appropriately describes the weight of each cost.

In the bellow example I used a formula that gives the distance a weight of 1 and  the delay a weight of 5.

cost = {
'D1': [150, 0],
'D2': [160, 0],
'D3': [170, 1],
'D4': [140, 2],
'D5': [150, 0]
}

def cost_function(x):
    # x here is a tuple of the form (door_name, [travel distance, delay])
    return x[1][0] + x[1][1] * 5

print(sorted(cost.items(), key=cost_function))
# [('D1', [150, 0]), ('D4', [140, 2]), ('D5', [150, 0]),
#  ('D2', [160, 0]), ('D3', [170, 1])]

This cost function achieves the specific order you wanted.


问:
Unable to fix position of two nodes in vis.js
I am trying to fix the position of two nodes.
They should be on top of each other, 400px apart in the y-dimension.

```<code>var edges = [{
    id:"1",
    fixed: {x:true, y:true},
    x:0,y:-200
},{
    id:"2",
    fixed: {x:true, y:true},
    x:0,y:200
}, ...];
</code>```

However, the position are not fixed and wander all over the place.
This is the corresponding fiddle.

Any ideas?

答:
Maybe this workaround will work for you:

1) store nodes and edges in dataSets

2) set node positions on afterDrawing and update the dataSet

```<code>  network.on('afterDrawing', function(){
    let data = [{id: 1, x: 0, y:-200}, {id:2, x:0, y:200}];
    nodesObj.update(data);
  });
</code>```

fiddle: http://jsfiddle.net/7juye694/

Body:
I am trying to fix the position of two nodes.
They should be on top of each other, 400px apart in the y-dimension.

var edges = [{
    id:"1",
    fixed: {x:true, y:true},
    x:0,y:-200
},{
    id:"2",
    fixed: {x:true, y:true},
    x:0,y:200
}, ...];

However, the position are not fixed and wander all over the place.
This is the corresponding fiddle.

Any ideas?

Body:
Maybe this workaround will work for you:

1) store nodes and edges in dataSets

2) set node positions on afterDrawing and update the dataSet

  network.on('afterDrawing', function(){
    let data = [{id: 1, x: 0, y:-200}, {id:2, x:0, y:200}];
    nodesObj.update(data);
  });

fiddle: http://jsfiddle.net/7juye694/


问:
Issues with gradle build in android studio
This is the situation:

I deleted app.impl and build.properties in my project. I used to do this all the time, but now when I rebuild gradle project, only app.impl is created, build.properties is missing.

When I navigate in application, in certain scenarios I get the following error:

```<code>07-04 10:38:37.784 14201-14201/net.-.- E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: net.-.-, PID: 14201
                                                                    java.lang.NoSuchFieldError: No field scrollView of type I in class Landroid/support/v7/appcompat/R$id; or its superclasses (declaration of 'android.support.v7.appcompat.R$id' appears in /data/app/net.dycode.eorder2-1/split_lib_slice_2_apk.apk)
                                                                        at android.support.v7.app.AlertController.setupContent(AlertController.java:675)
                                                                        at android.support.v7.app.AlertController.setupView(AlertController.java:463)
                                                                        at android.support.v7.app.AlertController.installContent(AlertController.java:215)
                                                                        at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:257)
                                                                        at android.app.Dialog.dispatchOnCreate(Dialog.java:395)
                                                                        at android.app.Dialog.show(Dialog.java:294)
                                                                        at android.app.DialogFragment.onStart(DialogFragment.java:502)
                                                                        at net.dycode.eorder2.dialog.AlertDialogFragment.onStart(AlertDialogFragment.java:48)
</code>```

What I have tried:

checking out different branch (granted it worked correctly before)

cleaning project

rebuilding project

making project

making app

I also tried updating android studio and it's SDK. Now there are no available updates.

答: I fixed the problem only by uninstalling android studio, deleting everything that is even remotely associated with it and then installing android studio again.</p>

Body:
This is the situation:

I deleted app.impl and build.properties in my project. I used to do this all the time, but now when I rebuild gradle project, only app.impl is created, build.properties is missing.

When I navigate in application, in certain scenarios I get the following error:

07-04 10:38:37.784 14201-14201/net.-.- E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: net.-.-, PID: 14201
                                                                    java.lang.NoSuchFieldError: No field scrollView of type I in class Landroid/support/v7/appcompat/R$id; or its superclasses (declaration of 'android.support.v7.appcompat.R$id' appears in /data/app/net.dycode.eorder2-1/split_lib_slice_2_apk.apk)
                                                                        at android.support.v7.app.AlertController.setupContent(AlertController.java:675)
                                                                        at android.support.v7.app.AlertController.setupView(AlertController.java:463)
                                                                        at android.support.v7.app.AlertController.installContent(AlertController.java:215)
                                                                        at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:257)
                                                                        at android.app.Dialog.dispatchOnCreate(Dialog.java:395)
                                                                        at android.app.Dialog.show(Dialog.java:294)
                                                                        at android.app.DialogFragment.onStart(DialogFragment.java:502)
                                                                        at net.dycode.eorder2.dialog.AlertDialogFragment.onStart(AlertDialogFragment.java:48)

What I have tried:

checking out different branch (granted it worked correctly before)

cleaning project

rebuilding project

making project

making app

I also tried updating android studio and it's SDK. Now there are no available updates.


问:
How to read msi log
I try to trouble shoot install as it fails recently.
I have the following part in my install log file, but do not know how to read/interpret it.
Can anyone point the doc or resources?
thanks a lot! </p>

```<code>MSI (s) (78:A8) [21:14:26:012]: Doing action: viewer.exe
Action start 21:14:26: viewer.exe.
MSI (s) (78:A8) [21:14:26:012]: Note: 1: 2262 2: CustomAction 3: -2147287038
MSI (s) (78:A8) [21:14:26:022]: Transforming table CustomAction.

MSI (s) (78:A8) [21:14:26:022]: Note: 1: 2262 2: Binary 3: -2147287038
MSI (s) (78:A8) [21:14:26:022]: Transforming table Binary.

Action ended 21:14:56: viewer.exe. Return value 1.
</code>```

<p>Edit
I found one link which is to tell how to interpret msi log
http://blogs.technet.com/b/richard_macdonald/archive/2007/04/02/how-to-interpret-windows-installer-logs.aspx </p>

答:
Here is also a detailed article on how to read MSI log files.

If you're an Advanced Installer user you can also leverage the built-in log parser/debugger from the application, however all the advices from the article can be applied for any MSI log file, no matter if you open it with Notepad, Notepad++ or in any other tool.

Title: How to read msi log

Body:
I try to trouble shoot install as it fails recently.
I have the following part in my install log file, but do not know how to read/interpret it.
Can anyone point the doc or resources?
thanks a lot!

MSI (s) (78:A8) [21:14:26:012]: Doing action: viewer.exe
Action start 21:14:26: viewer.exe.
MSI (s) (78:A8) [21:14:26:012]: Note: 1: 2262 2: CustomAction 3: -2147287038
MSI (s) (78:A8) [21:14:26:022]: Transforming table CustomAction.

MSI (s) (78:A8) [21:14:26:022]: Note: 1: 2262 2: Binary 3: -2147287038
MSI (s) (78:A8) [21:14:26:022]: Transforming table Binary.

Action ended 21:14:56: viewer.exe. Return value 1.

Edit
I found one link which is to tell how to interpret msi log
http://blogs.technet.com/b/richard_macdonald/archive/2007/04/02/how-to-interpret-windows-installer-logs.aspx


问:
How to implement dynamic flex value with Angular Material
I'm trying to build a div with uncertain number of child divs, I want the child div have flex="100" when there is only one of them, which takes the entire row. If there are more than one child divs (even if there are three or four child elements), they should all have exactly flex="50", which will take half of the row.

Any idea how could I do that?
Thanks in advance.

答:
Another way is

 and in controller define and modify flexSize e.g $scope.flexSize = 50;

Body: Another way is <div flex="{{::flexSize}}"></div> and in controller define and modify flexSize e.g $scope.flexSize = 50;


问:
primeNG plugin I am using,but i am facing issue like,it is not removing old breadcrumb
I am using this plugin. But here, the problem is,

```<code>this.itemBreadcrums.push({ label: 'home', routerLink: ['/home'] });
this.itemBreadcrums.push({ label: 'Participant List', routerLink: ['/home']
});
this.itemBreadcrums.push({ label: participantName});
</code>```

In this breadcrumb, when I click on home, other two labels are not hiding.

https://hassantariqblog.wordpress.com/2016/12/03/angular2-using-breadcrumb-as-angular-service-in-angular-2-application-2/

答:
Depending on your implementation:

First solution : you can try to play with shift(), pop(), slice() ... on your MenuItem object to add/delete what you push into it

Second solution and the best : Try to rebuild breadcrumbs in your "ngOnInit()" function and re-set it to the original point corresponding to the path relied to your component.

ngOnInit() {
this.breadcrumbService.setBreadcrumbs("packages.additionalPrices")
}

This method is the best I've found.

Body:
I am using this plugin. But here, the problem is,

this.itemBreadcrums.push({ label: 'home', routerLink: ['/home'] });
this.itemBreadcrums.push({ label: 'Participant List', routerLink: ['/home']
});
this.itemBreadcrums.push({ label: participantName});

In this breadcrumb, when I click on home, other two labels are not hiding.

https://hassantariqblog.wordpress.com/2016/12/03/angular2-using-breadcrumb-as-angular-service-in-angular-2-application-2/


问:
How to Fix "not allowed to load local resource" [Wordpress]
I am using the img tag but the code is in a php block.

```<code><img class='client_image' src='" . get_stylesheet_directory() . "/assets/images/" . $print->client_images . "' alt='clientimage" . $clientindex . "' width='200' height ='200' />";
</code>```

I keep getting not allowed to load local resource and I do not know why. I am using a premade wordpress theme. All I get is the broken image icon. The path is correct as well as the name of the file.

答:
get_stylesheet_directory() will returns the path on your server, you need get_stylesheet_directory_uri() instead:

```<code><img class='client_image' src='" . get_stylesheet_directory_uri() .
"/assets/images/" . $print->client_images . "' alt='clientimage" .
$clientindex . "' width='200' height ='200' />";
</code>```

Body:
I am using the img tag but the code is in a php block.

client_images . "' alt='clientimage" . $clientindex . "' width='200' height ='200' />";

I keep getting not allowed to load local resource and I do not know why. I am using a premade wordpress theme. All I get is the broken image icon. The path is correct as well as the name of the file.

Body:
get_stylesheet_directory() will returns the path on your server, you need get_stylesheet_directory_uri() instead:

<img class='client_image' src='" . get_stylesheet_directory_uri() .
"/assets/images/" . $print->client_images . "' alt='clientimage" .
$clientindex . "' width='200' height ='200' />";


问:
disable the list item for empty parent
I have 5 list item which has a tag with class Articles, Blogs, Brochures, Webinars, Whitepapers and have their child content in 'view-content' div.on load it shows blogs and hide the other child.when I chick 'whitepapers' child whitepaper shows and other child will hide(working fine).

I want to add the class 'disable' to the list item as

 for the list which doesn't has the child.In my example 'Brochures' and 'Webinars' have no child so need to add the class 'disable' for the respective list.

(function($) {
  function perspective_type() {
    $(".perspective-list a").click(function(e) {
      e.preventDefault();
      $(".perspective-list a").parent().removeClass('active');
      $('.wrapper .page-perspective').show();
      var href = $(this).attr('href');
      $('.wrapper > :not(.' + href + ')').hide();
      $('.wrapper > .' + href + '').show();
      $(this).parent().addClass('active');
    });
    $(".perspective-list a").mouseover(
      function() {
        $(".perspective-list a").removeClass('hover');
        $(this).parent().addClass('hover');
      });
    $(".perspective-list a").mouseout(
      function() {
        $(".perspective-list a").each(function() {
          $(this).parent().removeClass('hover');
        });
      });
    $('#perspectives .perspectiveReadurl', '#page_perspectives .perspectiveReadurl').find('a').attr('target', '_blank');
  }
  jQuery(document).ready(function($) {
    var href = 'Blogs';
    jQuery('.perspective-list a.' + href + '').parent().addClass('active');
    jQuery('.wrapper > :not(.' + href + ')').hide();
    perspective_type();
  });

})(jQuery)```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="perspective-list">
  <ul class="nav nav-justified">
    <li class="">Articles</li>
    <li class="">Blogs</li>
    <li class="">Brochures</li>
    <li class="">Webinars</li>
    <li class="active">Whitepapers</li>
  </ul>
</div>
<div class="view-content">
  <div class="wrapper">
    <div class=" Articles">
      article
    </div>
  </div>
  <div class="wrapper">
    <div class="Blogs">
      Blogs
    </div>
  </div>
  <div class="wrapper">
    <div class="Whitepapers">
      Whitepapers
    </div>
  </div>
</div></code>```

答:
I guess this jsfiddle will help you https://jsfiddle.net/h3ttxk8r/

```<code>jQuery(document).ready(function($) {
    var href = 'Blogs';
    jQuery('.perspective-list a.' + href + '').parent().addClass('active');
    jQuery('.wrapper > :not(.' + href + ')').hide();
    perspective_type();

    $('ul > li > a').each(function(){
        if(!$('div').hasClass($(this).attr('href'))){
            $(this).parent().addClass('disabled');
        }
   });
</code>```

});

CSS

```<code>.disabled {
    cursor: none;
    opacity: 0.5;
    pointer-events: none;
}
</code>```

Title: disable the list item for empty parent

Body:
I have 5 list item which has a tag with class Articles, Blogs, Brochures, Webinars, Whitepapers and have their child content in 'view-content' div.on load it shows blogs and hide the other child.when I chick 'whitepapers' child whitepaper shows and other child will hide(working fine).

I want to add the class 'disable' to the list item as

 for the list which doesn't has the child.In my example 'Brochures' and 'Webinars' have no child so need to add the class 'disable' for the respective list.

(function($) {
  function perspective_type() {
    $(".perspective-list a").click(function(e) {
      e.preventDefault();
      $(".perspective-list a").parent().removeClass('active');
      $('.wrapper .page-perspective').show();
      var href = $(this).attr('href');
      $('.wrapper > :not(.' + href + ')').hide();
      $('.wrapper > .' + href + '').show();
      $(this).parent().addClass('active');
    });
    $(".perspective-list a").mouseover(
      function() {
        $(".perspective-list a").removeClass('hover');
        $(this).parent().addClass('hover');
      });
    $(".perspective-list a").mouseout(
      function() {
        $(".perspective-list a").each(function() {
          $(this).parent().removeClass('hover');
        });
      });
    $('#perspectives .perspectiveReadurl', '#page_perspectives .perspectiveReadurl').find('a').attr('target', '_blank');
  }
  jQuery(document).ready(function($) {
    var href = 'Blogs';
    jQuery('.perspective-list a.' + href + '').parent().addClass('active');
    jQuery('.wrapper > :not(.' + href + ')').hide();
    perspective_type();
  });

})(jQuery)

Articles

Blogs

Brochures

Webinars

Whitepapers

      article

      Blogs

      Whitepapers

Body:
I guess this jsfiddle will help you https://jsfiddle.net/h3ttxk8r/

jQuery(document).ready(function($) {
    var href = 'Blogs';
    jQuery('.perspective-list a.' + href + '').parent().addClass('active');
    jQuery('.wrapper > :not(.' + href + ')').hide();
    perspective_type();

    $('ul > li > a').each(function(){
        if(!$('div').hasClass($(this).attr('href'))){
            $(this).parent().addClass('disabled');
        }
   });

});

CSS

.disabled {
    cursor: none;
    opacity: 0.5;
    pointer-events: none;
}


问:
Bootstrap 3 grid boxes should take free vertical space
Actually I am working with bootstrap 3.3.6 and want to achive following with the bootstrap grid system:

The boxes are all in the same
 tag and i want that the box 4 takes the available space on the left side below the box 1.

The jsfiddle https://jsfiddle.net/byrd9wx2/

I know how to do this with normal html + css but not with bootstrap.

Thanks for your help!

答:
The simplest way is to place both of BOX1 and BOX4 within first column.

#box1 {
  height: 60px;
  background-color: blue;
}
#box2 {
  height: 100px;
  background-color: red;
}
#box3 {
  height: 75px;
  background-color: yellow;
}
#box4 {
  height: 30px;
  background-color: green;
}
#box1,#box2,#box3,#box4 {
  text-align: center;
  color:white;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
  <div class="row">
    <div class="col-xs-4">
      <div id="box1">BOX1</div>
      <div id="box4">BOX4</div>
    </div>
    <div class="col-xs-4">
      <div id="box2">BOX2</div>
    </div>
    <div class="col-xs-4">
      <div id="box3">BOX3</div>
    </div>
  </div>
</div></code>```

Body:
The simplest way is to place both of BOX1 and BOX4 within first column.

#box1 {
  height: 60px;
  background-color: blue;
}
#box2 {
  height: 100px;
  background-color: red;
}
#box3 {
  height: 75px;
  background-color: yellow;
}
#box4 {
  height: 30px;
  background-color: green;
}
#box1,#box2,#box3,#box4 {
  text-align: center;
  color:white;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
  <div class="row">
    <div class="col-xs-4">
      <div id="box1">BOX1</div>
      <div id="box4">BOX4</div>
    </div>
    <div class="col-xs-4">
      <div id="box2">BOX2</div>
    </div>
    <div class="col-xs-4">
      <div id="box3">BOX3</div>
    </div>
  </div>
</div>


问:
Laravel 5.3 pass data to Modal to edit the Comment
Here is my button:
my $post->comment contained id, comment, email and name;
I want to pass the comment to the form inside the modal.
I also want to use the id to the 2nd parameter of the route to update the comment

```<code>@foreach($post->comments as $comment)
    <button class="btn btn-success btn-xs " data-toggle="modal" data-target="#myModal" data-id="{{ $comment->id }}" data-comment=" {{ $comment->comment }}"><i class="fa fa-pencil"></i></button>
    @endforeach
</code>```

Here is my modal:

```<code>  <!-- Modal -->
  <div class="modal fade modal-md" id="myModal" role="dialog">
    <div class="modal-dialog">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×
          </button>
          <h4 class="modal-title">Comment Update!</h4>
        </div>
        <div class="modal-body">
        <div id="comment-form" class="">
        {{ Form::open(['route' => ['comments.store', $post->id], 'method' => 'POST']) }}
        <div class="row">
        <div class="col-md-12">
        <b>{{ Form::label('comment', "Comment:") }}</b>
        {{ Form::textarea('comment', null, ['class' => 'form-control', 'rows' => '5', 'id'=>'comment ']) }}
        </div>
        </div>
        {{ Form::close() }}
        </div>
        </div>
        <div class="modal-footer">
        <a href="{{route('comments.store',$post->id) }}"
        onclick="event.preventDefault();
        document.getElementById('comment-update').submit();"  class="btn btn-primary">
            Update </a>
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
        </div>
        </div>
        </div>
        </div>
</code>```

I tried this Script but it wont work:

```<code><script type="text/javascript" charset="utf-8">
$('#myModal').on('show', function(e) {
var link = e.relatedTarget();

var id = link.data("id");
var comment = link.data("comment");

var modal = $(this);
modal.find("#id").val(id);
modal.find("#comment").val(comment);
</code>```

});

答:
you must using on click event in javascript

example:

```<code><button class="btn btn-success btn-xs add" data-toggle="modal" data-target="#myModal" data-id="{{ $comment->id }}" data-comment=" {{ $comment->comment }}"><i class="fa fa-pencil"></i></button>
</code>```

this script.

```<code>$(document).on('click', '.add', function() {
      $('#id_kategori').val($(this).data('id'));
      $('#comment').val($(this).data('comment'));
      $('.form-horizontal').show();
      $('#myModal').modal('show');
  });
</code>```

i hope my answer helping you

Body:
Here is my button:
my $post->comment contained id, comment, email and name;
I want to pass the comment to the form inside the modal.
I also want to use the id to the 2nd parameter of the route to update the comment

@foreach($post->comments as $comment)
    <button class="btn btn-success btn-xs " data-toggle="modal" data-target="#myModal" data-id="{{ $comment->id }}" data-comment=" {{ $comment->comment }}"></button>
    @endforeach

Here is my modal:

          <button type="button" class="close" data-dismiss="modal">×
          </button>

Comment Update!

        {{ Form::open(['route' => ['comments.store', $post->id], 'method' => 'POST']) }}

        {{ Form::label('comment', "Comment:") }}
        {{ Form::textarea('comment', null, ['class' => 'form-control', 'rows' => '5', 'id'=>'comment ']) }}

        {{ Form::close() }}

        id) }}"
        onclick="event.preventDefault();
        document.getElementById('comment-update').submit();"  class="btn btn-primary">
            Update
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

I tried this Script but it wont work:

Body:
you must using on click event in javascript

example:

<button class="btn btn-success btn-xs add" data-toggle="modal" data-target="#myModal" data-id="{{ $comment->id }}" data-comment=" {{ $comment->comment }}"><i class="fa fa-pencil"></i></button>

this script.

$(document).on('click', '.add', function() {
      $('#id_kategori').val($(this).data('id'));
      $('#comment').val($(this).data('comment'));
      $('.form-horizontal').show();
      $('#myModal').modal('show');
  });

i hope my answer helping you


问:
Why my php header() is not working?
My simple header() function not working.

login.php

```<code><html>
<head>
    <link rel="stylesheet" href="../css/bootstrap.css">
        <link rel="stylesheet" href="../css/style.css">
</head>
<body>
<div class="container ">
<div class="row">
    <div class="input-form">
        <h2 align="center" style="padding-top: 10px;">Log In</h2>
        <form action="logincheck.php" method="post">
        <div class="form-group">
            <label class="label1">UserName</label>
            <input name="username" type="text" class="form-control" id="" placeholder="username">
        </div>
        <div class="form-group">
            <label class="label2">Password</label>
            <input name="password" type="password" class="form-control" id="" placeholder="********">
        </div>
        <input type="submit" name="submit" class="btn btn-default" value="LOG IN">
        <?php /*
            if($errormsg != ""){
                    echo '<label class="label3 alert alert-danger">'.$errormsg.'</label>';
            } */
        ?>
        </form>
    </div>
</div>
</div>
</code>```

And my logincheck.php is

```<code><?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    header("location : login.php");
?>
</code>```

And I got " The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster. "

答:
In your logincheck.php file header should be like

```<code>header("Location : login.php");
</code>```

Title: Why my php header() is not working?

Body:
My simple header() function not working.

login.php

    <link rel="stylesheet" href="../css/bootstrap.css">
        <link rel="stylesheet" href="../css/style.css">

Log In

        <form action="logincheck.php" method="post">

            UserName
            <input name="username" type="text" class="form-control" id="" placeholder="username">

            Password
            <input name="password" type="password" class="form-control" id="" placeholder="********">

        <input type="submit" name="submit" class="btn btn-default" value="LOG IN">
        <?php /*
            if($errormsg != ""){
                    echo ''.$errormsg.'';
            } */
        ?>
        </form>

And my logincheck.php is

<?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    header("location : login.php");
?>

And I got " The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster. "

Body:
In your logincheck.php file header should be like

header("Location : login.php");