質問

I have a bar chart with four data points. I am trying to add a line to represent the average of the bars. When I add the line as a chartseries, it adds the line, but it also as the fifth bar.

How do I get a single red line to represent the average?

<cfchart format="png" scalefrom="0" scaleto="5000">
<!--- four blue bars --->
<cfchartseries
  type="bar"
  serieslabel="Website Traffic 2006"
  seriescolor="blue">
<cfchartdata item="January" value="1000">
<cfchartdata item="February" value="2000">
<cfchartdata item="March" value="3000">
<cfchartdata item="April" value="4000">
</cfchartseries>
<!--- one red line --->
<cfchartseries
    type="line"     
    seriesColor="red" 
    paintStyle="plain"
    seriesLabel="Contract Salaries">
<cfchartdata item="average" value="2500">
</cfchartseries></cfchart>
役に立ちましたか?

解決

Here is a solution that works. Basically, you have to REUSE the same item name in the line chart as you do in the bar chart to ensure that you do not introduce a new bar/x-axis point. You do not have to define all four matching points, but to me it seems like that would be good practice. The key to your problem though is to not introduce a new "item" name that results in a new bar. In my example, I just reused "January".

<cfchart format="png" scalefrom="0" scaleto="5000">
<!--- four blue bars --->
<cfchartseries
  type="bar"
  serieslabel="Website Traffic 2006"
  seriescolor="blue">
<cfchartdata item="January" value="1000">
<cfchartdata item="February" value="2000">
<cfchartdata item="March" value="3000">
<cfchartdata item="April" value="4000">
</cfchartseries>
<!--- one red line --->
<cfchartseries
    type="line"
    seriesColor="red"
    paintStyle="plain"
    seriesLabel="Contract Salaries">
<cfchartdata item="January" value="2500">
</cfchartseries>
</cfchart>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top