FusionCharts - 将图像添加到散点图(XML,C# MVC)

FusionCharts - Adding images to a scatter chart(XML,C# MVC)

我对 Fusioncharts 还很陌生,并且很难将图像添加到我的 Fusionchart。请原谅我,我什至不知道我应该怎么问这个问题,所以如果您希望我添加的数据会有所帮助,请告诉我。

我目前通过绘制 x 点和 y 点并设置锚边和锚半径来让它工作,但我想用图像替换它们,但我不知道该怎么做。

这是我使用 foreach 填充 x 和 y 轴的部分:

strXML += "<dataset  drawline= '0' seriesname= 'Peak' color= '#ff0000' anchorsides= '3' anchorradius= '5' anchorbgcolor= '#ff0000' anchorbordercolor= '#ff0000'>";

        foreach (var cat in CalcList)
        {
            if (cat.isPeak)
            {
                strXML += "<set y='" + cat.Elevation + "' x='" + cat.Accumulated_Length + "'/>";
            }
        }

        strXML += "</dataset>";

我访问了 FusionChart 网站,我看到他们做了这样的事情:

<annotations width="500" height="300" autoscale="1">
    <annotationgroup id="user-images" xscale_="20" yscale_="20">
        <annotation id="butterFinger-icon" type="image" url="http://static.fusioncharts.com/sampledata/images/butterFinger.png" x="$xaxis.label.0.x - 30" y="$canvasEndY - 150" xscale="50" yscale="40" />
        <annotation id="tom-user-icon" type="image" url="http://static.fusioncharts.com/sampledata/images/snickrs.png" x="$xaxis.label.1.x - 26" y="$canvasEndY - 141" xscale="48" yscale="38" />
        <annotation id="Milton-user-icon" type="image" url="http://static.fusioncharts.com/sampledata/images/coffee_crisp.png" x="$xaxis.label.2.x - 22" y="$canvasEndY - 134" xscale="43" yscale="36" />
        <annotation id="Brian-user-icon" type="image" url="http://static.fusioncharts.com/sampledata/images/100grand.png" x="$xaxis.label.3.x - 22" y="$canvasEndY - 131" xscale="43" yscale="35" />
    </annotationgroup>
</annotations>

所以我自己试过了,但它给了我一个错误:

 //Peak Images
        strXML += "<annotations>";
        strXML += "<annotationgroup>";

         foreach (var cat in CalcList)
        {
            if (cat.isPeak)
            {
                strXML += "<annotation id='Test' type='image' url='http://static.fusioncharts.com/sampledata/userimages/1.png' x='$dataset.0.set." + iPeakCount +".x-" + cat.Elevation + "' y='$dataset.0.set." + iPeakCount + ".y-" + cat.Accumulated_Length + "'/>  ";
                iPeakCount++;
            }
        }

        strXML += "<annotationgroup>";
        strXML += "<annotations>";

但我正在从 FusionChart 返回 "Invalid data"。

我们之前用 json 做了类似的测试,所以我们知道这是可能的——除了我想用 XML 做(我已经做了),但只是有不知道该怎么做 :( - 下面是代码片段 :

                    "annotations": {
                        "groups": [
                            {
                                "id": "anchor-highlight",
                                "items": [
                                    {
                                        "id": "high-star",
                                        "type": "image",
                                        "url": "http://static.fusioncharts.com/sampledata/userimages/1.png",
                                        "x": "$dataset.0.set.11.x-25",
                                        "y": "$dataset.0.set.11.y-25"
                                    },
                                    {
                                        "id": "high-star",
                                        "type": "image",
                                        "url": "http://static.fusioncharts.com/sampledata/userimages/1.png",
                                        "x": "$dataset.0.set.6.x-25",
                                        "y": "$dataset.0.set.6.y-25"
                                    }
                        ]
                            }
                        ]
                    },

我是完全错过了剧情还是错过了什么?

请对我温柔一点,这对我来说是全新的,我很挣扎。

提前致谢。

自己又找到了答案...

下面是代码:

strXML += "<annotations>";
strXML += "<annotationgroup>";

        foreach (var cat in CalcList)
        {
            if (cat.isPeak)
            {
                strXML += "<annotation id='Peak" + iPeakCount + "' type='image' url='/Images/Peak.png' x='$dataset.2.set." + iPeakCount + ".x-12' y='$dataset.2.set." + iPeakCount + ".y-12' xscale='6' yscale='6' />";
                iPeakCount++;
            }
        }

strXML += "</annotationgroup>";
strXML += "</annotations>";

您会注意到以下内容:

x='$dataset.2.set." + iPeakCount + ".x-12' y='$dataset.2.set." + iPeakCount + ".y-12'

数字 2 表示它必须显示在我的第三个数据集上(数据集从 0 开始)。以下是其中一个数据集:

strXML += "<dataset  drawline= '1' seriesname= 'Elevation' color= '#0045ff' anchorsides= '0' anchorradius= '0' anchorbgcolor= '#0045ff' anchorbordercolor= '#0045ff'>";

        foreach (var cat in CalcList)
        {
            if (cat.Elevation >= 0)
            {
                strXML += "<set y='" + cat.Elevation + "' x='" + cat.Accumulated_Length + "'/>";
            }
        }

strXML += "</dataset>";

希望这对其他人有帮助...