score:1

Accepted answer

what about setting the x values for those lines? http://jsfiddle.net/qpqcw/

, {
        name: "revenue",
        data: [
            {x:-0.2, y:49},
            {x:0.8, y:71.5},
            {x:1.8, y:106.4}],
        type: "line"
    }, 

, {
        name: "operating expenses",
        data: [
            {x:.2,y:48.9},
            {x:1.2, y:38.8},
            {x:2.2, y:39.3}],
        type: "line"
    }

to calculate the x values, i looked to the source code. the following assumes you are using the default values of grouppadding .2, and pointpadding .1. i modified the getcolumnmetrics function to get the general solution. here's what i came up with:

var columnmetrics = [];
    for (j=0;j<index;j++) {

        var categorywidth = 1,
            grouppadding = categorywidth * .2,
            groupwidth = categorywidth - 2 * grouppadding,
            pointoffsetwidth = groupwidth / index,
            pointpadding =  pointoffsetwidth * .1,
            pointwidth = pointoffsetwidth - 2 * pointpadding, 
            colindex =  j,
            pointxoffset = pointpadding + (grouppadding + colindex *
                pointoffsetwidth - (categorywidth / 2));

        columnmetrics.push( { 
            width: pointwidth, 
            offset: pointxoffset,
            center: pointxoffset + (pointwidth /2.0)
        });
    }
    var series = [];
    for(i=0;i<index;i++) {
        series.push({
            name: "column" + index,
            data: [
            49.9,
            71.5,
            106.4],
            type: "column"
        });
        series.push({
            name: "line" + index,
            data: [
                {x:0 + columnmetrics[i].center, y:49},
                {x:1 + columnmetrics[i].center, y:71.5},
                {x:2 + columnmetrics[i].center, y:106.4}],
            type: "line"
        });
    }

this shows the results with 1 to 10 series: http://jsfiddle.net/b8gs5/


Related Query

More Query from same tag