如何在Highcharts组合箱图和散点图中获取散点十字准线?

时间:2019-04-11 19:38:18

标签: highcharts dotnethighcharts

我正在尝试创建一个散点图叠加在Highcharts中的箱形图。我从Highcharts API中找到了以下示例。我正在尝试添加一个适用于散点而不是箱形图的x轴十字准线。

https://api.highcharts.com/highcharts/plotOptions.scatter.jitter https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/series-scatter/jitter-boxplot

不建议将十字线添加到图表。工具提示。

https://api.highcharts.com/highcharts/tooltip.crosshairs

所以我一直在努力将十字线添加到chart.xAxis。不幸的是,添加到xAxis会在箱形图上显示十字准线,而不是箱形图的每个散点。

xAxis: {
        categories: ['1', '2', '3', '4', '5'],
        title: {
            text: 'Experiment No.'
        },
        crosshair: true
    },

我还尝试创建辅助x轴,该辅助x轴适用于图形的初始负载,但是在缩放时,散点与箱形图不同步。

https://jsfiddle.net/cvngt48a/

我希望上述jsfiddle中的x轴十字准线与每个散点对齐,而不是与箱形图对齐。我的实际代码在Highcharts.net v7.0.1中,但我以js为例。

*******更新*******

感谢Highsoft帮助台的GrzegorzBlachliński,我有一个适用于highcharts.js v7.0.3的解决方案。他为十字准线添加了1的宽度,现在它可以按需工作了。

https://jsfiddle.net/cvngt48a/1/

但是,此修复程序不适用于highcharts.net v7.0.1,这是我实际使用的。它似乎可以在js v7.0.1中运行(即使抖动不是有效的函数),因为十字线的宽度仍为1,而仅使用“ crosshair:true”,则十字线的宽度即为整个箱形图(即我在.net v7.0.1中看到的行为是使用crosshair:true还是尝试将其宽度设置为1)。 https://jsfiddle.net/sfzd2met/

这是我asp.net网络表单代码后面的相关代码段:

XAxis = new List<XAxis>
{
    new XAxis
    {
        //Id = "Box",
        Type = XAxisType.Category,
        Categories = legend, //List<String>
        CrosshairBool = true,
        //this is the solution per Highcharts and works in highcharts.js v7.0.3, but doesn't work in .net v7.0.1
        //Crosshair = new XAxisCrosshair
        //{
        //    Width = 1,
        //    Color = "lightgrey"
        //}
    }//,
    ////tried creating a secondary x-axis in order to implement cross hairs for tooltips based on the scatter point x-axis locations,
    ////but the two axes were only vertically aligned on initial load. upon zoom, they got out of alignment and so the scatter points
    ////were no longer within the box plot. turning on cross hairs via Chart.Tooltip only worked for the box plot crosshair.
    //new XAxis
    //{
    //    Id = "Scatter",
    //    Type = XAxisType.Linear,
    //    CrosshairBool = true
    //}
},

当我探索实际的网页元素时,我可以看到该图的svg path标记中的highcharts-crosshair的笔触为:lightgrey,笔触宽度为30。因此,它会出现XAxisCrosshair类的Width属性。实际上不起作用,但是颜色起作用。如果我通过Chrome开发人员工具手动编辑网页,则可以得到1px宽的十字准线,因此我开始认为此问题是.net v7.0.1错误。有人对解决方案有其他建议/想法吗?升级到v7.0.3对于我的项目是可行的,但不是快速解决方案,因此我希望有其他选择,尽管如果有人可以确认它可以在.net v7.0.3中工作,那将是最有用的。

0 个答案:

没有答案