Highcharts重绘不使用alignTicks

时间:2014-11-16 04:11:16

标签: highcharts redraw

我已从版本2.1.6更新到4.0.4,我在刷新alignTicks选项时遇到问题。 我从属性开始,然后通过按钮将其设置为false。 从true到false,只有在Windows调整大小或禁用/启用一组数据后才会更新图形。从false回到true然后它正常工作......

这是一个例子:

chart = new Highcharts.Chart({
  'chart': {
    'renderTo': 'graph',
    'type': 'line',
    'zoomType': 'x',
    'alignTicks': true
  },
  'tooltip': {
    'formatter': function () {
      var d = new Date(this.x);
      return 'Time: <b>' + ('0' + d.getUTCHours()).slice( - 2) + ':' + ('0' + d.getUTCMinutes()).slice( - 2) + ':' + ('0' + d.getUTCSeconds()).slice( - 2) + '</b><br/> Value: <b>' + this.y + '</b>';
    }
  },
  'credits': false,
  'title': {
    'text': 'Date: 04-11-2014 - Location: Locale'
  },
  'xAxis': {
    'type': 'datetime'
  },
  'yAxis': [
    {
      'title': {
        'text': 'SK_angle',
        'style': {
          'color': '#4572A7'
        }
      },
      'labels': {
        'style': {
          'color': '#4572A7'
        }
      },
      'opposite': false,
      'allowDecimals': true
    },
    {
      'title': {
        'text': 'EL_angle',
        'style': {
          'color': '#AA4643'
        }
      },
      'labels': {
        'style': {
          'color': '#AA4643'
        }
      },
      'opposite': true,
      'allowDecimals': true
    },
    {
      'title': {
        'text': 'Software Status',
        'style': {
          'color': '#89A54E'
        }
      },
      'labels': {
        'style': {
          'color': '#89A54E'
        }
      },
      'opposite': false,
      'allowDecimals': false
    }
  ],
  'series': [
    {
      'color': '#4572A7',
      'name': 'SK_angle',
      'yAxis': 0,
      'data': [
        [1415064918000,305.89],
        [1415064919000,335.0],
        [1415064923000,306.05],
       ]
    },
    {
      'color': '#AA4643',
      'name': 'EL_angle',
      'yAxis': 1,
      'data': [
        [1415064918000,37.87],
        [1415064919000,37.2],
        [1415064923000,37.9],
      ]
    },
    {
      'color': '#89A54E',
      'name': 'Software Status',
      'yAxis': 2,
      'data': [
        [1415064918000,1362],
        [1415064919000,1362],
        [1415064923000,1256],
      ]
    }
  ]
});

$('#scaleAlign').click(function() {
    if (chart.options.chart.alignTicks) {
        chart.options.chart.alignTicks = false;
        $('#scaleAlign').attr('value','Align Scale'); 
    }
    else {
        chart.options.chart.alignTicks = true;
        $('#scaleAlign').attr('value','Unalign Scale');
    }
    chart.isDirtyBox = true;
    chart.redraw();
});

http://jsfiddle.net/04Lffe0r/3/

1 个答案:

答案 0 :(得分:1)

更新代码如下:http://jsfiddle.net/04Lffe0r/4/

添加:

chart.series[0].isDirty = true;

因为系列应该设置为脏图表才能重绘。

相关问题