javascript - 谷歌图表折线图上的直线向下?

标签 javascript google-visualization

可以从折线图谷歌图表中的点向下画一条线(点线和直线)吗?

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Year', 'Sales'],
        ['2004', 1000],
        ['2005', 1170],
        ['2006', 660],
        ['2007', 1030]
    ]);

var options = {
    title: 'Company Performance',
    pointSize: 10
};

var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);

这个概念是这样的...... enter image description here

http://jsfiddle.net/TD92C/

最佳答案

您可以通过使用 ComboChart 并使用 DataView 来复制数据系列来伪造这些线条。将第一个系列设置为“线”类型,将第二个系列设置为“条”类型。禁用条形图上的交互性并从图表图例中删除该系列。使用 bar.groupWidth 选项缩小绘制的条形,使其类似于线条:

bar: {
    // use this to set the width of the vertical lines
    groupWidth: 2
},
series: {
    0: {
        // this is the line series
        type: 'line',
        pointSize: 10
    },
    1: {
        // this creates the vertical "lines" down from the points
        type: 'bars',
        color: '#666666',
        enableInteractivity: false,
        visibleInLegend: false
    }
}

请参阅此处的示例 http://jsfiddle.net/asgallant/TD92C/1/ .

关于javascript - 谷歌图表折线图上的直线向下?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18245595/

相关文章:

javascript - 删除 Google 可视化饼图中的图例

javascript - html 和 js 文本字段数据 (DD-MM-YYYY) 验证

javascript - 如何创建像树这样的预期对象

javascript - 如何将json数据添加到数组onClick?

javascript - 谷歌可视化图表区域背景

javascript - 如何触发Google Chart内文本 anchor 的选择事件?

javascript - 在 asp.net 中加载页面之前将 javascript 值发送到服务器

javascript - GET 到 POST 不工作

api - Google 图表网格颜色

google-visualization - 谷歌折线图 API 用于 haxis 日期