图表创建中的散列问题 [英] Issue with Hash in chart creation

查看:100
本文介绍了图表创建中的散列问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 <$创建图表c $ c> Get-CorpChart-FullEdition 脚本,我发现图表创建非常好。




现在,你所要做的就是给予 $ Cities 参数作为 -Data 参数,并将 -Obj_Key 参数提供为City_Name -Obj_Value asCity_Population


  $ active_inactive = @ {} 
$ red = 15
$ orange = 25
$ active_inactive ['active'] = $ red
$ active_inactive ['inactive'] = $ orange

。 D:\Auto\Get-Corpchart-LightEdition.ps1-data $ active_inactive -obj_keyName-obj_valueValue-filepathc:\chart1.pngtype types

$ active_inactive中的数据

名称值
---- -----
非活动7
活动3


$ b b

问题是我收到一个空白的chart1.png文件。这似乎是我的哈希表的问题。



任何人可以建议我,如果我如上所述正确创建散列表。

.GetEnumarator()
方法 p>


有效地将散列表中的每个条目作为单独的对象发送到管道。




 。 D:\Auto\Get-Corpchart-LightEdition.ps1-data $ active_inactive.GetEnumerator()-obj_keyName-obj_valueValue-filepathc:\chart1.pngtype types 

查看脚本轻量级代码的代码,参数期待一个数组] 而不是散列表。



你最好根据hashtable的
数据创建自己的自定义对象

  [pscustomobject] @ {
State =Active
Value = 15
},[pscustomobject] @ {
State =Inactive
Value = 25
}

这种方法更有效的方法,所以上面的只是一个例子。


I am trying to create chart by Get-CorpChart-FullEdition script, which I found very good in chart creation.

On the website I found below instruction.

So now, all what you have to do is to give the $Cities array to the function as -Data parameter, and supply the -Obj_Key parameter as "City_Name", and -Obj_Value as "City_Population"

I created a hash like this:

$active_inactive = @{}
$red = 15
$orange = 25
$active_inactive['active']= $red
$active_inactive['inactive'] = $orange

. "D:\Auto\Get-Corpchart-LightEdition.ps1" -data $active_inactive -obj_key "Name" -obj_value "Value" -filepath "c:\chart1.png" -type pie

Data in $active_inactive:

Name                           Value
----                           -----
inactive                       7
active                         3

Problem is I am getting a blank chart1.png file. It seems like issue with my hashtable.

Can anybody advise me if I am creating the hashtable properly as described above or not?

解决方案

If you wanted to use a hashtable I think you can if you call the .GetEnumarator() method

which effectively sends each entry in the hash table across the pipeline as a separate object.

. "D:\Auto\Get-Corpchart-LightEdition.ps1" -data $active_inactive.GetEnumerator() -obj_key "Name" -obj_value "Value" -filepath "c:\chart1.png" -type pie

Looking at the code for the light edition of the script the parameter is expecting an [array] and not a hashtable.

You would be better of creating your own custom objects from that hashtable's data depending on how complex your date would get.

[pscustomobject]@{
    State="Active"
    Value=15
},[pscustomobject]@{
    State="Inactive"
    Value=25
}

Tonnes of ways to do this more effectively so the above is just an example.

这篇关于图表创建中的散列问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆