Jump to content
Software FX Community

Creating a chart where each bar shows a region of a bitmap


JuanC

Recommended Posts

This one is a little hard to describe but I am sure you have seen it before in magazines or newspapers. Although our API allows you to set brushes in code we will try to do all it XAML as it will allow more tweaking later. Here is our first attempt at showing an image on each bar

[color= blue]<[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]Chart [/color][color= red]Gallery[/color][color= blue]="Bar"[/color][color= blue]>  <[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]Chart.Series[/color][color= blue]>    <[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]SeriesAttributes[/color][color= blue]/>  </[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]Chart.Series[/color][color= blue]>  <[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]Chart.AllSeries[/color][color= blue]>    <[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]AllSeriesAttributes[/color][color= blue]>      <[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]AllSeriesAttributes.Template[/color][color= blue]>        <[/color][color= #a31515]DataTemplate[/color][color= blue]>          <[/color][color= #a31515]Canvas[/color][color= blue]>            <[/color][color= #a31515]Rectangle [/color][color= red]Width[/color][color= blue]="{[/color][color= #a31515]Binding [/color][color= red]Path[/color][color= blue]=Width}" [/color][color= red]Height[/color][color= blue]="{[/color][color= #a31515]Binding [/color][color= red]Path[/color][color= blue]=Height}">              <[/color][color= #a31515]Rectangle.Fill[/color][color= blue]>                <[/color][color= #a31515]ImageBrush [/color][color= red]ImageSource[/color][color= blue]="C:\Temp\WorldMap.png"/[/color][color= blue]>              </[/color][color= #a31515]Rectangle.Fill[/color][color= blue]>            </[/color][color= #a31515]Rectangle[/color][color= blue]>          </[/color][color= #a31515]Canvas[/color][color= blue]>        </[/color][color= #a31515]DataTemplate[/color][color= blue]>      </[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]AllSeriesAttributes.Template[/color][color= blue]>    </[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]AllSeriesAttributes[/color][color= blue]>  </[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]Chart.AllSeries[/color][color= blue]></[/color][color= #a31515]cfx[/color][color= blue]:[/color][color= #a31515]Chart[/color][color= blue]>[/color]

Nothing earth shattering, we are binding width and height of the rectangle to the Width and Height of the logical items we will create, note that we do not need to worry about Left and Top, this is handled internally. We are creating a Canvas because we plan to add more visual elements later. And this is what we get.

Posted Image

Obviously this is not what we are looking for, actually there is no feature that I am aware of in WPF that allows you to draw a rectangle and specify the

Link to comment
Share on other sites

  • 2 years later...
  • 9 months later...
  • 2 weeks later...
×
×
  • Create New...