我想要这个堆叠柱形图Demo column stacked和这个Basic Column with line。我想要的是在这个堆叠柱形图中有一条线。
注意:我发现这个例子已经存在于stackoverflow,Stacked bar with line中,但不能真正使它成为一个带有line的堆叠列。
我使用HighCharts.Net插件,我的代码堆叠酒吧是:
Highcharts chart = new Highcharts("chart");
chart.SetSeries(new[]
{
new Series { Name = "Title1", Data = new Data(data1) },
new Series { Name = "Title2", Data = new Data(data2) },
new Series { Name = "Title3", Data = new Data(data3) },
new Series { Name = "Title4", Data = new Data(data4) }
});
chart.InitChart(new Chart {DefaultSeriesType = ChartTypes.Column});
chart.SetTitle(new Title{Text = "Graph title" });
chart.SetXAxis(new XAxis { Categories = xaxis });
chart.SetYAxis(new YAxis
{
Min = 0,
Title = new YAxisTitle { Text = "Total hit" },
StackLabels = new YAxisStackLabels
{
Enabled = true,
Style = "fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'"
}
});
chart.SetLegend(new Legend
{
Layout = Layouts.Horizontal,
Align = HorizontalAligns.Right,
VerticalAlign = VerticalAligns.Top,
X = -100,
Y = 20,
Floating = true,
BackgroundColor = new BackColorOrGradient(ColorTranslator.FromHtml("#FFFFFF")),
BorderColor = ColorTranslator.FromHtml("#CCC"),
BorderWidth = 1,
Shadow = false
});
chart.SetPlotOptions(new PlotOptions
{
Column = new PlotOptionsColumn
{
Stacking = Stackings.Normal,
DataLabels = new PlotOptionsColumnDataLabels
{
Enabled = true,
Color = Color.White
}
}
});
ltrChart.Text = chart.ToHtmlString();
有人能帮忙吗?
2条答案
按热度按时间xxhby3vn1#
这是一个简单的JS解决方案。
HTML:
JS:
我做了一个JS小提琴与这个例子。你可以查here
wlwcrazw2#
我不敢相信它是如此简单,我只是用代码试验,它只是得到解决。我所要做的就是添加一个新的系列,并在每个系列中指定类型。