.NET 预定义调色板颜色列表的 MS 图表?

Posted

技术标签:

【中文标题】.NET 预定义调色板颜色列表的 MS 图表?【英文标题】:MS Chart for .NET predefined palettes color list? 【发布时间】:2012-12-21 16:57:06 【问题描述】:

Microsoft Chart for .NET (3.5, 4.x) 具有预定义的调色板,例如Berry、Bright、SeaGreen 等。

是否有每个调色板(十六进制或命名)的颜色列表?

谢谢!

【问题讨论】:

【参考方案1】:

在Alex Gorev's blog找到这张图片

我想我可以使用颜色选择器来获取实际的颜色名称/代码

编辑:这是我提取的颜色列表:

Berry: 8A2BE2,BA55D3,4169E1,C71585,0000FF,8019E0,DA70D6,7B68EE,C000C0,0000CD,800080
Bright: 008000,0000FF,800080,800080,FF00FF,008080,FFFF00,808080,00FFFF,000080,800000,FF3939,7F7F00,C0C0C0,FF6347,FFE4B5
BrightPastel: 418CF0,FCB441,DF3A02,056492,BFBFBF,1A3B69,FFE382,129CDD,CA6B4B,005CDB,F3D288,506381,F1B9A8,E0830A,7893BE
Chocolate: A0522D,D2691E,8B0000,CD853F,A52A2A,F4A460,8B4513,C04000,B22222,B65C3A
EarthTones: 33023,B8860B,C04000,6B8E23,CD853F,C0C000,228B22,D2691E,808000,20B2AA,F4A460,00C000,8FBC8B,B22222,843A05,C00000
Excel: 9999FF,993366,FFFFCC,CCFFFF,660066,FF8080,0063CB,CCCCFF,000080,FF00FF,FFFF00,00FFFF,800080,800000,007F7F,0000FF
Fire: FFD700,FF0000,FF1493,DC143C,FF8C00,FF00FF,FFFF00,FF4500,C71585,DDE221
GrayScale: C8C8C8,BDBDBD,B2B2B2,A7A7A7,9C9C9C,919191,868686,7A7A7A,707070,656565,565656,4F4F4F,424242,393939,2E2E2E,232323
Light: E6E6FA,FFF0F5,FFDAB9,,FFFACD,,FFE4E1,F0FFF0,F0F8FF,F5F5F5,FAEBD7,E0FFFF
Pastel: 87CEEB,32CD32,BA55D3,F08080,4682B4,9ACD32,40E0D0,FF69B4,F0E68C,D2B48C,8FBC8B,6495ED,DDA0DD,5F9EA0,FFDAB9,FFA07A
SeaGreen: 2E8B57,66CDAA,4682B4,008B8B,5F9EA0,38B16E,48D1CC,B0C4DE,8FBC8B,87CEEB
SemiTransparent: FF6969,69FF69,6969FF,FFFF5D,69FFFF,FF69FF,CDB075,FFAFAF,AFFFAF,AFAFFF,FFFFAF,AFFFFF,FFAFFF,E4D5B5,A4B086,819EC1

【讨论】:

提取完名称/颜色后,您一定要回来并在此处发布。 @GabrielBB 没问题。很高兴这些信息很有用。 @YuriyGalanter 嘿,感谢您发布此信息。这些颜色现在也可以从 Microsoft 的参考来源获得。看看:github.com/Microsoft/referencesource/blob/master/…【参考方案2】:

我创建了一个扩展类,它返回托盘的颜色列表。

using System.Collections.Generic;
using System.Drawing;
using Color = System.Drawing.Color;

namespace Extensions.Colors 
    public static class ChartColorPallets   

        public static List<Color> Bright 
            => new List<Color>() 
                "#008000".FromHex(),
                "#0000FF".FromHex(),
                "#800080".FromHex(),
                "#00FF00".FromHex(),
                "#FF00FF".FromHex(),
                "#008080".FromHex(),
                "#FFFF00".FromHex(),
                "#808080".FromHex(),
                "#00FFFF".FromHex(),
                "#000080".FromHex(),
                "#800000".FromHex(),
                "#FF0000".FromHex(),
                "#808000".FromHex(),
                "#C0C0C0".FromHex(),
                "#FF6347".FromHex(),
                "#FFE4B5".FromHex()
        ;
        public static List<Color> GreyScale 
            => new List<Color>() 
                "#C8C8C8".FromHex(),
                "#BDBDBD".FromHex(),
                "#B2B2B2".FromHex(),
                "#A7A7A7".FromHex(),
                "#9C9C9C".FromHex(),
                "#919191".FromHex(),
                "#868686".FromHex(),
                "#7B7B7B".FromHex(),
                "#707070".FromHex(),
                "#656565".FromHex(),
                "#5A5A5A".FromHex(),
                "#4F4F4F".FromHex(),
                "#444444".FromHex(),
                "#393939".FromHex(),
                "#2E2E2E".FromHex(),
                "#232323".FromHex()
        ;
        public static List<Color> Excel 
            => new List<Color>() 
                "#9999FF".FromHex(),
                "#993366".FromHex(),
                "#FFFFCC".FromHex(),
                "#CCFFFF".FromHex(),
                "#660066".FromHex(),
                "#FF8080".FromHex(),
                "#0066CC".FromHex(),
                "#CCCCFF".FromHex(),
                "#000080".FromHex(),
                "#FF00FF".FromHex(),
                "#FFFF00".FromHex(),
                "#00FFFF".FromHex(),
                "#800080".FromHex(),
                "#800000".FromHex(),
                "#008080".FromHex(),
                "#0000FF".FromHex()
        ;
        public static List<Color> Light 
            => new List<Color>() 
                "#E6E6FA".FromHex(),
                "#FFF0F5".FromHex(),
                "#FFDAB9".FromHex(),
                "#FFFACD".FromHex(),
                "#FFE4E1".FromHex(),
                "#F0FFF0".FromHex(),
                "#F0F8FF".FromHex(),
                "#F5F5F5".FromHex(),
                "#FAEBD7".FromHex(),
                "#E0FFFF".FromHex()
        ;
        public static List<Color> Pastel 
            => new List<Color>() 
                "#87CEEB".FromHex(),
                "#32CD32".FromHex(),
                "#BA55D3".FromHex(),
                "#F08080".FromHex(),
                "#4682B4".FromHex(),
                "#9ACD32".FromHex(),
                "#40E0D0".FromHex(),
                "#FF69B4".FromHex(),
                "#F0E68C".FromHex(),
                "#D2B48C".FromHex(),
                "#8FBC8B".FromHex(),
                "#6495ED".FromHex(),
                "#DDA0DD".FromHex(),
                "#5F9EA0".FromHex(),
                "#FFDAB9".FromHex(),
                "#FFA07A".FromHex()
        ;
        public static List<Color> EarthTones 
            => new List<Color>() 
                "#FF8000".FromHex(),
                "#B8860B".FromHex(),
                "#C04000".FromHex(),
                "#6B8E23".FromHex(),
                "#CD853F".FromHex(),
                "#C0C000".FromHex(),
                "#228B22".FromHex(),
                "#D2691E".FromHex(),
                "#808000".FromHex(),
                "#20B2AA".FromHex(),
                "#F4A460".FromHex(),
                "#00C000".FromHex(),
                "#8FBC8B".FromHex(),
                "#B22222".FromHex(),
                "#8B4513".FromHex(),
                "#C00000".FromHex()
        ;
        public static List<Color> SemiTransparent 
            => new List<Color>() 
                "#FF0000".FromHex(),
                "#00FF00".FromHex(),
                "#0000FF".FromHex(),
                "#FFFF00".FromHex(),
                "#00FFFF".FromHex(),
                "#FF00FF".FromHex(),
                "#AA7814".FromHex(),
                "#FF0000".FromHex(),
                "#00FF00".FromHex(),
                "#0000FF".FromHex(),
                "#FFFF00".FromHex(),
                "#00FFFF".FromHex(),
                "#FF00FF".FromHex(),
                "#AA7814".FromHex(),
                "#647832".FromHex(),
                "#285A96".FromHex()
        ;
        public static List<Color> Berry
            => new List<Color>() 
                "#8A2BE2".FromHex(),
                "#BA55D3".FromHex(),
                "#4169E1".FromHex(),
                "#C71585".FromHex(),
                "#0000FF".FromHex(),
                "#8A2BE2".FromHex(),
                "#DA70D6".FromHex(),
                "#7B68EE".FromHex(),
                "#C000C0".FromHex(),
                "#0000CD".FromHex(),
                "#800080".FromHex()
        ;
        public static List<Color> Chocolate 
            => new List<Color>() 
                "#A0522D".FromHex(),
                "#D2691E".FromHex(),
                "#8B0000".FromHex(),
                "#CD853F".FromHex(),
                "#A52A2A".FromHex(),
                "#F4A460".FromHex(),
                "#8B4513".FromHex(),
                "#C04000".FromHex(),
                "#B22222".FromHex(),
                "#B65C3A".FromHex()
        ;
        public static List<Color> Fire
            => new List<Color>() 
                "#FFD700".FromHex(),
                "#FF0000".FromHex(),
                "#FF1493".FromHex(),
                "#DC143C".FromHex(),
                "#FF8C00".FromHex(),
                "#FF00FF".FromHex(),
                "#FFFF00".FromHex(),
                "#FF4500".FromHex(),
                "#C71585".FromHex(),
                "#DDE221".FromHex()
        ;
        public static List<Color> SeaGreen 
            => new List<Color>() 
                "#2E8B57".FromHex(),
                "#66CDAA".FromHex(),
                "#4682B4".FromHex(),
                "#008B8B".FromHex(),
                "#5F9EA0".FromHex(),
                "#3CB371".FromHex(),
                "#48D1CC".FromHex(),
                "#B0C4DE".FromHex(),
                "#8FBC8B".FromHex(),
                "#87CEEB".FromHex()
        ;
        public static List<Color> BrightPastel
            => new List<Color>() 
                "#418CF0".FromHex(),
                "#FCB441".FromHex(),
                "#E0400A".FromHex(),
                "#056492".FromHex(),
                "#BFBFBF".FromHex(),
                "#1A3B69".FromHex(),
                "#FFE382".FromHex(),
                "#129CDD".FromHex(),
                "#CA6B4B".FromHex(),
                "#005CDB".FromHex(),
                "#F3D288".FromHex(),
                "#506381".FromHex(),
                "#F1B9A8".FromHex(),
                "#E0830A".FromHex(),
                "#7893BE".FromHex()
        ;
        private static Color FromHex(this string hex) => ColorTranslator.Fromhtml(hex);
    

然后就可以获取颜色列表了,只要包含命名空间,就可以调用了

List<Color> brightColors = ChartColorPallets.Bright;

【讨论】:

【参考方案3】:

+1 对 Yuriy 的回答,但如果您正在寻找确切的颜色(33023 不是有效颜色,以及其他不匹配的颜色),我在这里从实际值中提取它们:

Bright: "#008000", "#0000FF", "#800080", "#00FF00", "#FF00FF", "#008080", "#FFFF00", "#808080", "#00FFFF", "#000080", "#800000", "#FF0000", "#808000", "#C0C0C0", "#FF6347", "#FFE4B5"
Grayscale: "#C8C8C8", "#BDBDBD", "#B2B2B2", "#A7A7A7", "#9C9C9C", "#919191", "#868686", "#7B7B7B", "#707070", "#656565", "#5A5A5A", "#4F4F4F", "#444444", "#393939", "#2E2E2E", "#232323"
Excel: "#9999FF", "#993366", "#FFFFCC", "#CCFFFF", "#660066", "#FF8080", "#0066CC", "#CCCCFF", "#000080", "#FF00FF", "#FFFF00", "#00FFFF", "#800080", "#800000", "#008080", "#0000FF"
Light: "#E6E6FA", "#FFF0F5", "#FFDAB9", "#FFFACD", "#FFE4E1", "#F0FFF0", "#F0F8FF", "#F5F5F5", "#FAEBD7", "#E0FFFF"
Pastel: "#87CEEB", "#32CD32", "#BA55D3", "#F08080", "#4682B4", "#9ACD32", "#40E0D0", "#FF69B4", "#F0E68C", "#D2B48C", "#8FBC8B", "#6495ED", "#DDA0DD", "#5F9EA0", "#FFDAB9", "#FFA07A"
EarthTones: "#FF8000", "#B8860B", "#C04000", "#6B8E23", "#CD853F", "#C0C000", "#228B22", "#D2691E", "#808000", "#20B2AA", "#F4A460", "#00C000", "#8FBC8B", "#B22222", "#8B4513", "#C00000"
SemiTransparent: "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#AA7814", "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#AA7814", "#647832", "#285A96"
Berry: "#8A2BE2", "#BA55D3", "#4169E1", "#C71585", "#0000FF", "#8A2BE2", "#DA70D6", "#7B68EE", "#C000C0", "#0000CD", "#800080"
Chocolate: "#A0522D", "#D2691E", "#8B0000", "#CD853F", "#A52A2A", "#F4A460", "#8B4513", "#C04000", "#B22222", "#B65C3A"
Fire: "#FFD700", "#FF0000", "#FF1493", "#DC143C", "#FF8C00", "#FF00FF", "#FFFF00", "#FF4500", "#C71585", "#DDE221"
SeaGreen: "#2E8B57", "#66CDAA", "#4682B4", "#008B8B", "#5F9EA0", "#3CB371", "#48D1CC", "#B0C4DE", "#8FBC8B", "#87CEEB"
BrightPastel: "#418CF0", "#FCB441", "#E0400A", "#056492", "#BFBFBF", "#1A3B69", "#FFE382", "#129CDD", "#CA6B4B", "#005CDB", "#F3D288", "#506381", "#F1B9A8", "#E0830A", "#7893BE"

【讨论】:

【参考方案4】:

不久前我花了很长时间试图找到相同的信息,但从未找到答案。

我最终不得不自己“发现”这些价值观。我只需要 BrighPastel 调色板,这就是我发现的:

'See Color Palette details here:http://blogs.msdn.com/b/alexgor/archive/2009/10/06/setting-chart-series-colors.aspx
Public BrightPastel_ColorPalette As Integer() = 15764545, 4306172, 671968, 9593861, 12566463, 6896410, 8578047, 14523410, 4942794, 14375936, 8966899, 8479568, 11057649, 689120, 12489592

HTH

【讨论】:

【参考方案5】:

根据查看的文档

http://technet.microsoft.com/en-us/library/dd239355(v=sql.100).aspx

它是一组常用的 Microsoft 颜色代码 所有这些列表都可以在这里找到

http://msdn.microsoft.com/library/ms531197.aspx

【讨论】:

谢谢,但这并不是我想要的。如果您查看实际的调色板(颜色列表),例如blogs.msdn.com/b/alexgor/archive/2009/10/06/…(哦,它是用于 ASP.NET 而不是用于报告),我需要每个命名调色板的特定颜色列表,例如:“Berry = 00FF22, 2211DE, ....”【参考方案6】:

我不可能是唯一一个希望能够在网页上看到此内容的人。所以这里有一些快速而肮脏的 VB.NET 代码来显示它。只需在页面上添加一个名为“LitColors”的文字即可。

希望这可以节省 30 分钟。

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim ArrBright() As String = "#008000", "#0000FF", "#800080", "#00FF00", "#FF00FF", "#008080", "#FFFF00", "#808080", "#00FFFF", "#000080", "#800000", "#FF0000", "#808000", "#C0C0C0", "#FF6347", "#FFE4B5"
    Dim ArrGrayscale() As String = "#C8C8C8", "#BDBDBD", "#B2B2B2", "#A7A7A7", "#9C9C9C", "#919191", "#868686", "#7B7B7B", "#707070", "#656565", "#5A5A5A", "#4F4F4F", "#444444", "#393939", "#2E2E2E", "#232323"
    Dim ArrExcel() As String = "#9999FF", "#993366", "#FFFFCC", "#CCFFFF", "#660066", "#FF8080", "#0066CC", "#CCCCFF", "#000080", "#FF00FF", "#FFFF00", "#00FFFF", "#800080", "#800000", "#008080", "#0000FF"
    Dim ArrLight() As String = "#E6E6FA", "#FFF0F5", "#FFDAB9", "#FFFACD", "#FFE4E1", "#F0FFF0", "#F0F8FF", "#F5F5F5", "#FAEBD7", "#E0FFFF"
    Dim ArrPastel() As String = "#87CEEB", "#32CD32", "#BA55D3", "#F08080", "#4682B4", "#9ACD32", "#40E0D0", "#FF69B4", "#F0E68C", "#D2B48C", "#8FBC8B", "#6495ED", "#DDA0DD", "#5F9EA0", "#FFDAB9", "#FFA07A"
    Dim ArrEarthTones() As String = "#FF8000", "#B8860B", "#C04000", "#6B8E23", "#CD853F", "#C0C000", "#228B22", "#D2691E", "#808000", "#20B2AA", "#F4A460", "#00C000", "#8FBC8B", "#B22222", "#8B4513", "#C00000"
    Dim ArrSemiTransparent() As String = "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#AA7814", "#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#00FFFF", "#FF00FF", "#AA7814", "#647832", "#285A96"
    Dim ArrBerry() As String = "#8A2BE2", "#BA55D3", "#4169E1", "#C71585", "#0000FF", "#8A2BE2", "#DA70D6", "#7B68EE", "#C000C0", "#0000CD", "#800080"
    Dim ArrChocolate() As String = "#A0522D", "#D2691E", "#8B0000", "#CD853F", "#A52A2A", "#F4A460", "#8B4513", "#C04000", "#B22222", "#B65C3A"
    Dim ArrFire() As String = "#FFD700", "#FF0000", "#FF1493", "#DC143C", "#FF8C00", "#FF00FF", "#FFFF00", "#FF4500", "#C71585", "#DDE221"
    Dim ArrSeaGreen() As String = "#2E8B57", "#66CDAA", "#4682B4", "#008B8B", "#5F9EA0", "#3CB371", "#48D1CC", "#B0C4DE", "#8FBC8B", "#87CEEB"
    Dim ArrBrightPastel() As String = "#418CF0", "#FCB441", "#E0400A", "#056492", "#BFBFBF", "#1A3B69", "#FFE382", "#129CDD", "#CA6B4B", "#005CDB", "#F3D288", "#506381", "#F1B9A8", "#E0830A", "#7893BE"

    Dim HTML As String = ""
    HTML = HTML & "<table>"


    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Bright</td>"
    For Each a In ArrBright
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>GrayScale</td>"
    For Each a In ArrGrayscale
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Excel</td>"
    For Each a In ArrExcel
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Light</td>"
    For Each a In ArrLight
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Pastel</td>"
    For Each a In ArrPastel
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>EarthTomes</td>"
    For Each a In ArrEarthTones
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Semi Transparent</td>"
    For Each a In ArrSemiTransparent
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Berry</td>"
    For Each a In ArrBerry
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Chocolate</td>"
    For Each a In ArrChocolate
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>Fire</td>"
    For Each a In ArrFire
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>SeaGreen</td>"
    For Each a In ArrSeaGreen
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "<tr>"
    HTML = HTML & "<td>BrightPastel</td>"
    For Each a In ArrBrightPastel
        HTML = HTML & "<td style=""background: " & a.ToString & " "" >" & a.ToString & "</td>"
    Next
    HTML = HTML & "</tr><tr><td>&nbsp;</td></tr>"

    HTML = HTML & "</table>"

    LitColors.Text = HTML
End Sub

【讨论】:

【参考方案7】:

随着 .NET 的开源,您可以在此处找到所有图表调色板颜色:

https://github.com/dotnet/winforms-datavisualization/blob/main/src/System.Windows.Forms.DataVisualization/Utilities/ColorPalette.cs

【讨论】:

以上是关于.NET 预定义调色板颜色列表的 MS 图表?的主要内容,如果未能解决你的问题,请参考以下文章

seaborn使用boxplot函数进行箱图可视化(使用色彩调色板自定义设置箱图的颜色自定义颜色列表并创建为自己的调色板sns.set_palette全局设置palette参数)

同一 s-s-rS 2008 图表的条件调色板(或颜色集)

为啥调色板只对所有条应用一种颜色?

可视化 R 中的颜色/调色板列表

如何添加自定义 MUI 调色板颜色

Seaborn 调色板不适用于线图