How to use Visual Studio Charts to draw a 'Manhattan* Chart'? - visual-studio

*This is a name I have seen used for the style of chart I'm after - not sure how 'official' this name is.
What I would like:
Bar Chart
X - Day of the Week
Y - Number of items
Z - Week Number, receding back into the chart.
I'm not sure that the Chart Control can do it, but I might be missing something in the many many properties and settings the control has.

After a hint from pnuts. i've dug in an read up some more on the Chart Control....
I've created a 3D 'Manhattan' style chart. There's the datasource selects data with columns such as DayName, NumberOfOrders and WeekNo.
The chart should have clustering turned off and you need to use a special databinding method.
Chart1.DataBindCrossTable(ds.GetYearsOrdersByDay, "WeekNo", "DayName", "NumberOfOrders", null);
This creates several series based on the dataset and the parameters.
Basic markup
<asp:Chart ID="Chart1" runat="server" Height="600px" Width="700px">
<Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
<Area3DStyle Enable3D="True" IsClustered="false" Perspective="20"/>
<AxisY Interval="100"></AxisY>
<AxisX IntervalOffset ="1.0" Interval ="1.0" >
<MajorGrid Enabled="true" Interval="1.0" IntervalOffset="0.5" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Name="Legend1" Title="Number of Orders">
</asp:Legend>
</Legends>
</asp:Chart>

Related

Recharts square zoom implementation

The sample I am talkin' about is here
https://recharts.org/en-US/examples/HighlightAndZoomLineChart
and here
https://codesandbox.io/s/highlight-zomm-line-chart-v77bt
Please press left button of the mouse and drag it to the right - this is how zoom is currently done. Please take a look at the activeLabel variable.
Currently recharts could make a zoom into the graph by passing the x coordinate (which is stored in activeLabel variable) and zooom looks like a pillar all over the y coordinate.
I want to select an area - square or rectangle to make more customized zoom. The trouble is that I can't get the y value of the graph (not pixel in window). Recharts gives only x coordinate of the graph, but not y.
I've searched all over the issues on gitHub, mailed the creator with no luck.
I've read the
Recharts value at pointer to show in tooltip?
but I could not get how could I count the initial values of chartX and chartY in my responsive container, so it is very depends on the window user has.
Please help me to find a solution to match chartY in pixels to my real values in my chart depending on Responsive Container I am using.
Zoom can be done by using the mouse events of the chart.
You can store the values in a state then call the zoom function on onMouseUp.
And in zoom function, you can set the domains of the axes.
Don't forget to set the axes to allowDataOverflow.
And you can also draw the rectangle by using ReferenceArea
function zoom () {
setXAxisBoundaries([rectangle[0], rectangle[1]])
setYAxisBoundaries([rectangle[2], rectangle[3]])
}
<ScatterChart
onMouseDown={(event) => setRectangle([event.xValue, event.yValue])}
onMouseMove={(event) => setRectangle(rectangle => [...rectangle, event.xValue, event.yValue]))}
onMouseUp={zoom}>
<XAxis
dataKey="x"
allowDataOverflow
domain={xAxisBoundaries}
type="number" />
<YAxis
dataKey="y"
allowDataOverflow
domain={yAxisBoundaries}
type="number" />

How to display bars from left to right with a fixed bar gap?

I want to display bars from left to right with a fixed bar gap, rather than display them evenly.
I have tried to add barCategoryGap or barGap prop with fixed number, but no influence for the chart like this:
And my code is:
<BarChart data={data} barSize={10} barCategoryGap={1}>
<YAxis
...some props
/>
<Tooltip />
<Bar dataKey="responseTime">
{data.map((item, index) => (
<Cell fill={item.isPass ? '#3c763d' : '#a94442'} key={index} />
))}
</Bar>
</BarChart>
In your graph, you don't have any XAxis specified to group your bars into categories. Because of this, the props barGap and barCategoryGap won't work, since there is no category to make changes on.
To solve your problem, you should add the missing XAxis which datakey would be a prop in your data object array, that shares the same object where your Bars values come from so that they can be regrouped. Afterwards you can "play" around with the gap between the different bars, just like a demo found on Recharts for Bars.

Recharts X-Axis auto not showing most values in ticks for times?

I've just converted my project from using react vis over to recharts. I'm currently looking into why the ticks aren't showing as expected. There are 96 datapoints that should be showing up and the cartesian grid shows them, but no tick labels appear other than the few at weird times not aligned to the datapoints I provide. (The tick marks should be at a 30 minute interval.)
Is there a way to have the ticks show up just where I specify them in the data?
This is what I currently have (I thought "interval" was supposed to make all the ticks appear). I have the time specified as milliseconds and then format them, which seems to work for the most part.
<LineChart data={datapoints}>
<XAxis dataKey="x"
domain = {['auto', 'auto']}
name = 'Time'
tickFormatter = {(unixTime) => moment(unixTime).format('HH:mm')}
interval={0}
type = 'number'/>
<YAxis />
<CartesianGrid/>
<Tooltip/>
<Legend/>
{this.props.yLines.map(lineKey => {
return <Line dot={false} type="monotone" dataKey={lineKey} isAnimationActive={false}/>
})}
</LineChart>
And this is what is showing up:
Vs what I would expect (all intervals showing)
Update: I have since added tickCount={96} (like I had with react-vis) but the times are still at weird increments. Like 6:33, 8:20, etc. instead of 30 minute increments.
Any help would be appreciated!
You can use interval={0} in your XAxis. It will show all tick
Use scale="time" in your XAxis.

leader lines in FetchXML

I have a pie chart in Dynamics CRM that has the values of the segments listed outside of the pie chart. However I am trying to get the leader lines to display from the chart to the values. What property am I missing? Here is the XML.
<Series>
<Series ShadowOffset="0" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Outside, LabelsHorizontalLineSize=1, LabelsRadialLineSize=1, PieDrawingStyle=SoftEdge" ChartType="doughnut">
<SmartLabelStyle Enabled="True" />
</Series>
</Series>
The reason the lines were not showing up was because the attribute PieLineColor was not set to a color

Flex Chart Sorting ColumnSeries Order

I am trying to create a BarChart that will display values within a ColumnSeries in an order dependant of there value.
So for instance, If I had a ColumnSeries in a BarChart , one showing profit, the other showing expenses, it will render correctly if the profit is more than the expenses because the expenses series is rendered on top.
However, if the expenses is more than profit, the profit will not be viewable as it will be rendered underneath expenses.
At this point I am going to try and include an image to display my problem...
OK it turns out that I am not allowed to display an image :(
The image did show that profit in February is 500 but the profit of 300 in January is hidden because the Expenses of 500 is displaying over it.
You can run the code below to create the example:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var expenses:ArrayCollection = new ArrayCollection([
{Month:"Jan", Profit:300, Expenses:500},
{Month:"Feb", Profit:500, Expenses:300}
]);
]]></mx:Script>
<mx:Panel title="Bar Chart">
<mx:BarChart id="myChart" dataProvider="{expenses}" showDataTips="true" type="overlaid" >
<mx:verticalAxis>
<mx:CategoryAxis dataProvider="{expenses}" categoryField="Month" />
</mx:verticalAxis>
<mx:series>
<mx:BarSeries yField="Month" xField="Profit" displayName="Profit" />
<mx:BarSeries yField="Month" xField="Expenses" displayName="Expenses" />
</mx:series>
</mx:BarChart>
<mx:Legend dataProvider="{myChart}"/>
</mx:Panel>
An obvious solution to this would be to make the BarChart type 'clustered' as both values will be seen, however my client requires the BarChart to be 'overlaid', so currently some smaller values are hidden.
I would expect that there is a way to sort the order of the BarSeries but I cant seem to find how and I would really appreciate someone's superior knowledge on charting. ;)

Resources