Highcharts堆积柱线

赛义夫

我希望此堆积柱形图演示柱与带有的基本列一起堆积我想要的是在此堆积柱形图中有一条线。

注意:我发现该示例已经存在于stackoverflow中,带有line的Stacked bar,但不能真正使它成为带有line的stacked column。

我正在使用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();

有人可以帮忙吗?

这是使用普通JS的解决方案。

HTML:

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 500px; margin: 0 auto"></div>

JS:

$(function () {
  $('#container').highcharts({
    chart: {
        zoomType: 'xy'
    },
    colors: ['#7cb5ec', '#91e8e1', '#90ed7d'],

    title: {
        text: 'Something '
    },
    subtitle: {
        text: 'subsomething'
    },
    xAxis: [{
        categories: ['1/1','2/1','3/1','4/1', '5/1', '6/1','7/1','8/1','9/1','10/1','11/1', '12/1', '13/1', '14/1', '15/1']
                    }],
    yAxis: [{ // Primary yAxis
        labels: {
            format: '{value} %',
            style: {
                color: Highcharts.getOptions().colors[1]
            }
        },
        min: 0,
        max:100,
        title: {
            text: 'Percent',
            style: {
                color: Highcharts.getOptions().colors[1]
            }
        }
    }, { // Secondary yAxis
        title: {
            text: '',
            style: {
                color: Highcharts.getOptions().colors[0]
            }
        },
        min: 0,
        max: 100,
        labels: {
            format: '{value} %',
            style: {
                color: Highcharts.getOptions().colors[0],
                display:'none'
            }
        },
        opposite: true
    }],
    tooltip: {
        shared: true
    },
    legend: {
        layout: 'vertical',
        align: 'center',
        x: -0,
        verticalAlign: 'top',
        y: 400,
        floating: true,
        backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
    },
    plotOptions: {
        column: {
            stacking: 'percent'
        }
    },
    series: [
        {
        name: 'suff1',
        type: 'column',

        yAxis: 1,
        data: [20, 25, 10,30,80, 20, 25, 10,30,80, 20, 25, 10,30,80],
        tooltip: {
            valueSuffix: ' %'
        }

    }, 
      {
          name: 'suff2',
        type: 'column',

        yAxis: 1,
       tooltip: {
            valueSuffix: ' %'
        },
        data: [30, 50, 30,30,10, 30, 50, 30,30,10, 30, 50, 30,30,10]
    }, {
        name: 'suff3',
        yAxis: 1,
        type: 'column',
        tooltip: {
            valueSuffix: ' %'
        },
        data: [50,25, 60, 40, 10, 50,25, 60, 40, 10, 50,25, 60, 40, 10]
    },
      {
        name: 'NS',
        type: 'spline',

        data: [45,55,74,85,81, 45,55,74,85,81, 45,55,74,85,81],
        tooltip: {
            valueSuffix: '%'
        }
    }]
 });
 });

我用这个例子做了一个JS小提琴。你可以在这里检查

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

高图堆积柱

来自分类Dev

高图组的堆积柱

来自分类Dev

堆叠柱与线结合

来自分类Dev

CfChart堆积的条和堆积的线

来自分类Dev

高图X轴值位于堆积柱顶部

来自分类Dev

堆积柱高图改变x和y

来自分类Dev

高图X轴值在堆积柱顶

来自分类Dev

从重采样中找到最高和最低柱线号

来自分类Dev

如何在堆积的柱高图表中显示额外数据的总数

来自分类Dev

使用jfreechart的具有上限线的堆积条形图

来自分类Dev

使用晶格和R的多因素堆积线

来自分类Dev

堆积条形图上的误差线,使用plotly或ggplotly

来自分类Dev

R中堆积条形图上的滚动平均趋势线

来自分类Dev

堆积条形图ggplot上的单个误差线

来自分类Dev

R中的堆积条形图,比例线超标

来自分类Dev

将趋势线添加到堆积的条形图中

来自分类Dev

在R中使用指定的误差线值制作堆积的线图

来自分类Dev

Google图表-堆积柱形图的趋势线

来自分类Dev

Highcharts工具提示错误,带有堆积的柱形图

来自分类Dev

Highcharts 4.0.3堆积的条形图错误添加-

来自分类Dev

在Highcharts中对堆积的条形图进行分组

来自分类Dev

Highcharts-带有堆积列的详细信息图表

来自分类Dev

HighCharts堆积的列,将Onclick事件添加到图表

来自分类Dev

highcharts 示例中的堆积组柱状图

来自分类Dev

地图上两个点之间的堆积线(或多线?)

来自分类Dev

结合 100% 堆积面积和柱状图系列,强制值轴仅使用柱系列值

来自分类Dev

Highcharts网格线高度低于样条线

来自分类Dev

Highcharts.js绘制难看的系列线

来自分类Dev

Highcharts - 误差线更改图例符号