1

Highcharts v3.01

我正在尝试使用散点图在命名类别中绘制点(这些实际上是数字,但不属于系列,我不想要间隙)。

使用折线图类型会起作用,但我宁愿不这样做,因为我可能有数百个系列并且散点更清晰。

我最接近的是:

编辑 - 我会发布描述性图片,但显然我需要声誉积分。叹。

请看这里:http: //i117.photobucket.com/albums/o63/Harry_Flashman/close_zpsfe6d3ea2.png

这是使用引用 x 和 y 的点,

data: [{x:108432,test:100,y:0}, {x:109802,test:100,y:51}, etc. ]

我想完全按照上面的方式做,但没有差距。

我可以看到拥有非线性无间隙轴的唯一方法是使用类别,我以前在其他线型图上使用过,但从来没有使用散点图。

如果我将 x 轴类型“类别”与类别数组一起使用,则它只为每个类别分配一个散点值,其余分配给升序数字类别(即,如果我使用点“名称”选项,它不会对它们进行分组) .

xAxis: {
  type: category,
  categories: ['108432','109802','110240', etc. ]
}

数据点如下所示:

data: [{name:'108432',test:100,y:0}, {name:'109802',test:100,y:51}, etc. ]

就这样结束了。每个散点都有自己的类别。

http://i117.photobucket.com/albums/o63/Harry_Flashman/not_zps31aa4fef.png

任何帮助表示赞赏,如果我能让它工作,那就太好了。

谢谢!

PS。在下方添加了整个图表脚本(减去大量数据)。这是“几乎可以工作”的版本。

$('#container').highcharts({
  chart:    { type: 'scatter', zoomType: 'xy'     },
  title:    { text: 'Revision vs Runtime Scatter' },
  subtitle: { text: 'L3 Performance Test'         },
  xAxis:    {
    title:      { enabled: true, text: 'Revision' },
    startOnTick:   true,
    endOnTick:     true,
    showLastLabel: true,
    showEmpty:     false,
    legend:      { y: 120, floating: true, backgroundColor: '#FFFFFF' },
    labels:      { rotation: -90, align: 'right' },
    categories:  ['101831','101849','101850','101857','101861','101866','101868','101878','101879','101880','101881','101882','101883','101884','101885','101888','101894','101900','101903','101905','101908','101913','101914']
  },
  yAxis:       { title: { text: 'Variance (%)' } },
  legend:      { layout: 'vertical' },
  plotOptions: {
    scatter: {
      marker: { radius: 5, states: { hover: { enabled: true, lineColor: 'rgb(100,100,100)' } } },
        states: { hover: { marker: { enabled: false } } },
        tooltip: {
          headerFormat: '<b></b>',
          pointFormat: '<b>Test {point.test}</b><br/>r{point.x}<br/>{point.y}% change<br/>{series.name}'
        }
      }
    },
    series: [{
      name: 'PRd',
      data: [{x:101857,test:267,y:0}, {x:101861,test:267,y:-1}, {x:101866,test:267,y:-0}, {x:101868,test:267,y:-1}, {x:101878,test:267,y:-1}, {x:101879,test:267,y:-1}, {x:101880,test:267,y:-0}, {x:101881,test:267,y:-0}, {x:101882,test:267,y:-0}, {x:101883,test:267,y:-0}, {x:101884,test:267,y:-0}, {x:101885,test:267,y:-0}, {x:101888,test:267,y:-0}, {x:101894,test:267,y:-1}, {x:101900,test:267,y:-0}, {x:101903,test:267,y:-0}, {x:101905,test:267,y:-1}, {x:101908,test:267,y:-1}, {x:101913,test:267,y:0}, {x:101914,test:267,y:1}, {x:101831,test:430,y:0}, {x:101849,test:430,y:1}, {x:101850,test:430,y:1}]
      }, {
      name: 'Non-PRd',
      data: [{x:101831,test:100,y:0}, {x:101849,test:100,y:51}, {x:101850,test:100,y:51}, {x:101857,test:100,y:52}, {x:101861,test:100,y:49}, {x:101866,test:100,y:50}, {x:101868,test:100,y:50}, {x:101878,test:100,y:50}, {x:101879,test:100,y:50}, {x:101880,test:100,y:50}, {x:101881,test:100,y:50}, {x:101882,test:100,y:50}, {x:101883,test:100,y:50}, {x:101884,test:100,y:50}, {x:101885,test:100,y:50}, {x:101888,test:100,y:50}, {x:101894,test:100,y:50}, {x:101900,test:100,y:50}, {x:101903,test:100,y:0}, {x:101905,test:100,y:50}, {x:101908,test:100,y:51}, {x:101913,test:100,y:50}, {x:101914,test:100,y:50}, {x:101831,test:10937,y:0}, {x:101849,test:10937,y:2}]
    }]
  });
});
4

1 回答 1

4

好的,通过解决方法修复它,

基本上在 Javascript 中,我在点数组中添加了一个位置,该位置与该点所属的类别相关(通过 PHP 生成,类别按升序排序)。相关位如下:

xAxis:    {
  categories: ['r101831', 'r101849', 'r101850']
}   

plotOptions: {
  tooltip: {
    headerFormat: '<b></b>',
    pointFormat: '
      <b>Test {point.test}</b><br/>
      r{point.revision}<br/>
      {point.y}% change<br/>
      {series.name}'
  }
}

series: [{
  name: 'PRd',
  data: [
  {x:3,revision:101831,test:267,y:0},
  {x:4,revision:101849,test:267,y:-1},
  {x:5,revision:101850,test:267,y:-0}
  ]}
]

最终结果看起来很漂亮,我喜欢 HighCharts。

图片在这里:http: //i117.photobucket.com/albums/o63/Harry_Flashman/fixed_zps9952d58d.png

于 2013-05-11T05:54:08.310 回答