我对fusioncharts很新,并且很难将图像添加到我的Fusionchart中。请原谅我,我甚至不知道我应该怎么问这个问题,所以如果你想要我添加的数据会有所帮助,请告诉我。
我目前通过绘制x和y点以及设置anchorsides和anchorradius来实现它,但是我想用图像替换这些并且我不知道如何。
以下是我使用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回来了“无效数据”。
我们之前使用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"
}
]
}
]
},
我是否完全错过了情节或者我错过了什么?
请温柔地对我说,这对我来说都是新手,而且我正在苦苦挣扎。
提前感谢你。
答案 0 :(得分:0)
再次找到答案......
以下是代码:
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>";
希望这有助于其他人...