最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Highcharts legend custom css styleformat using only highcharts options - Stack Overflow

programmeradmin0浏览0评论

I've tried lots of binations in the legend options of the highcharts object, however I was not able to successfully realize the exact design that the designer made.

What I need is to be able to have a legend that looks exactly like this... Wanted legend layout

But the closest result that I achieved with the legend options available was this... The closest legend layout I could achieve

The properties I used within the highchart object definition were:

legend: {
    enabled: graphProperties.legend.enabled,
    backgroundColor: ...
    borderRadius: ...
    verticalAlign: ...
    align: ...
    borderWidth: ...
    x: ...
    y: ... }

Thank you in advance for any help.

I've tried lots of binations in the legend options of the highcharts object, however I was not able to successfully realize the exact design that the designer made.

What I need is to be able to have a legend that looks exactly like this... Wanted legend layout

But the closest result that I achieved with the legend options available was this... The closest legend layout I could achieve

The properties I used within the highchart object definition were:

legend: {
    enabled: graphProperties.legend.enabled,
    backgroundColor: ...
    borderRadius: ...
    verticalAlign: ...
    align: ...
    borderWidth: ...
    x: ...
    y: ... }

Thank you in advance for any help.

Share Improve this question asked May 11, 2012 at 15:49 DiscoPapaDiscoPapa 1,0442 gold badges14 silver badges27 bronze badges 2
  • 1 If possible can you throw up a sample set of data and code on jsFiddle? – wergeld Commented May 11, 2012 at 16:23
  • Sure, I'll try ass soon as I get back to work, since I cannot get to my work puter right now. – DiscoPapa Commented May 12, 2012 at 20:58
Add a ment  | 

1 Answer 1

Reset to default 6

Maybe you can use this as a starting point.

http://jsfiddle/DqAqu/4/

$(function () {
    var chart = new Highcharts.Chart({

        chart: {
            renderTo: 'container', 
            backgroundColor: '#F5F5F5', 
            plotBackgroundColor: '#FFFFFF'
        },

        symbols: [ 'square', 'square' ], 

        legend: {
            backgroundColor: '#F5F5F5',
            layout: 'horizontal',
            floating: true,
            align: 'left',
            verticalAlign: 'top',
            x: 60,
            y: 1,
            shadow: false, 
            border: 0, 
            borderRadius: 0, 
            borderWidth: 0
        },

        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], 
            color: '#47D147'            
        }, {
            data: [95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1], 
            color: '#19A3FF'            
        }]
    });
});​
发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>