Highcharts动态更改图例选项

时间:2015-11-17 11:22:19

标签: javascript highcharts

初始选项(这是垂直可拖动的图例):

private void showDialog() {
    //Here is ur gridview
    GridView gridView = new GridView(ctx);

    List<Integer>  mList = new ArrayList<Integer>();
    for (int i = 1 ; i < 20; i++) {
        mList.add(i);
    }

    gridView.setAdapter(new ArrayAdapter(ctx, android.R.layout.simple_list_item_1, mList));
    gridView.setNumColumns(4);
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // do what ev you want with ur stuff here
        }
    });

    // Here you can set grid view to ur dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(ctxI);
    builder.setView(gridView);
    builder.setTitle("Its me !!");
    builder.show();
}

我想让传奇看起来像http://jsfiddle.net/yqypj4qr/。 我真的想要, align:center,verticalAlign:bottom,layout:horizo​​ntal,borderwidth:0,shadow:false

我已经尝试过以下代码。 (尝试直接更改图例并使用选项变量并更新)

id : '<?=$id?>',
layout: 'vertical',
backgroundColor: 'white',
align: 'right',
verticalAlign: 'top',
y: legendY,
x: legendX,
borderWidth: 1,
borderRadius: 0,
title: {
   text: '::'
},
floating: true,
draggable: true

如何将可拖动图例转换为默认图例?

1 个答案:

答案 0 :(得分:1)

如果要更改图表选项,则必须销毁旧图表并创建新图表;

这里是删除阴影的jsfiddle示例,您也可以添加其他选项。

var c = $('#container').highcharts();
    var o = c.options;
    o.legend.shadow = false; 
    c  = new Highcharts.Chart(o);

http://jsfiddle.net/43ur8xyq/