如何减少DotNet.Highcharts中的列系列差距

时间:2016-06-28 08:50:17

标签: c# charts dotnethighcharts column-chart

我正在使用DotNet.Highchart Library创建我的图表,我在减少柱形图中数据系列之间的差距时遇到了问题。这是我目前的图表:

enter image description here

这是我目前的柱形图代码:

DotNet.Highcharts.Highcharts AttritionByReasonBarChart = new DotNet.Highcharts.Highcharts("AttritionByReasonBarChart")
                .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Height = 400, Width = 860, Style = "margin: '0 auto'" })
                .SetTitle(new Title { Text = "Attrition by Reason", Style = "font: 'normal 16px Verdana, sans-serif'" })
                .SetCredits(new Credits { Enabled = false })
                .SetXAxis(new XAxis
                {
                    Categories = vEmployment,
                    Labels = new XAxisLabels { Rotation = 0 }
                })
                .SetYAxis(new YAxis
                {
                    Title = new YAxisTitle
                    {
                        Text = "Employment Type",
                        Align = AxisTitleAligns.Middle
                    }
                })
                .SetPlotOptions(new PlotOptions
                {
                    Bar = new PlotOptionsBar
                    {
                        DataLabels = new PlotOptionsBarDataLabels { Enabled = true }
                    }
                })
                .SetLegend(new Legend
                {
                    Layout = Layouts.Vertical,
                    Align = HorizontalAligns.Right,
                    VerticalAlign = VerticalAligns.Middle,
                    Floating = true,
                    BorderWidth = 1,
                    BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")),
                    Shadow = true
                })
                .SetSeries(
                    new Series
                    { 
                        Name = "Head Count",
                        Data = new Data(vTotal)
                    });

有没有最好的方法来设置数据系列之间的差距? 感谢

1 个答案:

答案 0 :(得分:0)

PlotOptionsColumn替换为PointPadding,并将Highcharts AttritionByReasonBarChart = new Highcharts("AttritionByReasonBarChart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column, Height = 400, Width = 860, Style = "margin: '0 auto'" }) .SetTitle(new Title { Text = "Attrition by Reason", Style = "font: 'normal 16px Verdana, sans-serif'" }) .SetCredits(new Credits { Enabled = false }) .SetXAxis(new XAxis { Categories = new[] { "ABHFGFGETTRRD AGAGGSGSGS", "IEKHLTOTUYYT IIWWIIWEUEUEU", "KMVMVBBV DGDFEFJ", "KRJG JGJGJGT", "HAHAHSHSGD OTERETETE ET", "HAHAHA PRGDGDGDGDG DGT", "NRIRITITITITI WP", "DFC AHAHSSGGDF" }, Labels = new XAxisLabels { Rotation = 0 } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Employment Type", Align = AxisTitleAligns.Middle } }) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { PointPadding = -0.2, DataLabels = new PlotOptionsColumnDataLabels { Enabled = false } } }) .SetLegend(new Legend { Layout = Layouts.Vertical, Align = HorizontalAligns.Right, VerticalAlign = VerticalAligns.Middle, Floating = true, BorderWidth = 1, BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")), Shadow = true }) .SetSeries( new Series { Name = "Head Count", Data = new Data(new object[] { 30,10,5,20,5,10,25,15 }) }); 添加到您的代码中,如下所示:

> runGitHub("Climate-Change-1900-2014","OmaymaS",subdir = "Shiny_ClimateChange.zip")
Downloading https://github.com/OmaymaS/Climate-Change-1900-2014/archive/master.tar.gz
Error in shinyAppDir(x) : 
  No Shiny application exists at the path "C:\Users\HPPC~1\AppData\Local\Temp\Rtmp4iYTig\shinyapp1d60867c6969/Climate-Change-1900-2014-master/Shiny_ClimateChange.zip"


> runGitHub("Climate-Change-1900-2014","OmaymaS",subdir = "Shiny_ClimateChange")
Downloading https://github.com/OmaymaS/Climate-Change-1900-2014/archive/master.tar.gz
Error in shinyAppDir(x) : 
  No Shiny application exists at the path "C:\Users\HPPC~1\AppData\Local\Temp\Rtmp4iYTig\shinyapp1d6085ebc2c8d/Climate-Change-1900-2014-master/Shiny_ClimateChange"

> runUrl("https://github.com/OmaymaS/Climate-Change-1900-2014/blob/master/Shiny_ClimateChange.zip",filetype = ".zip")
Downloading https://github.com/OmaymaS/Climate-Change-1900-2014/blob/master/Shiny_ClimateChange.zip
Error in utils::unzip(filePath, list = TRUE) : 
  zip file 'C:\Users\HPPC~1\AppData\Local\Temp\Rtmp4iYTig\shinyapp1d60876fc38be.zip' cannot be opened


sessionInfo()

R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] curl_0.9.7      devtools_1.11.1 shiny_0.13.2    broom_0.4.1     RMySQL_0.10.6   DBI_0.3.1      

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5     magrittr_1.5    mnormt_1.5-4    xtable_1.8-2    lattice_0.20-31 R6_2.1.2       
 [7] stringr_1.0.0   plyr_1.8.4      dplyr_0.4.3     tools_3.2.1     parallel_3.2.1  grid_3.2.1     
[13] nlme_3.1-120    psych_1.6.4     withr_1.0.1     htmltools_0.3.5 yaml_2.1.13     assertthat_0.1 
[19] digest_0.6.9    tibble_1.0      reshape2_1.4.1  tidyr_0.5.1     rsconnect_0.4.3 memoise_1.0.0  
[25] mime_0.4        rmarkdown_0.9.2 stringi_1.1.1   jsonlite_0.9.21 httpuv_1.3.3   

enter image description here